@@ -47,7 +47,7 @@ class GenericType:
4747 _fmt = None
4848
4949 def __init__ (self , value = None , enum_ref = None ):
50- """The constructor takes the optional parameters below.
50+ """Create a GenericType with the optional parameters below.
5151
5252 Args:
5353 value: The type's value.
@@ -115,17 +115,19 @@ def __xor__(self, other):
115115 def __rxor__ (self , other ):
116116 return self .value ^ other
117117
118- def __lshift__ (self , n ):
119- return self .value << n
118+ def __lshift__ (self , shift ):
119+ return self .value << shift
120120
121- def __rshift__ (self , n ):
122- return self .value >> n
121+ def __rshift__ (self , shift ):
122+ return self .value >> shift
123123
124124 @property
125125 def value (self ):
126126 """Return this type's value.
127127
128- Returns: The value of an enum, bitmask, etc.
128+ Returns:
129+ object: The value of an enum, bitmask, etc.
130+
129131 """
130132 if self .isenum ():
131133 if isinstance (self ._value , self .enum_ref ):
@@ -163,6 +165,7 @@ def pack(self, value=None):
163165 Raises:
164166 :exc:`~.exceptions.BadValueException`: If the value does not
165167 fit the binary format.
168+
166169 """
167170 if isinstance (value , type (self )):
168171 return value .pack ()
@@ -193,21 +196,24 @@ def unpack(self, buff, offset=0):
193196
194197 Raises:
195198 :exc:`~.exceptions.UnpackException`: If unpack fails.
199+
196200 """
197201 try :
198202 self ._value = struct .unpack_from (self ._fmt , buff , offset )[0 ]
199203 if self .enum_ref :
200204 self ._value = self .enum_ref (self ._value )
201- except (struct .error , TypeError , ValueError ) as e :
202- msg = '{}; fmt = {}, buff = {}, offset = {}.' .format (e , self ._fmt ,
205+ except (struct .error , TypeError , ValueError ) as exception :
206+ msg = '{}; fmt = {}, buff = {}, offset = {}.' .format (exception ,
207+ self ._fmt ,
203208 buff , offset )
204209 raise UnpackException (msg )
205210
206- def get_size (self , value = None ):
211+ def get_size (self , value = None ): # pylint: disable=unused-argument
207212 """Return the size in bytes of this type.
208213
209214 Returns:
210215 int: Size in bytes.
216+
211217 """
212218 return struct .calcsize (self ._fmt )
213219
@@ -218,6 +224,7 @@ def is_valid(self):
218224
219225 Returns:
220226 bool: Whether the value is valid for this type.
227+
221228 """
222229 try :
223230 self .pack ()
@@ -230,6 +237,7 @@ def isenum(self):
230237
231238 Returns:
232239 bool: Whether it is an :class:`~enum.Enum`.
240+
233241 """
234242 return self .enum_ref and issubclass (self .enum_ref , (Enum , IntEnum ))
235243
@@ -238,6 +246,7 @@ def is_bitmask(self):
238246
239247 Returns:
240248 bool: Whether it is a :class:`GenericBitMask`.
249+
241250 """
242251 return self ._value and issubclass (type (self ._value ), GenericBitMask )
243252
@@ -356,6 +365,7 @@ def get_pyof_version(module_fullname):
356365 str: openflow version.
357366 The openflow version, on the format 'v0x0?' if any. Or None
358367 if there isn't a version on the fullname.
368+
359369 """
360370 ver_module_re = re .compile (r'(pyof\.)(v0x\d+)(\..*)' )
361371 matched = ver_module_re .match (module_fullname )
@@ -383,6 +393,7 @@ def replace_pyof_version(module_fullname, version):
383393 version is the same as the one of the module_fullname or if
384394 the module_fullname is not a 'OF version' specific module,
385395 returns None.
396+
386397 """
387398 module_version = MetaStruct .get_pyof_version (module_fullname )
388399 if not module_version or module_version == version :
@@ -434,6 +445,7 @@ def get_pyof_obj_new_version(name, obj, new_version):
434445 is returned without any changes. Also, if the obj is a pyof
435446 versioned attribute, but it is already on the right version
436447 (same as new_version), then the passed obj is return.
448+
437449 """
438450 if new_version is None :
439451 return (name , obj )
@@ -484,6 +496,7 @@ def __eq__(self, other):
484496
485497 Returns:
486498 bool: Returns the result of comparation.
499+
487500 """
488501 return self .pack () == other .pack ()
489502
@@ -505,6 +518,7 @@ def _is_pyof_attribute(obj):
505518
506519 Returns:
507520 bool: Returns TRUE if the obj is a kytos attribute, otherwise False
521+
508522 """
509523 return isinstance (obj , (GenericType , GenericStruct ))
510524
@@ -536,8 +550,9 @@ def get_class_attributes(cls):
536550 print("attribute name: {}".format(name))
537551 print("attribute type: {}".format(value))
538552
539- returns :
553+ Returns :
540554 generator: tuples with attribute name and value.
555+
541556 """
542557 #: see this method docstring for a important notice about the use of
543558 #: cls.__dict__
@@ -556,8 +571,9 @@ def _get_instance_attributes(self):
556571 print("attribute name: {}".format(_name))
557572 print("attribute value: {}".format(_value))
558573
559- returns :
574+ Returns :
560575 generator: tuples with attribute name and value.
576+
561577 """
562578 for name , value in self .__dict__ .items ():
563579 if name in map ((lambda x : x [0 ]), self .get_class_attributes ()):
@@ -574,6 +590,7 @@ def _get_attributes(self):
574590
575591 Returns:
576592 generator: Tuples with instance attribute and class attribute
593+
577594 """
578595 return map ((lambda i , c : (i [1 ], c [1 ])),
579596 self ._get_instance_attributes (),
@@ -588,9 +605,9 @@ def _unpack_attribute(self, name, obj, buff, begin):
588605 try :
589606 attribute .unpack (buff , begin )
590607 size = attribute .get_size ()
591- except UnpackException as e :
608+ except UnpackException as exception :
592609 child_cls = type (self ).__name__
593- msg = '{}.{}; {}' .format (child_cls , name , e )
610+ msg = '{}.{}; {}' .format (child_cls , name , exception )
594611 raise UnpackException (msg )
595612 return size
596613
@@ -609,6 +626,7 @@ def get_size(self, value=None):
609626
610627 Raises:
611628 Exception: If the struct is not valid.
629+
612630 """
613631 if value is None :
614632 return sum (cls_val .get_size (obj_val ) for obj_val , cls_val in
@@ -632,6 +650,7 @@ def pack(self, value=None):
632650
633651 Raises:
634652 :exc:`~.exceptions.ValidationError`: If validation fails.
653+
635654 """
636655 if value is None :
637656 if not self .is_valid ():
@@ -677,6 +696,7 @@ def is_valid(self):
677696
678697 Returns:
679698 bool: Whether the struct is valid.
699+
680700 """
681701 return True
682702 # pylint: disable=unreachable
@@ -720,6 +740,7 @@ def is_valid(self):
720740
721741 Returns:
722742 bool: Whether the message is valid.
743+
723744 """
724745 return True
725746 # pylint: disable=unreachable
@@ -743,6 +764,7 @@ def pack(self, value=None):
743764
744765 Raises:
745766 Exception: If there are validation errors.
767+
746768 """
747769 if value is None :
748770 self .update_header_length ()
@@ -820,7 +842,7 @@ class GenericBitMask(object, metaclass=MetaBitMask):
820842 """Base class for enums that use bitmask values."""
821843
822844 def __init__ (self , bitmask = None ):
823- """The constructor has the optional parameter below.
845+ """Create a GenericBitMask with the optional parameter below.
824846
825847 Args:
826848 bitmask: Bitmask value.
@@ -840,6 +862,7 @@ def names(self):
840862
841863 Returns:
842864 list: Enum names.
865+
843866 """
844867 result = []
845868 for key , value in self .iteritems ():
@@ -848,10 +871,11 @@ def names(self):
848871 return result
849872
850873 def iteritems (self ):
851- """Generator for attributes' name-value pairs.
874+ """Create a generator for attributes' name-value pairs.
852875
853876 Returns:
854877 generator: Attributes' (name, value) tuples.
878+
855879 """
856880 for key , value in self ._enum .items ():
857881 yield (key , value )
0 commit comments