日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python3 console input_Python console.colorize方法代码示例

發布時間:2025/4/5 python 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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;未經允許,請勿轉載。

《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀

總結

以上是生活随笔為你收集整理的python3 console input_Python console.colorize方法代码示例的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。