From 3ece906cadf904f6963c83dedce13ce562a06703 Mon Sep 17 00:00:00 2001 From: elie Date: Fri, 11 Feb 2011 07:06:59 +0000 Subject: * fix to PDU component addressing at TrapPDUAPI.getVarBinds() * replace map() with loops for efficiency --- pysnmp/proto/api/v1.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'pysnmp/proto/api') 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() -- cgit v1.2.1