summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelie <elie>2011-02-11 07:06:59 +0000
committerelie <elie>2011-02-11 07:06:59 +0000
commit5fd548e3b78e237ea46777abb20c23ff37c6a9e6 (patch)
treecd72adb854b618f386c877b2ba7afb67054d822a
parent18af13166fe807c8e8d1a75f47d8bafe7c213802 (diff)
downloadpysnmp-5fd548e3b78e237ea46777abb20c23ff37c6a9e6.tar.gz
* fix to PDU component addressing at TrapPDUAPI.getVarBinds()
* replace map() with loops for efficiency
-rw-r--r--pysnmp/proto/api/v1.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/pysnmp/proto/api/v1.py b/pysnmp/proto/api/v1.py
index 33bee4f..1e9ae5d 100644
--- a/pysnmp/proto/api/v1.py
+++ b/pysnmp/proto/api/v1.py
@@ -79,12 +79,14 @@ class PDUAPI:
def getVarBindList(self, pdu):
return pdu.getComponentByPosition(3)
+
def setVarBindList(self, pdu, varBindList):
varBindList = pdu.setComponentByPosition(3, varBindList)
-
def getVarBinds(self, pdu):
- return map(lambda x: apiVarBind.getOIDVal(x),
- pdu.getComponentByPosition(3))
+ varBinds = []
+ for varBind in pdu.getComponentByPosition(3):
+ varBinds.append(apiVarBind.getOIDVal(varBind))
+ return varBinds
def setVarBinds(self, pdu, varBinds):
varBindList = pdu.setComponentByPosition(3).getComponentByPosition(3)
varBindList.clear()
@@ -107,9 +109,10 @@ class PDUAPI:
def getVarBindTable(self, reqPDU, rspPDU):
if apiPDU.getErrorStatus(rspPDU) == 2:
- return [
- map(lambda (x,y),self=self: (x, self._null), apiPDU.getVarBinds(reqPDU))
- ]
+ varBindRow = []
+ for varBind in apiPDU.getVarBinds(reqPDU):
+ varBindRow.append((varBind[0], self._null))
+ return [ varBindRow ]
else:
return [ apiPDU.getVarBinds(rspPDU) ]
@@ -154,8 +157,10 @@ class TrapPDUAPI:
varBindList = pdu.setComponentByPosition(5, varBindList)
def getVarBinds(self, pdu):
- return map(lambda x: apiVarBind.getOIDVal(x),
- pdu.getComponentByPosition(5))
+ varBinds = []
+ for varBind in pdu.getComponentByPosition(5):
+ varBinds.append(apiVarBind.getOIDVal(varBind))
+ return varBinds
def setVarBinds(self, pdu, varBinds):
varBindList = pdu.setComponentByPosition(5).getComponentByPosition(5)
varBindList.clear()