File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change 3030# http://stackoverflow.com/questions/36932/how-can-i-represent-an-enum-in-python
3131def enum (* sequential , ** named ):
3232 enums = dict (zip (sequential , range (len (sequential ))), ** named )
33- enums ["Names" ] = dict ((value ,key ) for key , value in enums .iteritems ())
33+ try :
34+ # Python 2.x
35+ enums_iterator = enums .iteritems ()
36+ except AttributeError :
37+ # Python 3.x
38+ enums_iterator = enums .items ()
39+ enums ["Names" ] = dict ((value ,key ) for key , value in enums_iterator )
3440 return type ("Enum" , (), enums )
3541
3642# Indicates the status of a netsnmpAgent object
@@ -907,7 +913,13 @@ def getRegistered(self, context = ""):
907913 Returned is a dictionary objects for the specified "context",
908914 which defaults to the default context. """
909915 myobjs = {}
910- for oidstr , snmpobj in self ._objs [context ].iteritems ():
916+ try :
917+ # Python 2.x
918+ objs_iterator = self ._objs [context ].iteritems ()
919+ except AttributeError :
920+ # Python 3.x
921+ objs_iterator = self ._objs [context ].items ()
922+ for oidstr , snmpobj in objs_iterator :
911923 myobjs [oidstr ] = {
912924 "type" : type (snmpobj ).__name__ ,
913925 "value" : snmpobj .value ()
You can’t perform that action at this time.
0 commit comments