@@ -119,7 +119,7 @@ def __rxor__(self, other):
119119 def value (self ):
120120 """Return this type's value.
121121
122- The value of an enum, bitmask, etc.
122+ Returns: The value of an enum, bitmask, etc.
123123 """
124124 if self .isenum ():
125125 if isinstance (self ._value , self .enum_ref ):
@@ -347,14 +347,14 @@ def get_pyof_version(module_fullname):
347347 (e.g.: pyof.v0x01.common.header)
348348
349349 Returns:
350- str: The module version, on the format 'v0x0?' if any. Or None
351- if there isn't a version on the fullname.
350+ str: openflow version.
351+ The openflow version, on the format 'v0x0?' if any. Or None
352+ if there isn't a version on the fullname.
352353 """
353354 ver_module_re = re .compile (r'(pyof\.)(v0x\d+)(\..*)' )
354355 matched = ver_module_re .match (module_fullname )
355356 if matched :
356357 version = matched .group (2 )
357- # module = matched.group(3)
358358 return version
359359 return None
360360
@@ -386,7 +386,7 @@ def replace_pyof_version(module_fullname, version):
386386
387387 @staticmethod
388388 def get_pyof_obj_new_version (name , obj , new_version ):
389- """Return a class atrribute on a different pyof version.
389+ r """Return a class attribute on a different pyof version.
390390
391391 This method receives the name of a class attribute, the class attribute
392392 itself (object) and an openflow version.
@@ -399,14 +399,19 @@ def get_pyof_obj_new_version(name, obj, new_version):
399399 an instance of the new version of the 'obj'.
400400
401401 Example:
402- >> from pyof.v0x01.common.header import Header
403- >> name = 'header'
404- >> obj = Header()
405- >> obj
406- <pyof.v0x01.common.header.Header at 0x...>
407- >> new_version = 'v0x02'
408- >> MetaStruct.get_pyof_new_version(name, obj, new_version)
409- ('header', <pyof.v0x02.common.header.Header at 0x...)
402+
403+ >>> from pyof.foundation.base import MetaStruct as ms
404+ >>> from pyof.v0x01.common.header import Header
405+ >>> name = 'header'
406+ >>> obj = Header()
407+ >>> new_version = 'v0x04'
408+ >>> header, obj2 = ms.get_pyof_obj_new_version(name, obj, new_version)
409+ >>> header
410+ 'header'
411+ >>> obj.version
412+ UBInt8(1)
413+ >>> obj2.version
414+ UBInt8(4)
410415
411416 Args:
412417 name (str): the name of the class attribute being handled.
@@ -415,13 +420,14 @@ def get_pyof_obj_new_version(name, obj, new_version):
415420 'obj'.
416421
417422 Return:
418- (str, obj): A tuple in which the first item is the name of the
419- class attribute (the same that was passed), and the second item
420- is a instance of the passed class attribute. If the class
421- attribute is not a pyof versioned attribute, then the same
422- passed object is returned without any changes. Also, if the obj
423- is a pyof versioned attribute, but it is already on the right
424- version (same as new_version), then the passed obj is return.
423+ (str, obj): Tuple with class name and object instance.
424+ A tuple in which the first item is the name of the class
425+ attribute (the same that was passed), and the second item is a
426+ instance of the passed class attribute. If the class attribute
427+ is not a pyof versioned attribute, then the same passed object
428+ is returned without any changes. Also, if the obj is a pyof
429+ versioned attribute, but it is already on the right version
430+ (same as new_version), then the passed obj is return.
425431 """
426432 if new_version is None :
427433 return (name , obj )
@@ -469,6 +475,9 @@ def __eq__(self, other):
469475
470476 Args:
471477 other (GenericStruct): The struct to be compared with.
478+
479+ Returns:
480+ bool: Returns the result of comparation.
472481 """
473482 return self .pack () == other .pack ()
474483
@@ -488,9 +497,8 @@ def _is_pyof_attribute(obj):
488497 To be a kytos attribute the item must be an instance of either
489498 GenericType or GenericStruct.
490499
491- returns:
492- True: if the obj is a kytos attribute
493- False: if the obj is not a kytos attribute
500+ Returns:
501+ bool: Returns TRUE if the obj is a kytos attribute, otherwise False
494502 """
495503 return isinstance (obj , (GenericType , GenericStruct ))
496504
0 commit comments