예제 #1
0
파일: mem_paths.py 프로젝트: vismid86/grr
    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
예제 #2
0
파일: utils_test.py 프로젝트: hfakar/grr
 def testNonListIterable(self):
     self.assertTrue(utils.IterableStartsWith((5, 4, 3), (5, 4)))
예제 #3
0
파일: utils_test.py 프로젝트: hfakar/grr
 def testDifferentElement(self):
     self.assertFalse(utils.IterableStartsWith([1, 2, 3], [1, 4, 5]))
예제 #4
0
파일: utils_test.py 프로젝트: hfakar/grr
 def testStringTypes(self):
     self.assertTrue(
         utils.IterableStartsWith(["foo", "bar", "baz"], ["foo", "bar"]))
예제 #5
0
파일: utils_test.py 프로젝트: hfakar/grr
 def testProperPrefix(self):
     self.assertTrue(utils.IterableStartsWith([1, 2, 3], [1, 2]))
     self.assertTrue(utils.IterableStartsWith([1, 2, 3], [1]))
예제 #6
0
파일: utils_test.py 프로젝트: hfakar/grr
 def testEqual(self):
     self.assertTrue(utils.IterableStartsWith([1, 2, 3], [1, 2, 3]))
예제 #7
0
파일: utils_test.py 프로젝트: hfakar/grr
 def testEmptyDoesNotStartWithNonEmpty(self):
     self.assertFalse(utils.IterableStartsWith([], [1, 2, 3]))
예제 #8
0
파일: utils_test.py 프로젝트: hfakar/grr
 def testNonEmptyStartsWithEmpty(self):
     self.assertTrue(utils.IterableStartsWith([1, 2, 3], []))
예제 #9
0
파일: utils_test.py 프로젝트: hfakar/grr
 def testEmptyStartsWithEmpty(self):
     self.assertTrue(utils.IterableStartsWith([], []))