當前位置: 首頁>>代碼示例>>Python>>正文


Python pathtree.PathTree類代碼示例

本文整理匯總了Python中rhsm.pathtree.PathTree的典型用法代碼示例。如果您正苦於以下問題:Python PathTree類的具體用法?Python PathTree怎麽用?Python PathTree使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了PathTree類的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_match_variable

 def test_match_variable(self):
     tree = {'foo': [{'$releasever': [{'bar':[{PATH_END: None}]}]}]}
     data = open(DATA).read()
     pt = PathTree(data)
     # just swap out the pre-cooked data with out with
     pt.path_tree = tree
     self.assertTrue(pt.match_path('/foo/path/bar'))
     self.assertFalse(pt.match_path('/foo/path/abc'))
開發者ID:vritant,項目名稱:python-rhsm,代碼行數:8,代碼來源:pathtree-tests.py

示例2: test_generate_path_leaves

    def test_generate_path_leaves(self):
        data = open(DATA).read()
        nodes, bits = PathTree._unpack_data(data)
        ret = PathTree._generate_path_leaves(GhettoBitStream(bits))

        self.assertEqual(len(ret), 4)
        for node in ret:
            self.assertTrue(isinstance(node, HuffmanNode))
開發者ID:vritant,項目名稱:python-rhsm,代碼行數:8,代碼來源:pathtree-tests.py

示例3: test_build_path_list

 def test_build_path_list(self):
     f = os.path.join(os.path.dirname(os.path.abspath(__file__)), "satellite_generated_data.bin")
     data = open(f, 'rb').read()
     pt = PathTree(data)
     paths = []
     pt.build_path_list(paths)
     expected = [
         '/DPS_Satellite/Library/WF-RHEL-7-CV-2018_33-OS/content/dist/rhel/server/7/$releasever/$basearch/os',
         '/DPS_Satellite/Library/WF-RHEL-7-CV-2018_33-OS/content/dist/rhel/server/7/$releasever/$basearch/optional/os',
         '/DPS_Satellite/Library/WF-RHEL-7-CV-2018_33-OS/content/dist/rhel/server/7/$releasever/$basearch/rh-common/os',
         '/DPS_Satellite/Library/WF-RHEL-7-CV-2018_33-OS/content/dist/rhel/server/7/$releasever/$basearch/rhn-tools/os',
         '/DPS_Satellite/Library/WF-RHEL-7-CV-2018_33-OS/content/dist/rhel/server/7/7Server/$basearch/extras/os',
         '/DPS_Satellite/Library/WF-RHEL-7-CV-2018_33-OS/content/dist/rhel/server/7/7Server/$basearch/sat-tools/6.3/os'
     ]
     # Assert the lists contain the same items regardless of order
     six.assertCountEqual(self, expected, paths)
開發者ID:Januson,項目名稱:subscription-manager,代碼行數:16,代碼來源:pathtree_tests.py

示例4: test_unpack_data

 def test_unpack_data(self):
     data = open(DATA).read()
     nodes, bits = PathTree._unpack_data(data)
     self.assertEqual(len(nodes), 6)
     # first node always gets weight of 1
     self.assertEqual(nodes[0].weight, 1)
     self.assertEqual(nodes[0].value, 'never')
     self.assertEqual(nodes[5].weight, 6)
     self.assertEqual(nodes[5].value, '')
     self.assertEqual(len(bits), 6)
開發者ID:vritant,項目名稱:python-rhsm,代碼行數:10,代碼來源:pathtree-tests.py

示例5: test_match_path_listing

 def test_match_path_listing(self):
     tree = {'foo': [{'path': [{'bar':[{PATH_END: None}]}]}]}
     data = open(DATA).read()
     pt = PathTree(data)
     pt.path_tree = tree
     self.assertTrue(pt.match_path('/foo/path/bar/listing'))
     self.assertTrue(pt.match_path('/foo/path/listing'))
     self.assertTrue(pt.match_path('/foo/listing'))
     self.assertFalse(pt.match_path('/foo/path/alfred'))
     self.assertFalse(pt.match_path('/foo/path/listing/for/alfred'))
開發者ID:belonesox,項目名稱:python-rhsm,代碼行數:10,代碼來源:pathtree-tests.py

示例6: test_match_path

 def test_match_path(self):
     data = open(DATA).read()
     pt = PathTree(data)
     self.assertTrue(pt.match_path('/foo/path'))
     self.assertTrue(pt.match_path('/foo/path/'))
     # the '2' should match against "$releasever"
     self.assertTrue(pt.match_path('/foo/path/always/2'))
     self.assertTrue(pt.match_path('/foo/path/bar'))
     self.assertTrue(pt.match_path('/foo/path/bar/a/b/c'))
     self.assertFalse(pt.match_path('/foo'))
     self.assertFalse(pt.match_path('/bar'))
開發者ID:vritant,項目名稱:python-rhsm,代碼行數:11,代碼來源:pathtree-tests.py

示例7: test_match_different_variables

 def test_match_different_variables(self):
     tree1 = {'foo': [{'$releasever': [{'bar':[{PATH_END: None}]}],
                      'jarjar': [{'binks':[{PATH_END: None}]}]}]}
     tree2 = {'foo': [{'jarjar': [{'binks':[{PATH_END: None}]}],
                      '$releasever': [{'bar':[{PATH_END: None}]}]}]}
     tree3 = {'foo': [{'$releasever': [{'bar':[{PATH_END: None}]}]},
                      {'jarjar': [{'binks':[{PATH_END: None}]}]}]}
     tree4 = {'foo': [{'jarjar': [{'binks':[{PATH_END: None}]}]},
                      {'$releasever': [{'bar':[{PATH_END: None}]}]}]}
     trees = [tree1, tree2, tree3, tree4]
     data = open(DATA).read()
     pt = PathTree(data)
     #just swap out the pre-cooked data with out with
     for tree in trees:
         pt.path_tree = tree
         self.assertTrue(pt.match_path('/foo/path/bar'))
         self.assertFalse(pt.match_path('/foo/path/abc'))
         self.assertFalse(pt.match_path('/foo/path/abc'))
         self.assertTrue(pt.match_path('/foo/jarjar/binks'))
         self.assertTrue(pt.match_path('/foo/jarjar/bar'))
         self.assertFalse(pt.match_path('/foo/jarjar/notbinks'))
開發者ID:vritant,項目名稱:python-rhsm,代碼行數:21,代碼來源:pathtree-tests.py

示例8: test_generate_path_tree

 def test_generate_path_tree(self):
     data = open(DATA).read()
     pt = PathTree(data).path_tree
     self.assertTrue('foo' in pt)
     self.assertEqual(len(pt.keys()), 1)
開發者ID:vritant,項目名稱:python-rhsm,代碼行數:5,代碼來源:pathtree-tests.py

示例9: test_get_node_count_big

 def test_get_node_count_big(self):
     bs = GhettoBitStream([])
     # count bigger than 127, need next 2 bytes to represent it
     bs.bytes = deque([130, 1, 17])
     ret = PathTree._get_node_count(bs)
     self.assertEqual(ret, 273)
開發者ID:vritant,項目名稱:python-rhsm,代碼行數:6,代碼來源:pathtree-tests.py

示例10: test_get_node_count_medium

 def test_get_node_count_medium(self):
     bs = GhettoBitStream([])
     # count bigger than 127, only need 1 byte to represent it
     bs.bytes = deque([129, 150])
     ret = PathTree._get_node_count(bs)
     self.assertEqual(ret, 150)
開發者ID:vritant,項目名稱:python-rhsm,代碼行數:6,代碼來源:pathtree-tests.py

示例11: test_get_node_count_small

 def test_get_node_count_small(self):
     bs = GhettoBitStream([])
     bs.bytes = deque([6])
     ret = PathTree._get_node_count(bs)
     self.assertEqual(ret, 6)
開發者ID:vritant,項目名稱:python-rhsm,代碼行數:5,代碼來源:pathtree-tests.py

示例12: test_get_leaf_from_dict

 def test_get_leaf_from_dict(self):
     codes = {'1010': 'abc'}
     bitstream = '10101111110000'
     ret = PathTree._get_leaf_from_dict(codes, bitstream)
     self.assertEqual(ret, 'abc')
開發者ID:vritant,項目名稱:python-rhsm,代碼行數:5,代碼來源:pathtree-tests.py


注:本文中的rhsm.pathtree.PathTree類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。