summaryrefslogtreecommitdiff
path: root/pysnmp/carrier/base.py
diff options
context:
space:
mode:
authorelie <elie>2011-01-20 17:11:43 +0000
committerelie <elie>2011-01-20 17:11:43 +0000
commit2d34d4d970b975180de2e14c1ecc18c2db9838df (patch)
treebfd65788a72f82129484058f160969285f9661be /pysnmp/carrier/base.py
parente661d69e4866c44faa98a52f106711968bf4946f (diff)
downloadpysnmp-git-2d34d4d970b975180de2e14c1ecc18c2db9838df.tar.gz
all dict.has_key() & dict.get() invocations replaced with modern syntax
(this breaks compatibility with Python 2.1 and older).
Diffstat (limited to 'pysnmp/carrier/base.py')
-rw-r--r--pysnmp/carrier/base.py20
1 files changed, 13 insertions, 7 deletions
diff --git a/pysnmp/carrier/base.py b/pysnmp/carrier/base.py
index 4515be2f..3fc8c0fc 100644
--- a/pysnmp/carrier/base.py
+++ b/pysnmp/carrier/base.py
@@ -61,7 +61,7 @@ class AbstractTransportDispatcher:
self.__timerCallables.remove(timerCbFun)
def registerTransport(self, tDomain, transport):
- if self.__transports.has_key(tDomain):
+ if tDomain in self.__transports:
raise error.CarrierError(
'Transport %s already registered' % (tDomain,)
)
@@ -69,7 +69,7 @@ class AbstractTransportDispatcher:
self.__transports[tDomain] = transport
def unregisterTransport(self, tDomain):
- if not self.__transports.has_key(tDomain):
+ if tDomain not in self.__transports:
raise error.CarrierError(
'Transport %s not registered' % (tDomain,)
)
@@ -77,24 +77,30 @@ class AbstractTransportDispatcher:
del self.__transports[tDomain]
def getTransport(self, transportDomain):
- return self.__transports.get(transportDomain)
+ if transportDomain in self.__transports:
+ return self.__transports[transportDomain]
def sendMessage(
self, outgoingMessage, transportDomain, transportAddress
):
- transport = self.__transports.get(transportDomain)
- if transport is None:
+ if transportDomain in self.__transports:
+ self.__transports[transportDomain].sendMessage(
+ outgoingMessage, transportAddress
+ )
+ else:
raise error.CarrierError(
'No suitable transport domain for %s' % (transportDomain,)
)
- transport.sendMessage(outgoingMessage, transportAddress)
def handleTimerTick(self, timeNow):
for timerCallable in self.__timerCallables:
timerCallable(timeNow)
def jobStarted(self, jobId):
- self.__jobs[jobId] = self.__jobs.get(jobId, 0) + 1
+ if jobId in self.__jobs:
+ self.__jobs[jobId] = self.__jobs[jobId] + 1
+ else:
+ self.__jobs[jobId] = 1
def jobFinished(self, jobId):
self.__jobs[jobId] = self.__jobs[jobId] - 1