Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect example in pysnmp.smi.rfc1902.ObjectType.resolveWithMib #460

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ranshox127
Copy link

Corrects a typo in the example code for the resolveWithMib method of the ObjectType class. The previous example incorrectly referenced pysmi instead of pysnmp. Additionally, the code has been improved to use SnmpEngine() directly, providing better clarity regarding the object being passed to getMibViewController.

Previous example:

def resolveWithMib(self, mibViewController, ignoreErrors=True):
    """Perform MIB variable ID and associated value conversion.
    ....
    Examples
    --------
    >>> from pysmi.hlapi.asyncio import varbinds
    >>> mibViewController = varbinds.AbstractVarBinds.getMibViewController( engine )
    >>> objectType = ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr'), 'Linux i386')
    >>> objectType.resolveWithMib(mibViewController)
    ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr'), DisplayString('Linux i386'))
    >>> str(objectType)
    'SNMPv2-MIB::sysDescr."0" = Linux i386'
    >>>

    """

Correct example:

def resolveWithMib(self, mibViewController, ignoreErrors=True):
    """Perform MIB variable ID and associated value conversion.
    ....
    Examples
    --------
    >>> from pysnmp.hlapi import varbinds
    >>> from pysnmp.entity.engine import SnmpEngine
    >>> mibViewController = varbinds.AbstractVarBinds.getMibViewController(SnmpEngine())
    >>> objectType = ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr'), 'Linux i386')
    >>> objectType.resolveWithMib(mibViewController)
    ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr'), DisplayString('Linux i386'))
    >>> str(objectType)
    'SNMPv2-MIB::sysDescr."0" = Linux i386'
    >>>

    """

…thMib example

Corrects a typo in the example code for the `resolveWithMib` method of the `ObjectType` class. The previous example incorrectly referenced `pysmi` instead of `pysnmp`. Additionally, the code has been improved to use `SnmpEngine()` directly, providing better clarity regarding the object being passed to `getMibViewController`.
@lextm
Copy link

lextm commented Jul 31, 2024

  • This repo is dead if you read Call for your help to revive the PySNMP ecosystem together #429. You should switch to the correct repo if you want the latest code base.
  • Complete examples are in the examples directory of the code base, while the snippets in comments can be incomplete or incorrect. Currently, there is no plan to thoroughly fix those snippets.

@ranshox127
Copy link
Author

Thank you for the clarification.
Can I still submit these changes to the new repo?

@lextm
Copy link

lextm commented Jul 31, 2024

You might give that a try but 6.x releases have significant differences so the changes in this pull request are not applicable directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants