python3 console input_Python console.colorize方法代码示例
本文整理汇总了Python中pygments.console.colorize方法的典型用法代码示例。如果您正苦于以下问题:Python console.colorize方法的具体用法?Python console.colorize怎么用?Python console.colorize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在模块pygments.console的用法示例。
在下文中一共展示了console.colorize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
点赞 6
# 需要导入模块: from pygments import console [as 别名]
# 或者: from pygments.console import colorize [as 别名]
def __init__(self, **options):
Formatter.__init__(self, **options)
# We ignore self.encoding if it is set, since it gets set for lexer
# and formatter if given with -Oencoding on the command line.
# The RawTokenFormatter outputs only ASCII. Override here.
self.encoding = 'ascii' # let pygments.format() do the right thing
self.compress = get_choice_opt(options, 'compress',
['', 'none', 'gz', 'bz2'], '')
self.error_color = options.get('error_color', None)
if self.error_color is True:
self.error_color = 'red'
if self.error_color is not None:
try:
colorize(self.error_color, '')
except KeyError:
raise ValueError("Invalid color %r specified" %
self.error_color)
开发者ID:joxeankoret,项目名称:pigaios,代码行数:19,
示例2: i18n_validate_gettext
点赞 6
# 需要导入模块: from pygments import console [as 别名]
# 或者: from pygments.console import colorize [as 别名]
def i18n_validate_gettext():
"""
Make sure GNU gettext utilities are available
"""
returncode = subprocess.call(['which', 'xgettext'])
if returncode != 0:
msg = colorize(
'red',
"Cannot locate GNU gettext utilities, which are "
"required by django for internationalization.\n (see "
"https://docs.djangoproject.com/en/dev/topics/i18n/"
"translation/#message-files)\nTry downloading them from "
"http://www.gnu.org/software/gettext/ \n"
)
sys.stderr.write(msg)
sys.exit(1)
开发者ID:jruiperezv,项目名称:ANALYSE,代码行数:21,
示例3: i18n_validate_transifex_config
点赞 6
# 需要导入模块: from pygments import console [as 别名]
# 或者: from pygments.console import colorize [as 别名]
def i18n_validate_transifex_config():
"""
Make sure config file with username/password exists
"""
home = path('~').expanduser()
config = home / '.transifexrc'
if not config.isfile or config.getsize == 0:
msg = colorize(
'red',
"Cannot connect to Transifex, config file is missing"
" or empty: {config} \nSee "
"http://help.transifex.com/features/client/#transifexrc \n".format(
config=config,
)
)
sys.stderr.write(msg)
sys.exit(1)
开发者ID:jruiperezv,项目名称:ANALYSE,代码行数:21,
示例4: run_bokchoy
点赞 6
# 需要导入模块: from pygments import console [as 别名]
# 或者: from pygments.console import colorize [as 别名]
def run_bokchoy(**opts):
"""
Runs BokChoyTestSuite with the given options.
If a default store is not specified, runs the test suite for 'split' as the default store.
"""
if opts['default_store'] not in ['draft', 'split']:
msg = colorize(
'red',
'No modulestore specified, running tests for split.'
)
print(msg)
stores = ['split']
else:
stores = [opts['default_store']]
for store in stores:
opts['default_store'] = store
test_suite = BokChoyTestSuite('bok-choy', **opts)
test_suite.run()
开发者ID:jruiperezv,项目名称:ANALYSE,代码行数:21,
示例5: bokchoy_coverage
点赞 6
# 需要导入模块: from pygments import console [as 别名]
# 或者: from pygments.console import colorize [as 别名]
def bokchoy_coverage():
"""
Generate coverage reports for bok-choy tests
"""
Env.BOK_CHOY_REPORT_DIR.makedirs_p()
coveragerc = Env.BOK_CHOY_COVERAGERC
msg = colorize('green', "Combining coverage reports")
print(msg)
sh("coverage combine --rcfile={}".format(coveragerc))
msg = colorize('green', "Generating coverage reports")
print(msg)
sh("coverage html --rcfile={}".format(coveragerc))
sh("coverage xml --rcfile={}".format(coveragerc))
sh("coverage report --rcfile={}".format(coveragerc))
开发者ID:jruiperezv,项目名称:ANALYSE,代码行数:20,
示例6: format
点赞 5
# 需要导入模块: from pygments import console [as 别名]
# 或者: from pygments.console import colorize [as 别名]
def format(self, tokensource, outfile):
try:
outfile.write(b'')
except TypeError:
raise TypeError('The raw tokens formatter needs a binary '
'output file')
if self.compress == 'gz':
import gzip
outfile = gzip.GzipFile('', 'wb', 9, outfile)
def write(text):
outfile.write(text.encode())
flush = outfile.flush
elif self.compress == 'bz2':
import bz2
compressor = bz2.BZ2Compressor(9)
def write(text):
outfile.write(compressor.compress(text.encode()))
def flush():
outfile.write(compressor.flush())
outfile.flush()
else:
def write(text):
outfile.write(text.encode())
flush = outfile.flush
if self.error_color:
for ttype, value in tokensource:
line = "%s\t%r\n" % (ttype, value)
if ttype is Token.Error:
write(colorize(self.error_color, line))
else:
write(line)
else:
for ttype, value in tokensource:
write("%s\t%r\n" % (ttype, value))
flush()
开发者ID:joxeankoret,项目名称:pigaios,代码行数:38,
示例7: wait_for_test_servers
点赞 5
# 需要导入模块: from pygments import console [as 别名]
# 或者: from pygments.console import colorize [as 别名]
def wait_for_test_servers():
"""
Wait until we get a successful response from the servers or time out
"""
for service, info in Env.BOK_CHOY_SERVERS.iteritems():
ready = wait_for_server("0.0.0.0", info['port'])
if not ready:
msg = colorize(
"red",
"Could not contact {} test server".format(service)
)
print(msg)
sys.exit(1)
开发者ID:jruiperezv,项目名称:ANALYSE,代码行数:16,
示例8: check_mongo
点赞 5
# 需要导入模块: from pygments import console [as 别名]
# 或者: from pygments.console import colorize [as 别名]
def check_mongo():
"""
Check that mongo is running
"""
if not is_mongo_running():
msg = colorize('red', "Mongo is not running locally.")
print(msg)
sys.exit(1)
开发者ID:jruiperezv,项目名称:ANALYSE,代码行数:10,
示例9: check_mysql
点赞 5
# 需要导入模块: from pygments import console [as 别名]
# 或者: from pygments.console import colorize [as 别名]
def check_mysql():
"""
Check that mysql is running
"""
if not is_mysql_running():
msg = colorize('red', "MySQL is not running locally.")
print(msg)
sys.exit(1)
开发者ID:jruiperezv,项目名称:ANALYSE,代码行数:10,
示例10: __exit__
点赞 5
# 需要导入模块: from pygments import console [as 别名]
# 或者: from pygments.console import colorize [as 别名]
def __exit__(self, exc_type, exc_value, traceback):
super(BokChoyTestSuite, self).__exit__(exc_type, exc_value, traceback)
msg = colorize('green', "Cleaning up databases...")
print(msg)
# Clean up data we created in the databases
sh("./manage.py lms --settings bok_choy flush --traceback --noinput")
bokchoy_utils.clear_mongo()
开发者ID:jruiperezv,项目名称:ANALYSE,代码行数:11,
示例11: run_test
点赞 5
# 需要导入模块: from pygments import console [as 别名]
# 或者: from pygments.console import colorize [as 别名]
def run_test(self):
"""
Runs a self.cmd in a subprocess and waits for it to finish.
It returns False if errors or failures occur. Otherwise, it
returns True.
"""
cmd = self.cmd
sys.stdout.write(cmd)
msg = colorize(
'green',
'\n{bar}\n Running tests for {suite_name} \n{bar}\n'.format(suite_name=self.root, bar='=' * 40),
)
sys.stdout.write(msg)
sys.stdout.flush()
kwargs = {'shell': True, 'cwd': None}
process = None
try:
process = subprocess.Popen(cmd, **kwargs)
process.communicate()
except KeyboardInterrupt:
kill_process(process)
sys.exit(1)
else:
return (process.returncode == 0)
开发者ID:jruiperezv,项目名称:ANALYSE,代码行数:30,
示例12: report_test_results
点赞 5
# 需要导入模块: from pygments import console [as 别名]
# 或者: from pygments.console import colorize [as 别名]
def report_test_results(self):
"""
Writes a list of failed_suites to sys.stderr
"""
if len(self.failed_suites) > 0:
msg = colorize('red', "\n\n{bar}\nTests failed in the following suites:\n* ".format(bar="=" * 48))
msg += colorize('red', '\n* '.join([s.root for s in self.failed_suites]) + '\n\n')
else:
msg = colorize('green', "\n\n{bar}\nNo test failures ".format(bar="=" * 48))
print(msg)
开发者ID:jruiperezv,项目名称:ANALYSE,代码行数:13,
示例13: format
点赞 5
# 需要导入模块: from pygments import console [as 别名]
# 或者: from pygments.console import colorize [as 别名]
def format(self, tokensource, outfile):
try:
outfile.write(b'')
except TypeError:
raise TypeError('The raw tokens formatter needs a binary '
'output file')
if self.compress == 'gz':
import gzip
outfile = gzip.GzipFile('', 'wb', 9, outfile)
def write(text):
outfile.write(text.encode())
flush = outfile.flush
elif self.compress == 'bz2':
import bz2
compressor = bz2.BZ2Compressor(9)
def write(text):
outfile.write(compressor.compress(text.encode()))
def flush():
outfile.write(compressor.flush())
outfile.flush()
else:
def write(text):
outfile.write(text.encode())
flush = outfile.flush
if self.error_color:
for ttype, value in tokensource:
line = "%s\t%r\n" % (ttype, value)
if ttype is Token.Error:
write(colorize(self.error_color, line))
else:
write(line)
else:
for ttype, value in tokensource:
write("%s\t%r\n" % (ttype, value))
flush()
开发者ID:pygments,项目名称:pygments,代码行数:41,
示例14: test_console_functions
点赞 5
# 需要导入模块: from pygments import console [as 别名]
# 或者: from pygments.console import colorize [as 别名]
def test_console_functions():
assert console.reset_color() == console.codes['reset']
assert console.colorize('blue', 'text') == \
console.codes['blue'] + 'text' + console.codes['reset']
开发者ID:pygments,项目名称:pygments,代码行数:6,
示例15: coverage
点赞 4
# 需要导入模块: from pygments import console [as 别名]
# 或者: from pygments.console import colorize [as 别名]
def coverage(options):
"""
Build the html, xml, and diff coverage reports
"""
compare_branch = getattr(options, 'compare_branch', 'origin/master')
for directory in Env.LIB_TEST_DIRS + ['cms', 'lms']:
report_dir = Env.REPORT_DIR / directory
if (report_dir / '.coverage').isfile():
# Generate the coverage.py HTML report
sh("coverage html --rcfile={dir}/.coveragerc".format(dir=directory))
# Generate the coverage.py XML report
sh("coverage xml -o {report_dir}/coverage.xml --rcfile={dir}/.coveragerc".format(
report_dir=report_dir,
dir=directory
))
# Find all coverage XML files (both Python and JavaScript)
xml_reports = []
for filepath in Env.REPORT_DIR.walk():
if filepath.basename() == 'coverage.xml':
xml_reports.append(filepath)
if not xml_reports:
err_msg = colorize(
'red',
"No coverage info found. Run `paver test` before running `paver coverage`.\n"
)
sys.stderr.write(err_msg)
else:
xml_report_str = ' '.join(xml_reports)
diff_html_path = os.path.join(Env.REPORT_DIR, 'diff_coverage_combined.html')
# Generate the diff coverage reports (HTML and console)
sh(
"diff-cover {xml_report_str} --compare-branch={compare_branch} "
"--html-report {diff_html_path}".format(
xml_report_str=xml_report_str,
compare_branch=compare_branch,
diff_html_path=diff_html_path,
)
)
print("\n")
开发者ID:jruiperezv,项目名称:ANALYSE,代码行数:49,
注:本文中的pygments.console.colorize方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。
python3 console input_Python console.colorize方法代码示例相关推荐
- python3的fft_Python fft.fft方法代码示例
本文整理汇总了Python中numpy.fft.fft方法的典型用法代码示例.如果您正苦于以下问题:Python fft.fft方法的具体用法?Python fft.fft怎么用?Python fft ...
- python3版本800行的代码_Python number.long_to_bytes方法代码示例
本文整理汇总了Python中Crypto.Util.number.long_to_bytes方法的典型用法代码示例.如果您正苦于以下问题:Python number.long_to_bytes方法的具 ...
- python3 urllib3_Python urllib3.disable_warnings方法代码示例
本文整理汇总了Python中requests.packages.urllib3.disable_warnings方法的典型用法代码示例.如果您正苦于以下问题:Python urllib3.disabl ...
- Java IOUtils.copy方法代码示例(亲测)
本文整理汇总了Java中org.apache.commons.io.IOUtils.copy方法的典型用法代码示例.如果您正苦于以下问题:Java IOUtils.copy方法的具体用法?Java I ...
- python里defoults_Python Part.Compound方法代码示例
本文整理汇总了Python中Part.Compound方法的典型用法代码示例.如果您正苦于以下问题:Python Part.Compound方法的具体用法?Python Part.Compound怎么 ...
- python logging logger_Python logging.Logger方法代码示例
本文整理汇总了Python中logging.Logger方法的典型用法代码示例.如果您正苦于以下问题:Python logging.Logger方法的具体用法?Python logging.Logge ...
- python中config命令_Python config.config方法代码示例
本文整理汇总了Python中config.config方法的典型用法代码示例.如果您正苦于以下问题:Python config.config方法的具体用法?Python config.config怎么 ...
- python messagebox弹窗退出_Python messagebox.showinfo方法代码示例
本文整理汇总了Python中tkinter.messagebox.showinfo方法的典型用法代码示例.如果您正苦于以下问题:Python messagebox.showinfo方法的具体用法?Py ...
- doc python 颜色_Python wordcloud.ImageColorGenerator方法代码示例
本文整理汇总了Python中wordcloud.ImageColorGenerator方法的典型用法代码示例.如果您正苦于以下问题:Python wordcloud.ImageColorGenerat ...
最新文章
- NSIndexPath类
- 局域网访问php forbidden,PHP访问时Forbidden403错误
- ensp路由器无法启动_ensp和CRT使用小技巧
- Linux学习之基本介绍
- 论文浅尝 | Hike: A Hybrid Human-Machine Method for Entity Alignment
- Spark精华问答 | Spark和Hadoop的架构区别解读
- 通用计算机dsp采用,一种基于FPGA+DSP的通用飞控计算机平台设计
- python 多线程ping_Python快速多线程ping实现
- 爬取豆瓣电影分类排行榜
- 第一次安装Microsoft SharePoint Protal Server 2003遇到的问题
- 联想 thinkpad usb 移动硬盘 u盘 BIOS 启动 ubuntu 系统
- C语言基础-计算一个整数各个位数之和
- Docker的privileged的作用
- .[转] 全国主体功能区规划图
- Part3-4-1 搭建自己的SSR
- 洛谷 P1144 最短路计数 dijkstra
- 程序员应知必会的思维模型之 18 林纳斯定律 (Linus‘s Law)
- 记一次TX2安装向日葵
- MG动画实例——星星图标
- Python实战采集全球疫情数据
热门文章
- BZOJ - 2244 拦截导弹 (dp,CDQ分治+树状数组优化)
- 学习前端html 设置样式
- C#线程--5.0之前时代(一)--- 原理和基本使用
- asp.net mvc 从数据库中读取图片的实现代码
- IDisposable 接口介绍
- UA MATH567 高维统计专题1 稀疏信号及其恢复5 LASSO的估计误差
- UA PHYS515A 电磁理论IV 时变电磁场理论2 Helmholtz方程与含时的Green函数
- UA MATH571B 试验设计 总结 试验的类型与选择
- 图解一次Linux挂载操作和mount命令基本用法
- 图解DIV相关编程实例