本文整理汇总了Python中twitter.pants.goal.Phase.of方法的典型用法代码示例。如果您正苦于以下问题:Python Phase.of方法的具体用法?Python Phase.of怎么用?Python Phase.of使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twitter.pants.goal.Phase
的用法示例。
在下文中一共展示了Phase.of方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: graph
# 需要导入模块: from twitter.pants.goal import Phase [as 别名]
# 或者: from twitter.pants.goal.Phase import of [as 别名]
def graph():
def get_cluster_name(phase):
return 'cluster_%s' % phase.name.replace('-', '_')
def get_goal_name(phase, goal):
name = '%s_%s' % (phase.name, goal.name)
return name.replace('-', '_')
phase_by_phasename = {}
for phase, goals in Phase.all():
phase_by_phasename[phase.name] = phase
yield '\n'.join([
'digraph G {',
' rankdir=LR;',
' graph [compound=true];',
])
for phase, installed_goals in Phase.all():
yield '\n'.join([
' subgraph %s {' % get_cluster_name(phase),
' node [style=filled];',
' color = blue;',
' label = "%s";' % phase.name,
])
for installed_goal in installed_goals:
yield ' %s [label="%s"];' % (get_goal_name(phase, installed_goal),
installed_goal.name)
yield ' }'
edges = set()
for phase, installed_goals in Phase.all():
for installed_goal in installed_goals:
for dependency in installed_goal.dependencies:
tail_goal = phase_by_phasename.get(dependency.name).goals()[-1]
edge = 'ltail=%s lhead=%s' % (get_cluster_name(phase),
get_cluster_name(Phase.of(tail_goal)))
if edge not in edges:
yield ' %s -> %s [%s];' % (get_goal_name(phase, installed_goal),
get_goal_name(Phase.of(tail_goal), tail_goal),
edge)
edges.add(edge)
yield '}'
示例2: _record
# 需要导入模块: from twitter.pants.goal import Phase [as 别名]
# 或者: from twitter.pants.goal.Phase import of [as 别名]
def _record(self, goal, elapsed):
phase = Phase.of(goal)
phase_timings = self._timings.get(phase)
if phase_timings is None:
phase_timings = OrderedDict(())
self._timings[phase] = phase_timings
goal_timings = phase_timings.get(goal)
if goal_timings is None:
goal_timings = []
phase_timings[goal] = goal_timings
goal_timings.append(elapsed)