Skip to content

Commit

Permalink
fixed malformed python code being produced by pysnmp codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
etingof committed Nov 13, 2017
1 parent a602b43 commit 5bbcf0f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 22 deletions.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@

Revision 0.2.2, XX-11-2017
Revision 0.2.2, 13-11-2017
--------------------------

- Library documentation refactored and updated
- Fixed malformed Python code being produced by pysnmp code generator

Revision 0.2.1, 11-11-2017
--------------------------
Expand Down
19 changes: 10 additions & 9 deletions docs/source/library-reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,6 @@ Examples

The following examples focus on various feature of the PySMI library.

In case of any troubles or confusion, try enabling PySMI debugging
and watch the output:

.. code-block:: python
from pysmi import debug
debug.setLogger(debug.Debug('all'))
.. toctree::
:maxdepth: 2

Expand All @@ -167,3 +158,13 @@ and watch the output:
/examples/compile-smiv2-mibs-from-text-into-pysnmp-code.rst
/examples/borrow-precompiled-pysnmp-files-on-failure.rst
/examples/always-borrow-precompiled-pysnmp-files.rst

In case of any troubles or confusion, try enabling PySMI debugging
and watch the output:

.. code-block:: python
from pysmi import debug
debug.setLogger(debug.Debug('all'))
28 changes: 16 additions & 12 deletions pysmi/codegen/pysnmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,12 +423,13 @@ def genNotificationGroup(self, data, classmode=False):
# WARNING: leading objects get lost here! Upgrade your pysnmp version!
%(name)s = %(name)s.setObjects(*_%(name)s_obj)
else:
%(name)s = %(name)s.setObjects(*_%(name)s_obj, **dict(append=True))
%(name)s = %(name)s.setObjects(*_%(name)s_obj, **dict(append=True))\
""" % dict(name=name, objects=', '.join(objStrParts))

else:
outStr += '.setObjects(' + ', '.join(objects) + ')\n'
outStr += '.setObjects(' + ', '.join(objects) + ')'

outStr += '\n'

if status:
outStr += """\
Expand Down Expand Up @@ -475,12 +476,13 @@ def genNotificationType(self, data, classmode=False):
# WARNING: leading objects get lost here! Upgrade your pysnmp version!
%(name)s = %(name)s.setObjects(*_%(name)s_obj)
else:
%(name)s = %(name)s.setObjects(*_%(name)s_obj, **dict(append=True))
%(name)s = %(name)s.setObjects(*_%(name)s_obj, **dict(append=True))\
""" % dict(name=name, objects=', '.join(objStrParts))

else:
outStr += '.setObjects(' + ', '.join(objects) + ')\n'
outStr += '.setObjects(' + ', '.join(objects) + ')'

outStr += '\n'

if status:
outStr += self.ifTextStr + name + status + '\n'
Expand Down Expand Up @@ -524,12 +526,13 @@ def genObjectGroup(self, data, classmode=False):
# WARNING: leading objects get lost here!
%(name)s = %(name)s.setObjects(*_%(name)s_obj)
else:
%(name)s = %(name)s.setObjects(*_%(name)s_obj, **dict(append=True))
%(name)s = %(name)s.setObjects(*_%(name)s_obj, **dict(append=True))\
""" % dict(name=name, objects=', '.join(objStrParts))

else:
outStr += '.setObjects(' + ', '.join(objects) + ')\n'
outStr += '.setObjects(' + ', '.join(objects) + ')'

outStr += '\n'

if status:
outStr += """\
Expand Down Expand Up @@ -647,12 +650,13 @@ def genTrapType(self, data, classmode=False):
# WARNING: leading objects get lost here! Upgrade your pysnmp version!
%(name)s = %(name)s.setObjects(*_%(name)s_obj)
else:
%(name)s = %(name)s.setObjects(*_%(name)s_obj, **dict(append=True))
%(name)s = %(name)s.setObjects(*_%(name)s_obj, **dict(append=True))\
""" % dict(name=name, objects=', '.join(objStrParts))

else:
outStr += '.setObjects(' + ', '.join(objects) + ')\n'
outStr += '.setObjects(' + ', '.join(objects) + ')'

outStr += '\n'

if self.genRules['text'] and description:
outStr += self.ifTextStr + name + description + '\n'
Expand Down

0 comments on commit 5bbcf0f

Please sign in to comment.