diff options
author | Ilya Etingof <etingof@gmail.com> | 2019-07-29 22:52:38 +0200 |
---|---|---|
committer | Ilya Etingof <etingof@gmail.com> | 2019-07-29 22:52:38 +0200 |
commit | f2403842ab4af862127b2fce2799f6feff57ef4a (patch) | |
tree | 1dc9465609b377e1bdb41a21e1416bd30342b8a7 | |
parent | 9441850839bf8ebf0c8b365dcbebe22cb98b3baa (diff) | |
download | pysnmp-git-f2403842ab4af862127b2fce2799f6feff57ef4a.tar.gz |
Fix Python 2.4 compatibility
@property.setter has not been invented back then
-rw-r--r-- | pysnmp/carrier/base.py | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/pysnmp/carrier/base.py b/pysnmp/carrier/base.py index 40b8d78a..1ab3b454 100644 --- a/pysnmp/carrier/base.py +++ b/pysnmp/carrier/base.py @@ -4,19 +4,25 @@ # Copyright (c) 2005-2019, Ilya Etingof <etingof@gmail.com> # License: http://snmplabs.com/pysnmp/license.html # +import sys + from pysnmp.carrier import error class TimerCallable(object): def __init__(self, cbFun, callInterval): self.__cbFun = cbFun - self.__callInterval = callInterval self.__nextCall = 0 + if sys.version_info > (2, 5): + self.__callInterval = callInterval + else: + self.interval = callInterval + def __call__(self, timeNow): if self.__nextCall <= timeNow: self.__cbFun(timeNow) - self.__nextCall = timeNow + self.__callInterval + self.__nextCall = timeNow + self.interval def __eq__(self, cbFun): return self.__cbFun == cbFun @@ -36,13 +42,14 @@ class TimerCallable(object): def __ge__(self, cbFun): return self.__cbFun >= cbFun - @property - def interval(self): - return self.__callInterval + if sys.version_info > (2, 5): + @property + def interval(self): + return self.__callInterval - @interval.setter - def interval(self, callInterval): - self.__callInterval = callInterval + @interval.setter + def interval(self, callInterval): + self.__callInterval = callInterval class AbstractTransportDispatcher(object): |