Exemple #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
Exemple #2
0
 def testNonListIterable(self):
     self.assertTrue(utils.IterableStartsWith((5, 4, 3), (5, 4)))
Exemple #3
0
 def testDifferentElement(self):
     self.assertFalse(utils.IterableStartsWith([1, 2, 3], [1, 4, 5]))
Exemple #4
0
 def testStringTypes(self):
     self.assertTrue(
         utils.IterableStartsWith(["foo", "bar", "baz"], ["foo", "bar"]))
Exemple #5
0
 def testProperPrefix(self):
     self.assertTrue(utils.IterableStartsWith([1, 2, 3], [1, 2]))
     self.assertTrue(utils.IterableStartsWith([1, 2, 3], [1]))
Exemple #6
0
 def testEqual(self):
     self.assertTrue(utils.IterableStartsWith([1, 2, 3], [1, 2, 3]))
Exemple #7
0
 def testEmptyDoesNotStartWithNonEmpty(self):
     self.assertFalse(utils.IterableStartsWith([], [1, 2, 3]))
Exemple #8
0
 def testNonEmptyStartsWithEmpty(self):
     self.assertTrue(utils.IterableStartsWith([1, 2, 3], []))
Exemple #9
0
 def testEmptyStartsWithEmpty(self):
     self.assertTrue(utils.IterableStartsWith([], []))