diff options
author | elie <elie> | 2011-02-11 07:06:59 +0000 |
---|---|---|
committer | elie <elie> | 2011-02-11 07:06:59 +0000 |
commit | 3ece906cadf904f6963c83dedce13ce562a06703 (patch) | |
tree | e6bfd676154d2e77e69b0ce02df56e62b3132587 /pysnmp/proto/api | |
parent | 8f00fb24145df2f0d47698c52dd1300c8b4d5f64 (diff) | |
download | pysnmp-git-3ece906cadf904f6963c83dedce13ce562a06703.tar.gz |
* fix to PDU component addressing at TrapPDUAPI.getVarBinds()
* replace map() with loops for efficiency
Diffstat (limited to 'pysnmp/proto/api')
-rw-r--r-- | pysnmp/proto/api/v1.py | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/pysnmp/proto/api/v1.py b/pysnmp/proto/api/v1.py index 33bee4f4..1e9ae5db 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() |