@@ -826,15 +826,12 @@ def get_children(ctx, fd, i_children, module, parent, path=str(), parent_cfg=Tru
826826 parent_descr = ""
827827
828828 # Add more helper text.
829- nfd .write (
830- ''' """
829+ nfd .write (''' """
831830 This class was auto-generated by the PythonClass plugin for PYANG
832831 from YANG module %s - based on the path %s. Each member element of
833832 the container is represented as a class variable - with a specific
834833 YANG type.%s
835- """\n '''
836- % (module .arg , (path if not path == "" else "/%s" % parent .arg ), parent_descr )
837- )
834+ """\n ''' % (module .arg , (path if not path == "" else "/%s" % parent .arg ), parent_descr ))
838835 else :
839836 raise TypeError ("unhandled keyword with children %s at %s" % (parent .keyword , parent .pos ))
840837
@@ -1009,15 +1006,12 @@ def get_children(ctx, fd, i_children, module, parent, path=str(), parent_cfg=Tru
10091006 # set.
10101007
10111008 # Generic class __init__, set up the path_helper if asked to.
1012- nfd .write (
1013- """
1009+ nfd .write ("""
10141010 _pybind_generated_by = 'container'
10151011
1016- def __init__(self, *args, **kwargs):\n """
1017- )
1012+ def __init__(self, *args, **kwargs):\n """ )
10181013 if ctx .opts .use_xpathhelper :
1019- nfd .write (
1020- """
1014+ nfd .write ("""
10211015 helper = kwargs.pop("path_helper", None)
10221016 if helper is False:
10231017 self._path_helper = False
@@ -1027,17 +1021,13 @@ def __init__(self, *args, **kwargs):\n"""
10271021 helper = getattr(self._parent, "_path_helper", False)
10281022 self._path_helper = helper
10291023 else:
1030- self._path_helper = False\n """
1031- )
1024+ self._path_helper = False\n """ )
10321025 else :
1033- nfd .write (
1034- """
1035- self._path_helper = False\n """
1036- )
1026+ nfd .write ("""
1027+ self._path_helper = False\n """ )
10371028
10381029 if ctx .opts .use_extmethods :
1039- nfd .write (
1040- """
1030+ nfd .write ("""
10411031 extmethods = kwargs.pop("extmethods", None)
10421032 if extmethods is False:
10431033 self._extmethods = False
@@ -1047,21 +1037,17 @@ def __init__(self, *args, **kwargs):\n"""
10471037 extmethods = getattr(self._parent, "_extmethods", None)
10481038 self._extmethods = extmethods
10491039 else:
1050- self._extmethods = False\n """
1051- )
1040+ self._extmethods = False\n """ )
10521041 else :
1053- nfd .write (
1054- """
1055- self._extmethods = False\n """
1056- )
1042+ nfd .write ("""
1043+ self._extmethods = False\n """ )
10571044
10581045 # Write out the classes that are stored locally as self.__foo where
10591046 # foo is the safe YANG name.
10601047 for c in classes :
10611048 nfd .write (" self.%s = %s(%s)\n " % (classes [c ]["name" ], classes [c ]["type" ], classes [c ]["arg" ]))
10621049 # Don't accept arguments to a container/list/submodule class
1063- nfd .write (
1064- """
1050+ nfd .write ("""
10651051 load = kwargs.pop("load", None)
10661052 if args:
10671053 if len(args) > 1:
@@ -1081,20 +1067,16 @@ def __init__(self, *args, **kwargs):\n"""
10811067 if load is None:
10821068 setmethod(getattr(args[0], e))
10831069 else:
1084- setmethod(getattr(args[0], e), load=load)\n """
1085- )
1070+ setmethod(getattr(args[0], e), load=load)\n """ )
10861071
10871072 # A generic method to provide a path() method on each container, that gives
10881073 # a path in the form of a list that describes the nodes in the hierarchy.
1089- nfd .write (
1090- """
1074+ nfd .write ("""
10911075 def _path(self):
10921076 if hasattr(self, "_parent"):
10931077 return self._parent._path()+[self._yang_name]
10941078 else:
1095- return %s\n """
1096- % path .split ("/" )[1 :]
1097- )
1079+ return %s\n """ % path .split ("/" )[1 :])
10981080
10991081 # For each element, write out a getter and setter method - with the doc
11001082 # string of the element within the model.
@@ -1103,52 +1085,37 @@ def _path(self):
11031085 description_str = ""
11041086 if i ["description" ]:
11051087 description_str = "\n \n YANG Description: %s" % i ["description" ]
1106- nfd .write (
1107- '''
1088+ nfd .write ('''
11081089 def _get_%s(self):
11091090 """
11101091 Getter method for %s, mapped from YANG variable %s (%s)%s
11111092 """
11121093 return self.__%s
1113- '''
1114- % (i ["name" ], i ["name" ], i ["path" ], i ["origtype" ], description_str , i ["name" ])
1115- )
1094+ ''' % (i ["name" ], i ["name" ], i ["path" ], i ["origtype" ], description_str , i ["name" ]))
11161095
1117- nfd .write (
1118- '''
1096+ nfd .write ('''
11191097 def _set_%s(self, v, load=False):
11201098 """
11211099 Setter method for %s, mapped from YANG variable %s (%s)
11221100 If this variable is read-only (config: false) in the
11231101 source YANG file, then _set_%s is considered as a private
11241102 method. Backends looking to populate this variable should
11251103 do so via calling thisObj._set_%s() directly.%s
1126- """'''
1127- % (i ["name" ], i ["name" ], i ["path" ], i ["origtype" ], i ["name" ], i ["name" ], description_str )
1128- )
1104+ """''' % (i ["name" ], i ["name" ], i ["path" ], i ["origtype" ], i ["name" ], i ["name" ], description_str ))
11291105 if keyval and i ["yang_name" ] in keyval :
1130- nfd .write (
1131- """
1106+ nfd .write ("""
11321107 parent = getattr(self, "_parent", None)
11331108 if parent is not None and load is False:
11341109 raise AttributeError("Cannot set keys directly when" +
1135- " within an instantiated list")\n """
1136- )
1137- nfd .write (
1138- """
1110+ " within an instantiated list")\n """ )
1111+ nfd .write ("""
11391112 if hasattr(v, "_utype"):
1140- v = v._utype(v)"""
1141- )
1142- nfd .write (
1143- """
1113+ v = v._utype(v)""" )
1114+ nfd .write ("""
11441115 try:
1145- t = %s(v,%s)"""
1146- % (c_str ["type" ], c_str ["arg" ])
1147- )
1148- nfd .write (
1149- """
1150- except (TypeError, ValueError):\n """
1151- )
1116+ t = %s(v,%s)""" % (c_str ["type" ], c_str ["arg" ]))
1117+ nfd .write ("""
1118+ except (TypeError, ValueError):\n """ )
11521119 nfd .write (
11531120 """ raise ValueError({
11541121 'error-string': \" \" \" %s must be of a type compatible with %s\" \" \" ,
@@ -1175,12 +1142,9 @@ def _set_%s(self, v, load=False):
11751142 # be used. Generally, this is done in a choice where one branch needs to
11761143 # be set to the default, but may be used wherever re-initialiation of
11771144 # the object is required.
1178- nfd .write (
1179- """
1145+ nfd .write ("""
11801146 def _unset_%s(self):
1181- self.__%s = %s(%s)\n \n """
1182- % (i ["name" ], i ["name" ], c_str ["type" ], c_str ["arg" ])
1183- )
1147+ self.__%s = %s(%s)\n \n """ % (i ["name" ], i ["name" ], c_str ["type" ], c_str ["arg" ]))
11841148
11851149 # When an element is read-only, write out the _set and _get methods, but
11861150 # we don't actually make the property object accessible. This ensures that
0 commit comments