本文整理汇总了Python中waflib.Logs.colors方法的典型用法代码示例。如果您正苦于以下问题:Python Logs.colors方法的具体用法?Python Logs.colors怎么用?Python Logs.colors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类waflib.Logs
的用法示例。
在下文中一共展示了Logs.colors方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: display
# 需要导入模块: from waflib import Logs [as 别名]
# 或者: from waflib.Logs import colors [as 别名]
def display(self):
"print either the description (using __str__) or the progress bar or the ide output"
col1 = Logs.colors(self.color)
col2 = Logs.colors.NORMAL
if self.generator.bld.progress_bar == 1:
return self.generator.bld.progress_line(self.position[0], self.position[1], col1, col2)
if self.generator.bld.progress_bar == 2:
ela = str(self.generator.bld.timer)
try:
ins = ','.join([n.name for n in self.inputs])
except AttributeError:
ins = ''
try:
outs = ','.join([n.name for n in self.outputs])
except AttributeError:
outs = ''
return '|Total %s|Current %s|Inputs %s|Outputs %s|Time %s|\n' % (self.position[1], self.position[0], ins, outs, ela)
s = str(self)
if not s:
return None
total = self.position[1]
n = len(str(total))
fs = '[%%%dd/%%%dd] %%s%%s%%s' % (n, n)
return fs % (self.position[0], self.position[1], col1, s, col2)
示例2: display
# 需要导入模块: from waflib import Logs [as 别名]
# 或者: from waflib.Logs import colors [as 别名]
def display(self):
col1 = Logs.colors(self.color)
col2 = Logs.colors.NORMAL
if self.generator.bld.progress_bar == 1:
return self.generator.bld.progress_line(
self.generator.bld.producer.processed - 1, self.position[1], col1, col2
)
if self.generator.bld.progress_bar == 2:
ela = str(self.generator.bld.timer)
try:
ins = ",".join([n.name for n in self.inputs])
except AttributeError:
ins = ""
try:
outs = ",".join([n.name for n in self.outputs])
except AttributeError:
outs = ""
return "|Total %s|Current %s|Inputs %s|Outputs %s|Time %s|\n" % (
self.position[1],
self.generator.bld.producer.processed - 1,
ins,
outs,
ela,
)
s = str(self)
if not s:
return None
total = self.position[1]
n = len(str(total))
fs = "[%%%dd/%%%dd] %%s%%s%%s" % (n, n)
return fs % (self.generator.bld.producer.processed - 1, self.position[1], col1, s, col2)
示例3: display
# 需要导入模块: from waflib import Logs [as 别名]
# 或者: from waflib.Logs import colors [as 别名]
def display(self):
col1=Logs.colors(self.color)
col2=Logs.colors.NORMAL
master=self.master
def cur():
tmp=-1
if hasattr(master,'ready'):
tmp-=master.ready.qsize()
return master.processed+tmp
if self.generator.bld.progress_bar==1:
return self.generator.bld.progress_line(cur(),master.total,col1,col2)
if self.generator.bld.progress_bar==2:
ela=str(self.generator.bld.timer)
try:
ins=','.join([n.name for n in self.inputs])
except AttributeError:
ins=''
try:
outs=','.join([n.name for n in self.outputs])
except AttributeError:
outs=''
return'|Total %s|Current %s|Inputs %s|Outputs %s|Time %s|\n'%(master.total,cur(),ins,outs,ela)
s=str(self)
if not s:
return None
total=master.total
n=len(str(total))
fs='[%%%dd/%%%dd] %%s%%s%%s%%s\n'%(n,n)
kw=self.keyword()
if kw:
kw+=' '
return fs%(cur(),total,kw,col1,s,col2)
示例4: display
# 需要导入模块: from waflib import Logs [as 别名]
# 或者: from waflib.Logs import colors [as 别名]
def display(self):
"""
Return an execution status for the console, the progress bar, or the IDE output.
:rtype: string
"""
col1 = Logs.colors(self.color)
col2 = Logs.colors.NORMAL
if self.generator.bld.progress_bar == 1:
return self.generator.bld.progress_line(len(self.generator.bld.returned_tasks), self.position[1], col1, col2)
if self.generator.bld.progress_bar == 2:
ela = str(self.generator.bld.timer)
try:
ins = ','.join([n.name for n in self.inputs])
except AttributeError:
ins = ''
try:
outs = ','.join([n.name for n in self.outputs])
except AttributeError:
outs = ''
return '|Total %s|Current %s|Inputs %s|Outputs %s|Time %s|\n' % (self.position[1], len(self.generator.bld.returned_tasks), ins, outs, ela)
s = str(self)
if not s:
return None
total = self.position[1]
n = len(str(total))
fs = '[%%%dd/%%%dd] %%s%%s%%s' % (n, n)
return fs % (len(self.generator.bld.returned_tasks), self.position[1], col1, s, col2)
示例5: display
# 需要导入模块: from waflib import Logs [as 别名]
# 或者: from waflib.Logs import colors [as 别名]
def display(self):
"""
Returns an execution status for the console, the progress bar, or the IDE output.
:rtype: string
"""
col1 = Logs.colors(self.color)
col2 = Logs.colors.NORMAL
master = self.generator.bld.producer
def cur():
# the current task position, computed as late as possible
tmp = -1
if hasattr(master, 'ready'):
tmp -= master.ready.qsize()
return master.processed + tmp
if self.generator.bld.progress_bar == 1:
return self.generator.bld.progress_line(cur(), master.total, col1, col2)
if self.generator.bld.progress_bar == 2:
ela = str(self.generator.bld.timer)
try:
ins = ','.join([n.name for n in self.inputs])
except AttributeError:
ins = ''
try:
outs = ','.join([n.name for n in self.outputs])
except AttributeError:
outs = ''
return '|Total %s|Current %s|Inputs %s|Outputs %s|Time %s|\n' % (master.total, cur(), ins, outs, ela)
s = str(self)
if not s:
return None
total = master.total
n = len(str(total))
fs = '[%%%dd/%%%dd] %%s%%s%%s%%s\n' % (n, n)
kw = self.keyword()
if kw:
kw += ' '
return fs % (cur(), total, kw, col1, s, col2)
示例6: run
# 需要导入模块: from waflib import Logs [as 别名]
# 或者: from waflib.Logs import colors [as 别名]
def run(self):
"""Run the task."""
for source_node, target_node in zip(self.inputs, self.outputs):
source = source_node.abspath()
target = target_node.abspath()
# Following is for shared libs and stale inodes (-_-)
try:
os.remove(target)
except OSError:
pass
# Make sure the output directories are available
try:
os.makedirs(os.path.dirname(target))
except OSError:
pass
# Copy the file
try:
shutil.copy2(source, target)
os.chmod(target, self.chmod)
except IOError as e:
Logs.error("The copy file step failed: {0}".format(e))
try:
os.stat(source)
except (OSError, IOError):
Logs.error('File %r does not exist' % source)
raise Errors.WafError('Could not copy the file %r' % target)
Logs.info("{n}{s}Copying {c}{source}{n} -> {c}{target}{n}".format(
c=Logs.colors(CopyFileTask.color),
s=' ' * 10,
source=source_node.name,
target=target_node.relpath(),
n=Logs.colors.NORMAL))
示例7: fake_pprint
# 需要导入模块: from waflib import Logs [as 别名]
# 或者: from waflib.Logs import colors [as 别名]
def fake_pprint(col, str, label='', sep='\n'):
fake_output.write("%s%s%s %s%s" % (Logs.colors(col), str, Logs.colors.NORMAL, label, sep))
示例8: display
# 需要导入模块: from waflib import Logs [as 别名]
# 或者: from waflib.Logs import colors [as 别名]
def display(self):
"""log to term... mostly copied from waflib.Task.Task
"""
norm = Logs.colors.NORMAL
bold = Logs.colors.BOLD
dark = Logs.colors.BLACK
col1 = Logs.colors(self.color)
col2 = bold + col1
master = self.master
def cur():
# the current task position, computed as late as possible
tmp = -1
if hasattr(master, 'ready'):
tmp -= master.ready.qsize()
return master.processed + tmp
if self.generator.bld.progress_bar == 1:
return self.generator.bld.progress_line(
cur(), master.total,
col1, col2,
)
if self.generator.bld.progress_bar == 2:
ela = str(self.generator.bld.timer)
try:
ins = ','.join([n.name for n in self.inputs])
except AttributeError:
ins = ''
try:
outs = ','.join([n.name for n in self.outputs])
except AttributeError:
outs = ''
return '|Total %s|Current %s|Inputs %s|Outputs %s|Time %s|\n' % (
master.total, cur(), ins, outs, ela,
)
total = master.total
n = len(str(total))
n_min = (n * 2) + 2
n_mod = n_min % 4
n_buf = n_min + n_mod
pfx = ' '*n_buf
sp = ' '*2
env = self.env
src_str = ('\n'+pfx).join([a.nice_path() for a in self.inputs])
tgt_str = ('\n'+pfx+sp).join([a.nice_path() for a in self.outputs])
sep0 = sep1 = ''
if self.inputs:
sep0 = '\n'+norm+col1+pfx
if self.outputs:
sep1 = '\n'+norm+col1+pfx+sp
name = str(self)
dist = getattr(self, 'dist', None)
if dist:
name = '%s%s %s%s' % (
name, dark, norm, dist.name_and_version
)
s = '%s%s%s%s%s\n' % (name, sep0, src_str, sep1, tgt_str)
fs = '%s%%%dd/%%%dd%s%s %%s%%s%%s' % (' '*n_mod, n, n, bold, dark)
out = fs % (cur(), total, col2, s, norm)
sys.stderr.write(out)
return ''