本文整理汇总了Python中mozbuild.backend.recursivemake.RecursiveMakeTraversal类的典型用法代码示例。如果您正苦于以下问题:Python RecursiveMakeTraversal类的具体用法?Python RecursiveMakeTraversal怎么用?Python RecursiveMakeTraversal使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RecursiveMakeTraversal类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_traversal
def test_traversal(self):
traversal = RecursiveMakeTraversal()
traversal.add('', dirs=['A', 'B', 'C'])
traversal.add('', dirs=['D'])
traversal.add('A')
traversal.add('B', dirs=['E', 'F'])
traversal.add('C', dirs=['G', 'H'])
traversal.add('D', dirs=['I', 'K'])
traversal.add('D', dirs=['J', 'L'])
traversal.add('E')
traversal.add('F')
traversal.add('G')
traversal.add('H')
traversal.add('I', dirs=['M', 'N'])
traversal.add('J', dirs=['O', 'P'])
traversal.add('K', dirs=['Q', 'R'])
traversal.add('L', dirs=['S'])
traversal.add('M')
traversal.add('N', dirs=['T'])
traversal.add('O')
traversal.add('P', dirs=['U'])
traversal.add('Q')
traversal.add('R', dirs=['V'])
traversal.add('S', dirs=['W'])
traversal.add('T')
traversal.add('U')
traversal.add('V')
traversal.add('W', dirs=['X'])
traversal.add('X')
parallels = set(('G', 'H', 'I', 'J', 'O', 'P', 'Q', 'R', 'U'))
def filter(current, subdirs):
return (current, [d for d in subdirs.dirs if d in parallels],
[d for d in subdirs.dirs if d not in parallels])
start, deps = traversal.compute_dependencies(filter)
self.assertEqual(start, ('X',))
self.maxDiff = None
self.assertEqual(deps, {
'A': ('',),
'B': ('A',),
'C': ('F',),
'D': ('G', 'H'),
'E': ('B',),
'F': ('E',),
'G': ('C',),
'H': ('C',),
'I': ('D',),
'J': ('D',),
'K': ('T', 'O', 'U'),
'L': ('Q', 'V'),
'M': ('I',),
'N': ('M',),
'O': ('J',),
'P': ('J',),
'Q': ('K',),
'R': ('K',),
'S': ('L',),
'T': ('N',),
'U': ('P',),
'V': ('R',),
'W': ('S',),
'X': ('W',),
})
self.assertEqual(list(traversal.traverse('', filter)),
['', 'A', 'B', 'E', 'F', 'C', 'G', 'H', 'D', 'I',
'M', 'N', 'T', 'J', 'O', 'P', 'U', 'K', 'Q', 'R',
'V', 'L', 'S', 'W', 'X'])
self.assertEqual(list(traversal.traverse('C', filter)),
['C', 'G', 'H'])
示例2: test_traversal_2
def test_traversal_2(self):
traversal = RecursiveMakeTraversal()
traversal.add('', dirs=['A', 'B', 'C'])
traversal.add('A')
traversal.add('B', dirs=['D', 'E', 'F'])
traversal.add('C', dirs=['G', 'H', 'I'])
traversal.add('D')
traversal.add('E')
traversal.add('F')
traversal.add('G')
traversal.add('H')
traversal.add('I')
start, deps = traversal.compute_dependencies()
self.assertEqual(start, ('I',))
self.assertEqual(deps, {
'A': ('',),
'B': ('A',),
'C': ('F',),
'D': ('B',),
'E': ('D',),
'F': ('E',),
'G': ('C',),
'H': ('G',),
'I': ('H',),
})
示例3: test_traversal_filter
def test_traversal_filter(self):
traversal = RecursiveMakeTraversal()
traversal.add('', dirs=['A', 'B', 'C'])
traversal.add('A')
traversal.add('B', dirs=['D', 'E', 'F'])
traversal.add('C', dirs=['G', 'H', 'I'])
traversal.add('D')
traversal.add('E')
traversal.add('F')
traversal.add('G')
traversal.add('H')
traversal.add('I')
def filter(current, subdirs):
if current == 'B':
current = None
return current, [], subdirs.dirs
start, deps = traversal.compute_dependencies(filter)
self.assertEqual(start, ('I',))
self.assertEqual(deps, {
'A': ('',),
'C': ('F',),
'D': ('A',),
'E': ('D',),
'F': ('E',),
'G': ('C',),
'H': ('G',),
'I': ('H',),
})
示例4: test_traversal
def test_traversal(self):
traversal = RecursiveMakeTraversal()
traversal.add('', dirs=['A', 'B', 'C'])
traversal.add('', dirs=['D'])
traversal.add('A')
traversal.add('B', dirs=['E', 'F'])
traversal.add('C', parallel=['G', 'H'])
traversal.add('D', parallel=['I'], dirs=['K'])
traversal.add('D', parallel=['J'], dirs=['L'])
traversal.add('E')
traversal.add('F')
traversal.add('G')
traversal.add('H')
traversal.add('I', dirs=['M', 'N'])
traversal.add('J', parallel=['O', 'P'])
traversal.add('K', parallel=['Q', 'R'])
traversal.add('L', dirs=['S'])
traversal.add('M')
traversal.add('N', dirs=['T'])
traversal.add('O')
traversal.add('P', parallel=['U'])
traversal.add('Q')
traversal.add('R', dirs=['V'])
traversal.add('S', dirs=['W'])
traversal.add('T')
traversal.add('U')
traversal.add('V')
traversal.add('W', dirs=['X'])
traversal.add('X')
start, deps = traversal.compute_dependencies()
self.assertEqual(start, ('X',))
self.assertEqual(deps, {
'A': ('',),
'B': ('A',),
'C': ('F',),
'D': ('G', 'H'),
'E': ('B',),
'F': ('E',),
'G': ('C',),
'H': ('C',),
'I': ('D',),
'J': ('D',),
'K': ('T', 'O', 'U'),
'L': ('Q', 'V'),
'M': ('I',),
'N': ('M',),
'O': ('J',),
'P': ('J',),
'Q': ('K',),
'R': ('K',),
'S': ('L',),
'T': ('N',),
'U': ('P',),
'V': ('R',),
'W': ('S',),
'X': ('W',),
})
self.assertEqual(list(traversal.traverse('')),
['', 'A', 'B', 'E', 'F', 'C', 'G', 'H', 'D', 'I',
'M', 'N', 'T', 'J', 'O', 'P', 'U', 'K', 'Q', 'R',
'V', 'L', 'S', 'W', 'X'])
self.assertEqual(list(traversal.traverse('C')),
['C', 'G', 'H'])
示例5: test_traversal
def test_traversal(self):
traversal = RecursiveMakeTraversal()
traversal.add("", dirs=["A", "B", "C"])
traversal.add("", dirs=["D"])
traversal.add("A")
traversal.add("B", dirs=["E", "F"])
traversal.add("C", dirs=["G", "H"])
traversal.add("D", dirs=["I", "K"])
traversal.add("D", dirs=["J", "L"])
traversal.add("E")
traversal.add("F")
traversal.add("G")
traversal.add("H")
traversal.add("I", dirs=["M", "N"])
traversal.add("J", dirs=["O", "P"])
traversal.add("K", dirs=["Q", "R"])
traversal.add("L", dirs=["S"])
traversal.add("M")
traversal.add("N", dirs=["T"])
traversal.add("O")
traversal.add("P", dirs=["U"])
traversal.add("Q")
traversal.add("R", dirs=["V"])
traversal.add("S", dirs=["W"])
traversal.add("T")
traversal.add("U")
traversal.add("V")
traversal.add("W", dirs=["X"])
traversal.add("X")
parallels = set(("G", "H", "I", "J", "O", "P", "Q", "R", "U"))
def filter(current, subdirs):
return (
current,
[d for d in subdirs.dirs if d in parallels],
[d for d in subdirs.dirs if d not in parallels],
)
start, deps = traversal.compute_dependencies(filter)
self.assertEqual(start, ("X",))
self.maxDiff = None
self.assertEqual(
deps,
{
"A": ("",),
"B": ("A",),
"C": ("F",),
"D": ("G", "H"),
"E": ("B",),
"F": ("E",),
"G": ("C",),
"H": ("C",),
"I": ("D",),
"J": ("D",),
"K": ("T", "O", "U"),
"L": ("Q", "V"),
"M": ("I",),
"N": ("M",),
"O": ("J",),
"P": ("J",),
"Q": ("K",),
"R": ("K",),
"S": ("L",),
"T": ("N",),
"U": ("P",),
"V": ("R",),
"W": ("S",),
"X": ("W",),
},
)
self.assertEqual(
list(traversal.traverse("", filter)),
[
"",
"A",
"B",
"E",
"F",
"C",
"G",
"H",
"D",
"I",
"M",
"N",
"T",
"J",
"O",
"P",
"U",
"K",
"Q",
"R",
"V",
"L",
"S",
"W",
"X",
#.........这里部分代码省略.........