Esempio n. 1
0
    def ListDescendentPathInfos(self,
                                client_id,
                                path_type,
                                components,
                                max_depth=None):
        """Lists path info records that correspond to children of given path."""
        result = []

        for path_idx, path_record in iteritems(self.path_records):
            other_client_id, other_path_type, other_components = path_idx
            if client_id != other_client_id or path_type != other_path_type:
                continue
            if len(other_components) == len(components):
                continue
            if not utils.IterableStartsWith(other_components, components):
                continue
            if (max_depth is not None
                    and len(other_components) - len(components) > max_depth):
                continue

            result.append(path_record.GetPathInfo())

        result.sort(key=lambda _: tuple(_.components))
        return result
Esempio n. 2
0
 def testNonListIterable(self):
     self.assertTrue(utils.IterableStartsWith((5, 4, 3), (5, 4)))
Esempio n. 3
0
 def testDifferentElement(self):
     self.assertFalse(utils.IterableStartsWith([1, 2, 3], [1, 4, 5]))
Esempio n. 4
0
 def testStringTypes(self):
     self.assertTrue(
         utils.IterableStartsWith(["foo", "bar", "baz"], ["foo", "bar"]))
Esempio n. 5
0
 def testProperPrefix(self):
     self.assertTrue(utils.IterableStartsWith([1, 2, 3], [1, 2]))
     self.assertTrue(utils.IterableStartsWith([1, 2, 3], [1]))
Esempio n. 6
0
 def testEqual(self):
     self.assertTrue(utils.IterableStartsWith([1, 2, 3], [1, 2, 3]))
Esempio n. 7
0
 def testEmptyDoesNotStartWithNonEmpty(self):
     self.assertFalse(utils.IterableStartsWith([], [1, 2, 3]))
Esempio n. 8
0
 def testNonEmptyStartsWithEmpty(self):
     self.assertTrue(utils.IterableStartsWith([1, 2, 3], []))
Esempio n. 9
0
 def testEmptyStartsWithEmpty(self):
     self.assertTrue(utils.IterableStartsWith([], []))