• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python netdiff.diff函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中netdiff.diff函数的典型用法代码示例。如果您正苦于以下问题:Python diff函数的具体用法?Python diff怎么用?Python diff使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了diff函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_no_changes

 def test_no_changes(self):
     old = NetJsonParser(links2)
     new = NetJsonParser(links2)
     result = diff(old, new)
     self.assertIsInstance(result, dict)
     self.assertIsNone(result['added'])
     self.assertIsNone(result['removed'])
开发者ID:gabri94,项目名称:netdiff,代码行数:7,代码来源:test_netjson.py


示例2: test_no_changes

 def test_no_changes(self):
     old = CnmlParser(cnml1)
     new = CnmlParser(cnml1)
     result = diff(old, new)
     self.assertIsInstance(result, dict)
     self.assertIsNone(result['added'])
     self.assertIsNone(result['removed'])
开发者ID:leonardomaccari,项目名称:netdiff,代码行数:7,代码来源:test_cnml.py


示例3: test_simple_diff

 def test_simple_diff(self):
     old = OlsrParser(links3)
     new = OlsrParser(links5)
     result = diff(old, new)
     self.assertIsNone(result['changed'])
     # ensure there are differences
     self.assertEqual(len(result['added']['links']), 3)
     self.assertEqual(len(result['removed']['links']), 1)
     self.assertEqual(len(result['added']['nodes']), 2)
     self.assertEqual(len(result['removed']['nodes']), 1)
     # ensure 3 links added
     self._test_expected_links(
         graph=result['added'],
         expected_links=[
             ('10.150.0.3', '10.150.0.7'),
             ('10.150.0.3', '10.150.0.6'),
             ('10.150.0.7', '10.150.0.6'),
         ]
     )
     self._test_expected_links(
         graph=result['removed'],
         expected_links=[('10.150.0.5', '10.150.0.4')]
     )
     added_nodes = [node['id'] for node in result['added']['nodes']]
     self.assertIn('10.150.0.6', added_nodes)
     self.assertIn('10.150.0.7', added_nodes)
     self.assertIn('10.150.0.5', result['removed']['nodes'][0].values())
开发者ID:gabri94,项目名称:netdiff,代码行数:27,代码来源:test_olsr_txtinfo.py


示例4: test_no_changes

 def test_no_changes(self):
     old = BatmanParser(iulinet)
     new = BatmanParser(iulinet)
     result = diff(old, new)
     self.assertIsInstance(result, dict)
     self.assertIsNone(result['added'])
     self.assertIsNone(result['removed'])
开发者ID:cl4u2,项目名称:netdiff,代码行数:7,代码来源:test_batman.py


示例5: test_no_changes

 def test_no_changes(self):
     old = Bmx6Parser(topo)
     new = Bmx6Parser(topo)
     result = diff(old, new)
     self.assertIsInstance(result, dict)
     self.assertIsNone(result['added'])
     self.assertIsNone(result['removed'])
开发者ID:ninuxorg,项目名称:netdiff,代码行数:7,代码来源:test_bmx6.py


示例6: test_added_1_link

 def test_added_1_link(self):
     old = CnmlParser(cnml1)
     new = CnmlParser(cnml2)
     result = diff(old, new)
     self.assertIsNone(result['removed'])
     # ensure there are differences
     self.assertEqual(len(result['added']['links']), 1)
     # ensure 1 link added
     self.assertIn('10.228.172.97', result['added']['links'][0].values())
     self.assertIn('10.228.172.101', result['added']['links'][0].values())
开发者ID:leonardomaccari,项目名称:netdiff,代码行数:10,代码来源:test_cnml.py


示例7: diff

 def diff(self, data=None):
     """ shortcut to netdiff.diff """
     # if we get an instance of ``self.parser_class`` it means
     # ``self.get_topology_data`` has already been executed by ``receive``
     if isinstance(data, self.parser_class):
         latest = data
     else:
         latest = self.get_topology_data(data)
     current = NetJsonParser(self.json(dict=True, omit_down=True))
     return diff(current, latest)
开发者ID:interop-dev,项目名称:django-netjsongraph,代码行数:10,代码来源:topology.py


示例8: test_no_changes

 def test_no_changes(self):
     old = OlsrParser(links2)
     new = OlsrParser(links2)
     result = diff(old, new)
     self.assertTrue(type(result) is dict)
     self.assertTrue(type(result['added']) is list)
     self.assertTrue(type(result['removed']) is list)
     # ensure there are no differences
     self.assertEqual(len(result['added']), 0)
     self.assertEqual(len(result['removed']), 0)
开发者ID:PabloCastellano,项目名称:netdiff,代码行数:10,代码来源:tests.py


示例9: test_added_1_link

 def test_added_1_link(self):
     old = OlsrParser(links2)
     new = OlsrParser(links3)
     result = diff(old, new)
     # ensure there are differences
     self.assertEqual(len(result['added']), 1)
     self.assertEqual(len(result['removed']), 0)
     # ensure 1 link added
     self.assertIn('10.150.0.5', result['added'][0])
     self.assertIn('10.150.0.4', result['added'][0])
开发者ID:PabloCastellano,项目名称:netdiff,代码行数:10,代码来源:tests.py


示例10: test_removed_1_link

 def test_removed_1_link(self):
     old = CnmlParser(cnml2)
     new = CnmlParser(cnml1)
     result = diff(old, new)
     self.assertIsInstance(result, dict)
     self.assertIsNone(result['added'])
     self.assertTrue(type(result['removed']['links']) is list)
     # ensure there are differences
     self.assertEqual(len(result['removed']['links']), 1)
     # ensure 1 link removed
     self.assertIn('10.228.172.97', result['removed']['links'][0].values())
     self.assertIn('10.228.172.101', result['removed']['links'][0].values())
开发者ID:leonardomaccari,项目名称:netdiff,代码行数:12,代码来源:test_cnml.py


示例11: test_added_1_link

 def test_added_1_link(self):
     old = NetJsonParser(links2)
     new = NetJsonParser(links3)
     result = diff(old, new)
     self.assertIsNone(result['removed'])
     # ensure there are no differences
     self.assertEqual(len(result['added']['links']), 1)
     self.assertEqual(len(result['added']['nodes']), 1)
     # ensure correct link added
     self.assertIn('10.150.0.5', result['added']['links'][0].values())
     self.assertIn('10.150.0.4', result['added']['links'][0].values())
     # ensure correct node added
     self.assertIn('10.150.0.5', result['added']['nodes'][0].values())
开发者ID:leonardomaccari,项目名称:netdiff,代码行数:13,代码来源:test_netjson.py


示例12: test_removed_1_link

 def test_removed_1_link(self):
     old = OlsrParser(links3)
     new = OlsrParser(links2)
     result = diff(old, new)
     self.assertTrue(type(result) is dict)
     self.assertTrue(type(result['added']) is list)
     self.assertTrue(type(result['removed']) is list)
     # ensure there are differences
     self.assertEqual(len(result['added']), 0)
     self.assertEqual(len(result['removed']), 1)
     # ensure 1 link removed
     self.assertIn('10.150.0.5', result['removed'][0])
     self.assertIn('10.150.0.4', result['removed'][0])
开发者ID:PabloCastellano,项目名称:netdiff,代码行数:13,代码来源:tests.py


示例13: test_cost_changes_1

 def test_cost_changes_1(self):
     old = OlsrParser(links2)
     new = OlsrParser(links2_cost)
     result = diff(old, new)
     self.assertIsNone(result['added'])
     self.assertIsNone(result['removed'])
     self.assertIsInstance(result['changed'], dict)
     self.assertEqual(len(result['changed']['nodes']), 0)
     links = result['changed']['links']
     self.assertTrue(type(links) is list)
     self.assertEqual(len(links), 2)
     # ensure results are correct
     self.assertTrue(1.302 in (links[0]['cost'], links[1]['cost']))
     self.assertTrue(1.023 in (links[0]['cost'], links[1]['cost']))
开发者ID:gabri94,项目名称:netdiff,代码行数:14,代码来源:test_olsr_txtinfo.py


示例14: test_label_diff_added

 def test_label_diff_added(self):
     old = OpenvpnParser({})
     new = OpenvpnParser(links5_tap)
     result = diff(old, new)
     labels = []
     for node in result['added']['nodes']:
         if 'label' in node:
             labels.append(node['label'])
     self.assertEqual(len(labels), 5)
     self.assertIn('nodeA', labels)
     self.assertIn('nodeB', labels)
     self.assertIn('nodeC', labels)
     self.assertIn('nodeD', labels)
     self.assertIn('nodeE', labels)
开发者ID:ninuxorg,项目名称:netdiff,代码行数:14,代码来源:test_openvpn.py


示例15: test_cost_changes_2

 def test_cost_changes_2(self):
     old = OlsrParser(links5)
     new = OlsrParser(links5_cost)
     result = diff(old, new)
     self.assertIsNone(result['added'])
     self.assertIsNone(result['removed'])
     self.assertIsInstance(result['changed'], dict)
     self.assertEqual(len(result['changed']['nodes']), 0)
     links = result['changed']['links']
     self.assertEqual(len(links), 4)
     weights = [link['weight'] for link in links]
     self.assertIn(1.0, weights)
     self.assertIn(2.0, weights)
     self.assertIn(1.50390625, weights)
     self.assertIn(3.515625, weights)
开发者ID:cl4u2,项目名称:netdiff,代码行数:15,代码来源:test_olsr.py


示例16: test_removed_1_link

 def test_removed_1_link(self):
     old = OlsrParser(links3)
     new = OlsrParser(links2)
     result = diff(old, new)
     self.assertIsNone(result['added'])
     self.assertIsNone(result['changed'])
     self.assertIsInstance(result, dict)
     self.assertTrue(type(result['removed']['links']) is list)
     # ensure there are differences
     self.assertEqual(len(result['removed']['links']), 1)
     self.assertEqual(len(result['removed']['nodes']), 1)
     # ensure correct link removed
     self.assertIn('10.150.0.5', result['removed']['links'][0].values())
     self.assertIn('10.150.0.4', result['removed']['links'][0].values())
     # ensure correct node removed
     self.assertIn('10.150.0.5', result['removed']['nodes'][0].values())
开发者ID:gabri94,项目名称:netdiff,代码行数:16,代码来源:test_olsr_txtinfo.py


示例17: test_simple_diff

 def test_simple_diff(self):
     old = CnmlParser(cnml1)
     new = CnmlParser(cnml3)
     result = diff(old, new)
     # ensure there are differences
     self.assertEqual(len(result["added"]["links"]), 2)
     self.assertEqual(len(result["removed"]["links"]), 2)
     # ensure 2 links added
     self._test_expected_links(
         graph=result["added"],
         expected_links=[("10.228.172.97", "10.228.172.101"), ("10.228.172.194", "10.228.172.193")],
     )
     # ensure 2 links removed
     self._test_expected_links(
         graph=result["removed"],
         expected_links=[("10.228.172.33", "10.228.172.34"), ("10.228.172.33", "10.228.172.36")],
     )
开发者ID:rolinston,项目名称:netdiff,代码行数:17,代码来源:test_cnml.py


示例18: update_topology

def update_topology():
    for topology in Topology.objects.all():
        module = importlib.import_module(topology.backend)
        parser_class_name = topology.backend.split('.')[-1]
        classparsr = getattr(module, parser_class_name)
        njparser = NetJsonParser(to_netjson(topology))
        parser = classparser(topology.url)
        graph_diff = diff(njparser, parser)

        for link in graph_diff['added']:
            if_a, if_b = get_ifs(topology, link)
            Link.objects.create(interface_a=if_a, interface_b=if_b, metric_value=link[2]['weight'])
        for link in graph_diff['removed']:
            if_a, if_b = get_ifs(topology, link)
            try:
                l = Link.objects.get(interface_a=if_a, interface_b=if_b)
                l.delete()
            except Link.DoesNotExist:
                pass
开发者ID:gabri94,项目名称:nodeshot,代码行数:19,代码来源:utils.py


示例19: test_simple_diff

 def test_simple_diff(self):
     old = OlsrParser(links3)
     new = OlsrParser(links5)
     result = diff(old, new)
     # ensure there are differences
     self.assertEqual(len(result['added']), 3)
     self.assertEqual(len(result['removed']), 1)
     # ensure 3 links added
     self._test_expected_links(
         links=result['added'],
         expected_links=[
             ('10.150.0.3', '10.150.0.7'),
             ('10.150.0.3', '10.150.0.6'),
             ('10.150.0.7', '10.150.0.6'),
         ]
     )
     self._test_expected_links(
         links=result['removed'],
         expected_links=[('10.150.0.5', '10.150.0.4')]
     )
开发者ID:PabloCastellano,项目名称:netdiff,代码行数:20,代码来源:tests.py


示例20: test_diff_format

 def test_diff_format(self):
     old = OlsrParser(links3)
     new = OlsrParser(links5)
     result = diff(old, new)
     data = result['added']
     self.assertEqual(data['type'], 'NetworkGraph')
     self.assertEqual(data['protocol'], 'OLSR')
     self.assertEqual(data['version'], '0.8')
     self.assertEqual(data['revision'], None)
     self.assertEqual(data['metric'], 'ETX')
     self.assertIsInstance(data['nodes'], list)
     self.assertIsInstance(data['links'], list)
     data = result['removed']
     self.assertEqual(data['type'], 'NetworkGraph')
     self.assertEqual(data['protocol'], 'OLSR')
     self.assertEqual(data['version'], '0.8')
     self.assertEqual(data['revision'], None)
     self.assertEqual(data['metric'], 'ETX')
     self.assertIsInstance(data['nodes'], list)
     self.assertIsInstance(data['links'], list)
开发者ID:gabri94,项目名称:netdiff,代码行数:20,代码来源:test_olsr_txtinfo.py



注:本文中的netdiff.diff函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python event_manager.emit函数代码示例发布时间:2022-05-27
下一篇:
Python netcdftime.utime函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap