Skip to content

Commit d203f2b

Browse files
Format files as per newer version of linter suggests (#369)
1 parent 63b319f commit d203f2b

4 files changed

Lines changed: 34 additions & 71 deletions

File tree

pyangbind/lib/serialise.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636

3737
from pyangbind.lib.yangtypes import YANGBool, safe_name
3838

39-
4039
long = int
4140

4241

pyangbind/lib/xpathhelper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def _encode_path(self, path, mode="search", find_parent=False, normalise_namespa
165165
else:
166166
epath = "/"
167167
for i in range(startelem, lastelem):
168-
(tagname, attributes) = self._tagname_attributes(parts[i], normalise_namespace=normalise_namespace)
168+
tagname, attributes = self._tagname_attributes(parts[i], normalise_namespace=normalise_namespace)
169169
if ":" in tagname and normalise_namespace:
170170
tagname = tagname.split(":")[1]
171171

@@ -256,7 +256,7 @@ def register(self, object_path, object_ptr, caller=False):
256256
this_obj_id = str(uuid.uuid1())
257257
self._library[this_obj_id] = object_ptr
258258
parent = object_path[:-1]
259-
(tagname, attributes) = self._tagname_attributes(object_path[-1])
259+
tagname, attributes = self._tagname_attributes(object_path[-1])
260260

261261
if parent == []:
262262
parent_o = self._root

pyangbind/lib/yangtypes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ def add(self, *args, **kwargs):
796796

797797
value = kwargs.pop("_v", None)
798798

799-
(k, keyargs) = self._generate_key(*args, **kwargs)
799+
k, keyargs = self._generate_key(*args, **kwargs)
800800

801801
if k in self._members:
802802
raise KeyError("%s is already defined as a list entry" % k)
@@ -817,7 +817,7 @@ def add(self, *args, **kwargs):
817817
return k
818818

819819
def delete(self, *args, **kwargs):
820-
(k, _) = self._generate_key(*args, **kwargs)
820+
k, _ = self._generate_key(*args, **kwargs)
821821

822822
if self._path_helper:
823823
current_item = self._members[k]

pyangbind/plugin/pybind.py

Lines changed: 30 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)