本文整理汇总了Python中crayons.green方法的典型用法代码示例。如果您正苦于以下问题:Python crayons.green方法的具体用法?Python crayons.green怎么用?Python crayons.green使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类crayons
的用法示例。
在下文中一共展示了crayons.green方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _cstate
# 需要导入模块: import crayons [as 别名]
# 或者: from crayons import green [as 别名]
def _cstate(tw):
"""Returns state in colour for pretty printing reports."""
if isinstance(tw, ThreadWrapper):
if tw.state == ThreadState.SUCCESS:
return str(crayons.green(tw.state.name))
elif tw.state == ThreadState.FAILED:
return str(crayons.red(tw.state.name))
else:
return str(crayons.yellow(tw.state.name))
else:
if ThreadState.SUCCESS.name in tw:
return str(crayons.green(tw))
elif ThreadState.FAILED.name in tw:
return str(crayons.red(tw))
else:
return str(crayons.yellow(tw))
示例2: report
# 需要导入模块: import crayons [as 别名]
# 或者: from crayons import green [as 别名]
def report(self):
"""Method to pretty print the report."""
print("")
print(crayons.green(self.name, bold=True))
if not self.thread_map:
print(crayons.red("No jobs run in pipeline yet !"))
return
joblen = len(self.thread_map)
for i, jobs in enumerate(self.thread_map.values()):
print(crayons.blue(u"| "))
if len(jobs) == 1:
print(crayons.blue(u"\u21E8 ") + Pipe._cstate(jobs[0]))
else:
if i == joblen - 1:
pre = u" "
else:
pre = u"| "
l1 = [u"-" * 10 for j in jobs]
l1 = u"".join(l1)
l1 = l1[:-1]
print(crayons.blue(u"\u21E8 ") + crayons.blue(l1))
fmt = u"{0:^{wid}}"
l2 = [fmt.format(u"\u21E9", wid=12) for j in jobs]
print(crayons.blue(pre) + crayons.blue(u"".join(l2)))
l3 = [
Pipe._cstate(fmt.format(j.state.name, wid=12))
for j in jobs
]
print(crayons.blue(pre) + u"".join(l3))
pipes = filter(
lambda x: isinstance(x.job, Pipe), chain(*self.thread_map.values())
)
for item in pipes:
item.job.report()
示例3: _pretty_print
# 需要导入模块: import crayons [as 别名]
# 或者: from crayons import green [as 别名]
def _pretty_print(self):
"""Method to pretty print the pipeline."""
print("")
print(crayons.green(self.name, bold=True))
if not self.job_map:
print(crayons.red("No jobs added to the pipeline yet !"))
return
joblen = len(self.job_map)
for i, jobs in enumerate(self.job_map.values()):
print(crayons.blue(u"| "))
if len(jobs) == 1:
print(crayons.blue(u"\u21E8 ") + crayons.white(jobs[0].name))
else:
if i == joblen - 1:
pre = u" "
else:
pre = u"| "
l1 = [u"-" * (len(j.name) + 2) for j in jobs]
l1 = u"".join(l1)
l1 = l1[: -len(jobs[-1].name) // 2 + 1]
print(crayons.blue(u"\u21E8 ") + crayons.blue(l1))
fmt = u"{0:^{wid}}"
l2 = [fmt.format(u"\u21E9", wid=len(j.name) + 2) for j in jobs]
print(crayons.blue(pre) + crayons.blue(u"".join(l2)))
l3 = [fmt.format(j.name, wid=len(j.name) + 2) for j in jobs]
print(crayons.blue(pre) + crayons.white(u"".join(l3)))
pipes = filter(
lambda x: isinstance(x, Pipe), chain(*self.job_map.values())
)
for item in pipes:
item._pretty_print()
示例4: cli
# 需要导入模块: import crayons [as 别名]
# 或者: from crayons import green [as 别名]
def cli(ctx, verbose=False, help=False, source=None, here=False, ignore='', encoding=None):
if ctx.invoked_subcommand is None:
if source:
source = os.path.abspath(source)
click.echo(crayons.yellow(
'Target source provided: {}'.format(source)))
elif here:
source = os.getcwd()
else:
# Display help to user, if no commands were passed.
click.echo(format_help(ctx.get_help()))
sys.exit(0)
if not source:
click.echo(crayons.red(
'No project provided. Provide either --here or --source.'))
if not os.path.isdir(source):
click.echo(crayons.red('Directory does not exist.'), err=True)
sys.exit(1)
root_node = read_project(source, verbose=verbose, ignore=ignore.split(','), encoding=encoding)
click.echo(crayons.yellow(
'Project successfully transformed to AST, checking imports for cycles..'))
if check_if_cycles_exist(root_node):
click.echo(crayons.red('Cycle Found :('))
click.echo(crayons.red(get_cycle_path(root_node)))
click.echo(crayons.green("Finished."))
sys.exit(1)
else:
click.echo(crayons.green(('No worries, no cycles here!')))
click.echo(crayons.green(
'If you think some cycle was missed, please open an Issue on Github.'))
click.echo(crayons.green("Finished."))
sys.exit(0)
示例5: colordiff
# 需要导入模块: import crayons [as 别名]
# 或者: from crayons import green [as 别名]
def colordiff(a, b, fromfile='', tofile='', fromfiledate='', tofiledate='', n=3, lineterm='\n'):
for i, diff in enumerate(unified_diff(a, b, fromfile, tofile, fromfiledate, tofiledate, n, lineterm)):
if i < 2:
yield str(crayons.white(diff, bold=True))
elif diff.startswith("@"):
yield str(crayons.blue(diff))
elif diff.startswith("+"):
yield str(crayons.green(diff))
elif diff.startswith("-"):
yield str(crayons.red(diff))
else:
yield diff
示例6: formattext
# 需要导入模块: import crayons [as 别名]
# 或者: from crayons import green [as 别名]
def formattext():
print '--' * 38
print crayons.blue(url)
print crayons.yellow('Press cmd + double click link to go to link!')
try:
print grabhandle() + ' | ' + grabdate() + ' \n' + crayons.green(grabprice()) + ' \n' + grabsku()
print ' '*38
grabszstk()
print crayons.yellow('Press ctrl + z to exit')
except TypeError:
print crayons.red("Try copying everything before the '?variant' \n or before the '?' in the link!".upper())
#While true statment for multiple link checks!