Download and docs:
http://pypi.python.org/pypi/colorama
Development:
http://code.google.com/p/colorama
Discussion group:
https://groups.google.com/forum/#!forum/python-colorama
Description
===========
Makes ANSI escape character sequences for producing colored terminal text and
cursor positioning work under MS Windows.
ANSI escape character sequences have long been used to produce colored terminal
text and cursor positioning on Unix and Macs. Colorama makes this work on
Windows, too, by wrapping stdout, stripping ANSI sequences it finds (which
otherwise show up as gobbledygook in your output), and converting them into the
appropriate win32 calls to modify the state of the terminal. On other platforms,
Colorama does nothing.
Colorama also provides some shortcuts to help generate ANSI sequences
but works fine in conjunction with any other ANSI sequence generation library,
such as Termcolor (http://pypi.python.org/pypi/termcolor.)
This has the upshot of providing a simple cross-platform API for printing
colored terminal text from Python, and has the happy side-effect that existing
applications or libraries which use ANSI sequences to produce colored output on
Linux or Macs can now also work on Windows, simply by calling
``colorama.init()``.
An alternative approach is to install 'ansi.sys' on Windows machines, which
provides the same behaviour for all applications running in terminals. Colorama
is intended for situations where that isn't easy (e.g. maybe your app doesn't
have an installer.)
Demo scripts in the source code repository prints some colored text using
ANSI sequences. Compare their output under Gnome-terminal's built in ANSI
handling, versus on Windows Command-Prompt using Colorama:
.. image:: http://colorama.googlecode.com/hg/screenshots/ubuntu-demo.png
:width: 661
:height: 357
:alt: ANSI sequences on Ubuntu under gnome-terminal.
.. image:: http://colorama.googlecode.com/hg/screenshots/windows-demo.png
:width: 668
:height: 325
:alt: Same ANSI sequences on Windows, using Colorama.
These screengrabs show that Colorama on Windows does not support ANSI 'dim
text': it looks the same as 'normal text'.
License
=======
Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file.
Dependencies
============
None, other than Python. Tested on Python 2.5.5, 2.6.5, 2.7, 3.1.2, and 3.2
Usage
=====
Initialisation
--------------
Applications should initialise Colorama using::
from colorama import init
init()
If you are on Windows, the call to ``init()`` will start filtering ANSI escape
sequences out of any text sent to stdout or stderr, and will replace them with
equivalent Win32 calls.
Calling ``init()`` has no effect on other platforms (unless you request other
optional functionality, see keyword args below.) The intention is that
applications can call ``init()`` unconditionally on all platforms, after which
ANSI output should just work.
To stop using colorama before your program exits, simply call ``deinit()``.
This will restore stdout and stderr to their original values, so that Colorama
is disabled. To start using Colorama again, call ``reinit()``, which wraps
stdout and stderr again, but is cheaper to call than doing ``init()`` all over
again.
Colored Output
--------------
Cross-platform printing of colored text can then be done using Colorama's
constant shorthand for ANSI escape sequences::
from colorama import Fore, Back, Style
print(Fore.RED + 'some red text')
print(Back.GREEN + 'and with a green background')
print(Style.DIM + 'and in dim text')
print(Fore.RESET + Back.RESET + Style.RESET_ALL)
print('back to normal now')
or simply by manually printing ANSI sequences from your own code::
print('/033[31m' + 'some red text')
print('/033[30m' # and reset to default color)
or Colorama can be used happily in conjunction with existing ANSI libraries
such as Termcolor::
from colorama import init
from termcolor import colored
# use Colorama to make Termcolor work on Windows too
init()
# then use Termcolor for all colored text output
print(colored('Hello, World!', 'green', 'on_red'))
Available formatting constants are::
Fore: BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, RESET.
Back: BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, RESET.
Style: DIM, NORMAL, BRIGHT, RESET_ALL
Style.RESET_ALL resets foreground, background and brightness. Colorama will
perform this reset automatically on program exit.
Cursor Positioning
------------------
ANSI codes to reposition the cursor are supported. See demos/demo06.py for
an example of how to generate them.
Init Keyword Args
-----------------
``init()`` accepts some kwargs to override default behaviour.
init(autoreset=False):
If you find yourself repeatedly sending reset sequences to turn off color
changes at the end of every print, then ``init(autoreset=True)`` will
automate that::
from colorama import init
init(autoreset=True)
print(Fore.RED + 'some red text')
print('automatically back to default color again')
init(strip=None):
Pass ``True`` or ``False`` to override whether ansi codes should be
stripped from the output. The default behaviour is to strip if on Windows.
init(convert=None):
Pass ``True`` or ``False`` to override whether to convert ansi codes in the
output into win32 calls. The default behaviour is to convert if on Windows
and output is to a tty (terminal).
init(wrap=True):
On Windows, colorama works by replacing ``sys.stdout`` and ``sys.stderr``
with proxy objects, which override the .write() method to do their work. If
this wrapping causes you problems, then this can be disabled by passing
``init(wrap=False)``. The default behaviour is to wrap if autoreset or
strip or convert are True.
When wrapping is disabled, colored printing on non-Windows platforms will
continue to work as normal. To do cross-platform colored output, you can
use Colorama's ``AnsiToWin32`` proxy directly::
import sys
from colorama import init, AnsiToWin32
init(wrap=False)
stream = AnsiToWin32(sys.stderr).stream
# Python 2
print >>stream, Fore.BLUE + 'blue text on stderr'
# Python 3
print(Fore.BLUE + 'blue text on stderr', file=stream)
Status & Known Problems
=======================
I've personally only tested it on WinXP (CMD, Console2), Ubuntu
(gnome-terminal, xterm), and OSX.
Some presumably valid ANSI sequences aren't recognised (see details below)
but to my knowledge nobody has yet complained about this. Puzzling.
See outstanding issues and wishlist at:
http://code.google.com/p/colorama/issues/list
If anything doesn't work for you, or doesn't do what you expected or hoped for,
I'd love to hear about it on that issues list, would be delighted by patches,
and would be happy to grant commit access to anyone who submits a working patch
or two.
Recognised ANSI Sequences
=========================
ANSI sequences generally take the form:
ESC [ <param> ; <param> ... <command>
Where <param> is an integer, and <command> is a single letter. Zero or more
params are passed to a <command>. If no params are passed, it is generally
synonymous with passing a single zero. No spaces exist in the sequence, they
have just been inserted here to make it easy to read.
The only ANSI sequences that colorama converts into win32 calls are::
ESC [ 0 m # reset all (colors and brightness)
ESC [ 1 m # bright
ESC [ 2 m # dim (looks same as normal brightness)
ESC [ 22 m # normal brightness
# FOREGROUND:
ESC [ 30 m # black
ESC [ 31 m # red
ESC [ 32 m # green
ESC [ 33 m # yellow
ESC [ 34 m # blue
ESC [ 35 m # magenta
ESC [ 36 m # cyan
ESC [ 37 m # white
ESC [ 39 m # reset
# BAC
没有合适的资源?快使用搜索试试~ 我知道了~
chromium depot_tools for macos
共876个文件
py:494个
json:70个
txt:57个
5星 · 超过95%的资源 需积分: 32 37 下载量 7 浏览量
2016-10-28
16:54:30
上传
评论
收藏 3.53MB ZIP 举报
温馨提示
chromium的depot_tools,macos版本,这是从git仓库下载下来的,更新日期2016年10月22日。 如果需要windows版本的话,可以搜索我的另一个资源chromium depot_tools for windows。
资源推荐
资源详情
资源评论
收起资源包目录
chromium depot_tools for macos (876个子文件)
git-drover.1 9KB
git-rebase-update.1 6KB
git-squash-branch.1 6KB
git-hyper-blame.1 5KB
git-map.1 5KB
git-new-branch.1 5KB
git-freeze.1 4KB
git-upstream-diff.1 4KB
git-footers.1 4KB
git-map-branches.1 4KB
git-retry.1 4KB
git-nav-upstream.1 3KB
git-nav-downstream.1 3KB
git-reparent-branch.1 3KB
git-cherry-pick-upload.1 3KB
git-mark-merge-base.1 3KB
git-rename-branch.1 2KB
git-thaw.1 2KB
depot_tools_tutorial.7 33KB
depot_tools.7 4KB
_gclient 189B
apply_issue 283B
applypatch-msg 107B
win_tools.bat 3KB
update_depot_tools.bat 2KB
gclient.bat 1KB
gclient.bat 431B
fetch.bat 426B
download_from_google_storage.bat 320B
depot-tools-auth.bat 314B
apply_issue.bat 313B
clang_format_merge_driver.bat 312B
commit_queue.bat 310B
clang-format.bat 310B
gn.bat 300B
roll-dep.bat 300B
roll-dep-svn.bat 294B
cit.bat 294B
python276.new.bat 290B
pylint.new.bat 228B
git.template.bat 142B
cpplint.bat 113B
svnversion.new.bat 85B
svn.new.bat 78B
create-ntfs-junction.c 5KB
cbuildbot 24B
copybot.cfg 2KB
cq_rietveld.cfg 2KB
sonofmmm.cfg 1KB
cq_gerrit.cfg 1KB
cq.cfg 739B
recipes.cfg 254B
chrome_set_ver 24B
chromite_wrapper 3KB
README.chromium 2KB
README.chromium 1KB
README.chromium 938B
README.chromium 362B
README.chromium 354B
README.chromium 313B
README.chromium 284B
README.chromium 237B
README.chromium 216B
README.chromium 194B
README.chromium 180B
README.chromium 103B
cit 275B
clang-format 280B
clang_format_merge_driver 293B
commit_queue 280B
config 1KB
COPYING 11KB
COPYING 11KB
cros 24B
cros_sdk 24B
style.css 5KB
asciidoc-override.css 136B
depot-tools-auth 284B
description 166B
MODIFICATIONS.diff 2KB
7z.dll 893KB
download_from_google_storage 300B
exclude 240B
ninja.exe 388KB
7z.exe 160KB
create-ntfs-junction.exe 9KB
fetch 277B
gclient 517B
git-cache 213B
git-cherry-pick-upload 213B
git-cl 217B
git-crrev-parse 2KB
git-crsync 32B
git-drover 213B
git-find-releases 213B
git-footers 213B
git-freeze 254B
git-gs 519B
git-hyper-blame 213B
git-map 223B
共 876 条
- 1
- 2
- 3
- 4
- 5
- 6
- 9
资源评论
- Darren_X_2018-09-11挺好的资源,感谢楼主分享
- AksaiChin2018-04-04挺好的资源,感谢楼主分享
还没想好昵称
- 粉丝: 11
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 1731260448754.jpeg
- 博图 博途1s保护解除DLL Siemens.Automation.AdvancedProtection.dll
- 基于Java和Shell语言的csj_21_08_20_task1设计源码分享
- 基于Typescript和Python的MNIST卷积神经网络模型加载与预测浏览器端设计源码
- 基于Python的RasaTalk语音对话语义分析系统源码
- 基于Vue框架的租车平台前端设计源码
- 基于Java和C/C++的浙江高速反扫优惠券码830主板设计源码
- 基于Java的一站式退休服务项目源码设计
- 基于Java语言实现的鼎鸿餐厅管理系统设计源码
- 基于Java的iText扩展库:简化PDF创建与中文字体应用设计源码
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功