Пример #1
0
    class Yangify(translator.TranslatorData):
        def init(self) -> None:
            self.root_result = ConfigTree()
            self.result = self.root_result

        def post(self) -> None:
            self.root_result = self.root_result.to_string()
Пример #2
0
 def test_simple(self) -> None:
     config = ConfigTree()
     gi1 = config.new_section("interface Gi1")
     gi1.add_command('   description "A description for Gi1"')
     gi1.add_command("   shutdown")
     gi1.add_command("   exit")
     gi1.add_command("!")
     gi2 = config.new_section("interface Gi2")
     gi2.add_command('   description "A description for Gi2"')
     gi2.add_command("   exit")
     gi2.add_command("!")
     config.add_command("logging something something")
     config.add_command("logging something else")
     assert config.to_string() == expected_simple
Пример #3
0
 def test_double_nest(self) -> None:
     config = ConfigTree()
     gi1 = config.new_section("interface Gi1")
     gi1.add_command('   description "A description for Gi1"')
     gi1.add_command("   shutdown")
     nest = gi1.new_section("   another nest")
     nest.add_command("      more subsubcommands")
     gi1.add_command("   exit")
     gi1.add_command("!")
     gi2 = config.new_section("interface Gi2")
     gi2.add_command('   description "A description for Gi2"')
     gi2.add_command("   exit")
     gi2.add_command("!")
     config.add_command("logging something something")
     config.add_command("logging something else")
     assert config.to_string() == expected_double_nested
Пример #4
0
 def init(self) -> None:
     self.root_result = ConfigTree()
     self.result = self.root_result