summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlya Etingof <etingof@gmail.com>2016-04-01 23:06:11 +0200
committerIlya Etingof <etingof@gmail.com>2016-04-01 23:06:11 +0200
commitfbc9c2679bd04ea3241b294e78e1b66fe993d952 (patch)
treeab33c2701ccac4e7105eead5825d6545ea20e819
parent020791a97232849c9504024834906dd4a4ffb36c (diff)
downloadpysnmp-git-fbc9c2679bd04ea3241b294e78e1b66fe993d952.tar.gz
pep8 reformatted
-rw-r--r--pysnmp/cache.py2
-rw-r--r--pysnmp/debug.py9
-rw-r--r--pysnmp/error.py2
-rw-r--r--pysnmp/nextid.py12
-rw-r--r--setup.py88
5 files changed, 64 insertions, 49 deletions
diff --git a/pysnmp/cache.py b/pysnmp/cache.py
index 41a1a2cb..00fc047b 100644
--- a/pysnmp/cache.py
+++ b/pysnmp/cache.py
@@ -10,7 +10,7 @@ class Cache:
def __init__(self, maxSize=256):
self.__maxSize = maxSize
self.__size = 0
- self.__chopSize = maxSize//10
+ self.__chopSize = maxSize // 10
self.__chopSize = self.__chopSize and self.__chopSize or 1
self.__cache = {}
self.__usage = {}
diff --git a/pysnmp/debug.py b/pysnmp/debug.py
index 4a41f722..75b7df46 100644
--- a/pysnmp/debug.py
+++ b/pysnmp/debug.py
@@ -34,6 +34,7 @@ flagMap = {'io': flagIO,
'app': flagApp,
'all': flagAll}
+
class Printer:
def __init__(self, logger=None, handler=None, formatter=None):
if logger is None:
@@ -54,6 +55,7 @@ class Printer:
def __str__(self):
return '<python built-in logging>'
+
if hasattr(logging, 'NullHandler'):
NullHandler = logging.NullHandler
else:
@@ -62,8 +64,10 @@ else:
def emit(self, record):
pass
+
class Debug:
defaultPrinter = None
+
def __init__(self, *flags, **options):
self._flags = flagNone
if options.get('printer') is not None:
@@ -106,13 +110,16 @@ class Debug:
def __rand__(self, flag):
return flag & self._flags
+
# This will yield false from bitwise and with a flag, and save
# on unnecessary calls
logger = 0
+
def setLogger(l):
global logger
logger = l
+
def hexdump(octets):
- return ' '.join(['%s%.2X' % (n%16 == 0 and ('\n%.5d: ' % n) or '', x) for n, x in zip(range(len(octets)), octs2ints(octets))])
+ return ' '.join(['%s%.2X' % (n % 16 == 0 and ('\n%.5d: ' % n) or '', x) for n, x in zip(range(len(octets)), octs2ints(octets))])
diff --git a/pysnmp/error.py b/pysnmp/error.py
index 75b75190..2cb6b98e 100644
--- a/pysnmp/error.py
+++ b/pysnmp/error.py
@@ -4,5 +4,7 @@
# Copyright (c) 2005-2016, Ilya Etingof <ilya@glas.net>
# License: http://pysnmp.sf.net/license.html
#
+
+
class PySnmpError(Exception):
pass
diff --git a/pysnmp/nextid.py b/pysnmp/nextid.py
index 3ac719d4..cd2fe20b 100644
--- a/pysnmp/nextid.py
+++ b/pysnmp/nextid.py
@@ -8,23 +8,25 @@ import random
random.seed()
+
class Integer:
"""Return a next value in a reasonably MT-safe manner"""
+
def __init__(self, maximum, increment=256):
self.__maximum = maximum
if increment >= maximum:
increment = maximum
self.__increment = increment
- self.__threshold = increment//2
+ self.__threshold = increment // 2
e = random.randrange(self.__maximum - self.__increment)
- self.__bank = list(range(e, e+self.__increment))
+ self.__bank = list(range(e, e + self.__increment))
def __repr__(self):
return '%s(%d, %d)' % (
self.__class__.__name__,
self.__maximum,
self.__increment
- )
+ )
def __call__(self):
v = self.__bank.pop(0)
@@ -33,8 +35,8 @@ class Integer:
else:
# this is MT-safe unless too many (~ increment/2) threads
# bump into this code simultaneously
- e = self.__bank[-1]+1
+ e = self.__bank[-1] + 1
if e > self.__maximum:
e = 0
- self.__bank.extend(range(e, e+self.__threshold))
+ self.__bank.extend(range(e, e + self.__threshold))
return v
diff --git a/setup.py b/setup.py
index 325b95b5..47465938 100644
--- a/setup.py
+++ b/setup.py
@@ -28,6 +28,7 @@ Topic :: System :: Networking :: Monitoring
Topic :: Software Development :: Libraries :: Python Modules
"""
+
def howto_install_setuptools():
print("""
Error: You need setuptools Python package!
@@ -40,16 +41,18 @@ def howto_install_setuptools():
Then you could make eggs from this package.
""")
+
if sys.version_info[:2] < (2, 4):
print("ERROR: this package requires Python 2.4 or later!")
sys.exit(1)
try:
from setuptools import setup
+
params = {
- 'install_requires': [ 'pyasn1>=0.1.8', 'pysmi' ],
+ 'install_requires': ['pyasn1>=0.1.8', 'pysmi'],
'zip_safe': True
- }
+ }
if sys.platform.lower()[:3] != 'win':
params['install_requires'].append('pycrypto>=2.4.1')
@@ -59,9 +62,10 @@ except ImportError:
howto_install_setuptools()
sys.exit(1)
from distutils.core import setup
+
params = {}
if sys.version_info[:2] > (2, 4):
- params['requires'] = [ 'pyasn1(>=0.1.8)', 'pysmi' ]
+ params['requires'] = ['pyasn1(>=0.1.8)', 'pysmi']
if sys.platform.lower()[:3] != 'win':
params['requires'].append('pycrypto(>=2.4.1)')
@@ -76,54 +80,54 @@ and install into your system.
""")
doclines = [x.strip() for x in (__doc__ or '').split('\n') if x]
-
+
params.update({
'name': 'pysnmp',
- 'version': open(os.path.join('pysnmp','__init__.py')).read().split('\'')[1],
+ 'version': open(os.path.join('pysnmp', '__init__.py')).read().split('\'')[1],
'description': doclines[0],
'long_description': ' '.join(doclines[1:]),
'maintainer': 'Ilya Etingof <ilya@glas.net>',
'author': 'Ilya Etingof',
'author_email': 'ilya@glas.net',
'url': 'http://sourceforge.net/projects/pysnmp/',
- 'classifiers': [ x for x in classifiers.split('\n') if x ],
+ 'classifiers': [x for x in classifiers.split('\n') if x],
'platforms': ['any'],
'license': 'BSD',
- 'packages': [ 'pysnmp',
- 'pysnmp.smi',
- 'pysnmp.smi.mibs',
- 'pysnmp.smi.mibs.instances',
- 'pysnmp.carrier',
- 'pysnmp.carrier.asynsock',
- 'pysnmp.carrier.asynsock.dgram',
- 'pysnmp.carrier.asyncore',
- 'pysnmp.carrier.asyncore.dgram',
- 'pysnmp.carrier.twisted',
- 'pysnmp.carrier.twisted.dgram',
- 'pysnmp.carrier.asyncio',
- 'pysnmp.carrier.asyncio.dgram',
- 'pysnmp.entity',
- 'pysnmp.entity.rfc3413',
- 'pysnmp.entity.rfc3413.oneliner',
- 'pysnmp.hlapi',
- 'pysnmp.hlapi.asyncio',
- 'pysnmp.hlapi.asyncore',
- 'pysnmp.hlapi.asyncore.sync',
- 'pysnmp.hlapi.asyncore.sync.compat',
- 'pysnmp.hlapi.twisted',
- 'pysnmp.proto',
- 'pysnmp.proto.mpmod',
- 'pysnmp.proto.secmod',
- 'pysnmp.proto.secmod.rfc3414',
- 'pysnmp.proto.secmod.rfc3414.auth',
- 'pysnmp.proto.secmod.rfc3414.priv',
- 'pysnmp.proto.secmod.rfc3826',
- 'pysnmp.proto.secmod.rfc3826.priv',
- 'pysnmp.proto.secmod.eso',
- 'pysnmp.proto.secmod.eso.priv',
- 'pysnmp.proto.acmod',
- 'pysnmp.proto.proxy',
- 'pysnmp.proto.api' ]
- })
+ 'packages': ['pysnmp',
+ 'pysnmp.smi',
+ 'pysnmp.smi.mibs',
+ 'pysnmp.smi.mibs.instances',
+ 'pysnmp.carrier',
+ 'pysnmp.carrier.asynsock',
+ 'pysnmp.carrier.asynsock.dgram',
+ 'pysnmp.carrier.asyncore',
+ 'pysnmp.carrier.asyncore.dgram',
+ 'pysnmp.carrier.twisted',
+ 'pysnmp.carrier.twisted.dgram',
+ 'pysnmp.carrier.asyncio',
+ 'pysnmp.carrier.asyncio.dgram',
+ 'pysnmp.entity',
+ 'pysnmp.entity.rfc3413',
+ 'pysnmp.entity.rfc3413.oneliner',
+ 'pysnmp.hlapi',
+ 'pysnmp.hlapi.asyncio',
+ 'pysnmp.hlapi.asyncore',
+ 'pysnmp.hlapi.asyncore.sync',
+ 'pysnmp.hlapi.asyncore.sync.compat',
+ 'pysnmp.hlapi.twisted',
+ 'pysnmp.proto',
+ 'pysnmp.proto.mpmod',
+ 'pysnmp.proto.secmod',
+ 'pysnmp.proto.secmod.rfc3414',
+ 'pysnmp.proto.secmod.rfc3414.auth',
+ 'pysnmp.proto.secmod.rfc3414.priv',
+ 'pysnmp.proto.secmod.rfc3826',
+ 'pysnmp.proto.secmod.rfc3826.priv',
+ 'pysnmp.proto.secmod.eso',
+ 'pysnmp.proto.secmod.eso.priv',
+ 'pysnmp.proto.acmod',
+ 'pysnmp.proto.proxy',
+ 'pysnmp.proto.api']
+})
setup(**params)