示例#1
0
 def flatten_restricts(self, v):
     i = expandable_chain(v)
     depth = 0
     conditionals = []
     for x in i:
         for t, s in ((boolean.OrRestriction, "||"),
                      (boolean.AndRestriction, "&&")):
             if isinstance(x, t):
                 yield s
                 yield "("
                 i.appendleft(")")
                 i.appendleft(x.restrictions)
                 depth += 1
                 break
         else:
             if isinstance(x, packages.Conditional):
                 self.assertTrue(x.attr == "use")
                 conditionals.insert(
                     depth, list(self.mangle_cond_payload(x.restriction)))
                 yield set(iflatten_instance(conditionals[:depth + 1]))
                 yield "("
                 i.appendleft(")")
                 i.appendleft(x.payload)
                 depth += 1
             else:
                 if x == ")":
                     self.assertTrue(depth)
                     depth -= 1
                 yield x
     self.assertFalse(depth)
示例#2
0
 def flatten_restricts(self, v):
     i = expandable_chain(v)
     depth = 0
     conditionals = []
     for x in i:
         for t, s in ((boolean.OrRestriction, "||"),
                      (boolean.AndRestriction, "&&")):
             if isinstance(x, t):
                 yield s
                 yield "("
                 i.appendleft(")")
                 i.appendleft(x.restrictions)
                 depth += 1
                 break
         else:
             if isinstance(x, packages.Conditional):
                 self.assertTrue(x.attr == "use")
                 conditionals.insert(
                     depth, list(self.mangle_cond_payload(x.restriction)))
                 yield set(iflatten_instance(conditionals[:depth + 1]))
                 yield "("
                 i.appendleft(")")
                 i.appendleft(x.payload)
                 depth += 1
             else:
                 if x == ")":
                     self.assertTrue(depth)
                     depth -= 1
                 yield x
     self.assertFalse(depth)