diff options
author | Ask Solem <ask@celeryproject.org> | 2014-01-13 14:42:26 +0000 |
---|---|---|
committer | Ask Solem <ask@celeryproject.org> | 2014-01-13 14:42:26 +0000 |
commit | f03ba7477331a0189347e38325c440132c434aa1 (patch) | |
tree | 462e45425ff26abb0a6903f2a2618d0cbf30ea44 | |
parent | 75bf573ade4c4ba9a6b4796484b443a566e50eca (diff) | |
download | py-amqp-f03ba7477331a0189347e38325c440132c434aa1.tar.gz |
flakes
-rw-r--r-- | amqp/connection.py | 6 | ||||
-rw-r--r-- | amqp/five.py | 1 | ||||
-rw-r--r-- | amqp/serialization.py | 2 | ||||
-rw-r--r-- | amqp/transport.py | 1 | ||||
-rwxr-xr-x | demo/amqp_clock.py | 17 | ||||
-rwxr-xr-x | demo/demo_receive.py | 24 | ||||
-rwxr-xr-x | demo/demo_send.py | 12 | ||||
-rw-r--r-- | docs/_ext/applyxrefs.py | 4 | ||||
-rw-r--r-- | docs/_ext/literals_to_xrefs.py | 4 | ||||
-rw-r--r-- | docs/conf.py | 6 | ||||
-rwxr-xr-x | extra/generate_skeleton_0_8.py | 17 | ||||
-rwxr-xr-x | funtests/test_channel.py | 14 | ||||
-rwxr-xr-x | funtests/test_serialization.py | 2 | ||||
-rw-r--r-- | pavement.py | 123 | ||||
-rw-r--r-- | setup.py | 3 |
15 files changed, 125 insertions, 111 deletions
diff --git a/amqp/connection.py b/amqp/connection.py index 7f2592a..0580e2e 100644 --- a/amqp/connection.py +++ b/amqp/connection.py @@ -862,7 +862,8 @@ class Connection(AbstractChannel): self.method_writer.frame_max = self.frame_max self.server_heartbeat = args.read_short() - # negotiate the heartbeat interval to the smaller of the specified values + # negotiate the heartbeat interval to the smaller of the + # specified values if self.server_heartbeat == 0 or self.client_heartbeat == 0: self.heartbeat = max(self.server_heartbeat, self.client_heartbeat) else: @@ -900,7 +901,8 @@ class Connection(AbstractChannel): # if we've missed two intervals' heartbeats, fail; this gives the # server enough time to send heartbeats a little late if (self.last_heartbeat_received and - self.last_heartbeat_received + 2 * self.heartbeat < monotonic()): + self.last_heartbeat_received + 2 * + self.heartbeat < monotonic()): raise ConnectionForced('Too many heartbeats missed') def _x_tune_ok(self, channel_max, frame_max, heartbeat): diff --git a/amqp/five.py b/amqp/five.py index 9f40329..5157df5 100644 --- a/amqp/five.py +++ b/amqp/five.py @@ -186,4 +186,3 @@ try: from time import monotonic except ImportError: monotonic = _monotonic # noqa - diff --git a/amqp/serialization.py b/amqp/serialization.py index 73227cc..528d0b7 100644 --- a/amqp/serialization.py +++ b/amqp/serialization.py @@ -347,7 +347,7 @@ class AMQPWriter(object): elif isinstance(v, (list, tuple)): self.write(b'A') self.write_array(v) - elif v == None: + elif v is None: self.write(b'V') else: err = (ILLEGAL_TABLE_TYPE_WITH_KEY.format(type(v), k, v) if k diff --git a/amqp/transport.py b/amqp/transport.py index c888849..e24a72a 100644 --- a/amqp/transport.py +++ b/amqp/transport.py @@ -18,6 +18,7 @@ from __future__ import absolute_import import errno import re import socket +import ssl # Jython does not have this attribute try: diff --git a/demo/amqp_clock.py b/demo/amqp_clock.py index d842296..c718266 100755 --- a/demo/amqp_clock.py +++ b/demo/amqp_clock.py @@ -27,18 +27,23 @@ TOPIC_PATTERN = '%Y.%m.%d.%w.%H.%M' # Python datetime.strftime() pattern def main(): parser = OptionParser() - parser.add_option('--host', dest='host', - help='AMQP server to connect to (default: %default)', - default='localhost') - parser.add_option('-u', '--userid', dest='userid', + parser.add_option( + '--host', dest='host', + help='AMQP server to connect to (default: %default)', + default='localhost', + ) + parser.add_option( + '-u', '--userid', dest='userid', help='AMQP userid to authenticate as (default: %default)', default='guest', ) - parser.add_option('-p', '--password', dest='password', + parser.add_option( + '-p', '--password', dest='password', help='AMQP password to authenticate with (default: %default)', default='guest', ) - parser.add_option('--ssl', dest='ssl', action='store_true', + parser.add_option( + '--ssl', dest='ssl', action='store_true', help='Enable SSL with AMQP server (default: not enabled)', default=False, ) diff --git a/demo/demo_receive.py b/demo/demo_receive.py index 7382604..bfda624 100755 --- a/demo/demo_receive.py +++ b/demo/demo_receive.py @@ -16,14 +16,14 @@ import amqp def callback(channel, msg): for key, val in msg.properties.items(): - print ('%s: %s' % (key, str(val))) + print('%s: %s' % (key, str(val))) for key, val in msg.delivery_info.items(): - print ('> %s: %s' % (key, str(val))) + print('> %s: %s' % (key, str(val))) - print ('') - print (msg.body) - print ('-------') - print msg.delivery_tag + print('') + print(msg.body) + print('-------') + print(msg.delivery_tag) channel.basic_ack(msg.delivery_tag) # @@ -35,19 +35,23 @@ def callback(channel, msg): def main(): parser = OptionParser() - parser.add_option('--host', dest='host', + parser.add_option( + '--host', dest='host', help='AMQP server to connect to (default: %default)', default='localhost', ) - parser.add_option('-u', '--userid', dest='userid', + parser.add_option( + '-u', '--userid', dest='userid', help='userid to authenticate as (default: %default)', default='guest', ) - parser.add_option('-p', '--password', dest='password', + parser.add_option( + '-p', '--password', dest='password', help='password to authenticate with (default: %default)', default='guest', ) - parser.add_option('--ssl', dest='ssl', action='store_true', + parser.add_option( + '--ssl', dest='ssl', action='store_true', help='Enable SSL (default: not enabled)', default=False, ) diff --git a/demo/demo_send.py b/demo/demo_send.py index 0084815..27bb1b1 100755 --- a/demo/demo_send.py +++ b/demo/demo_send.py @@ -19,19 +19,23 @@ def main(): parser = OptionParser( usage='usage: %prog [options] message\nexample: %prog hello world', ) - parser.add_option('--host', dest='host', + parser.add_option( + '--host', dest='host', help='AMQP server to connect to (default: %default)', default='localhost', ) - parser.add_option('-u', '--userid', dest='userid', + parser.add_option( + '-u', '--userid', dest='userid', help='userid to authenticate as (default: %default)', default='guest', ) - parser.add_option('-p', '--password', dest='password', + parser.add_option( + '-p', '--password', dest='password', help='password to authenticate with (default: %default)', default='guest', ) - parser.add_option('--ssl', dest='ssl', action='store_true', + parser.add_option( + '--ssl', dest='ssl', action='store_true', help='Enable SSL (default: not enabled)', default=False, ) diff --git a/docs/_ext/applyxrefs.py b/docs/_ext/applyxrefs.py index 027490b..deed5d9 100644 --- a/docs/_ext/applyxrefs.py +++ b/docs/_ext/applyxrefs.py @@ -6,8 +6,8 @@ import os testing = False DONT_TOUCH = ( - './index.txt', - ) + './index.txt', +) def target_name(fn): diff --git a/docs/_ext/literals_to_xrefs.py b/docs/_ext/literals_to_xrefs.py index e9dc7ca..41aa616 100644 --- a/docs/_ext/literals_to_xrefs.py +++ b/docs/_ext/literals_to_xrefs.py @@ -95,8 +95,8 @@ def fixliterals(fname): replace_type in ("class", "func", "meth"): default = default[:-2] replace_value = raw_input( - colorize("Text <target> [", fg="yellow") + default + \ - colorize("]: ", fg="yellow")).strip() + colorize("Text <target> [", fg="yellow") + default + + colorize("]: ", fg="yellow")).strip() if not replace_value: replace_value = default new.append(":%s:`%s`" % (replace_type, replace_value)) diff --git a/docs/conf.py b/docs/conf.py index 3b6f524..1191395 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -70,8 +70,8 @@ html_use_modindex = True html_use_index = True latex_documents = [ - ('index', 'py-amqp.tex', ur'py-amqp Documentation', - ur'Ask Solem & Contributors', 'manual'), + ('index', 'py-amqp.tex', ur'py-amqp Documentation', + ur'Ask Solem & Contributors', 'manual'), ] html_theme = "celery" @@ -89,7 +89,7 @@ if False: issuetracker_project = "celery/py-amqp" issuetracker_issue_pattern = r'[Ii]ssue #(\d+)' -# -- Options for Epub output --------------------------------------------------- +# -- Options for Epub output ------------------------------------------------ # Bibliographic Dublin Core info. epub_title = 'py-amqp Manual, Version 1.0' diff --git a/extra/generate_skeleton_0_8.py b/extra/generate_skeleton_0_8.py index 442bc83..3bf4482 100755 --- a/extra/generate_skeleton_0_8.py +++ b/extra/generate_skeleton_0_8.py @@ -204,9 +204,10 @@ def generate_methods(class_element, out): if 'content' in amqp_method.attrib: params.append('msg') - out.write(' def %s(%s):\n' % - (_fixup_method_name(class_element, amqp_method), - ', '.join(params + fieldnames))) + out.write(' def %s(%s):\n' % ( + _fixup_method_name(class_element, amqp_method), + ', '.join(params + fieldnames)), + ) s = generate_docstr(amqp_method, ' ', ' """') if s: @@ -231,7 +232,7 @@ def generate_methods(class_element, out): if 'synchronous' in amqp_method.attrib: responses = [x.attrib['name'] - for x in amqp_method.findall('response')] + for x in amqp_method.findall('response')] out.write(' return self.wait(allowed_methods=[\n') for r in responses: resp = method_name_map[(class_element.attrib['name'], r)] @@ -274,7 +275,7 @@ def generate_class(spec, class_element, out): # for amqp_class in spec.findall('class'): if (amqp_class.attrib['handler'] == class_element.attrib['name']) and \ - (amqp_class.attrib['name'] != class_element.attrib['name']): + (amqp_class.attrib['name'] != class_element.attrib['name']): out.write(' #############\n') out.write(' #\n') out.write(' # %s\n' % amqp_class.attrib['name'].capitalize()) @@ -315,8 +316,8 @@ def generate_module(spec, out): ( amqp_class.attrib['index'], amqp_method.attrib['index'], - amqp_class.attrib['handler'].capitalize() + '.' + - _fixup_method_name(amqp_class, amqp_method), + (amqp_class.attrib['handler'].capitalize() + '.' + + _fixup_method_name(amqp_class, amqp_method)), ) #### Actually generate output @@ -335,7 +336,7 @@ def generate_module(spec, out): # for chassis in amqp_method.findall('chassis'): # print ' ', chassis.attrib chassis = [x.attrib['name'] - for x in amqp_method.findall('chassis')] + for x in amqp_method.findall('chassis')] if 'client' in chassis: out.write(" (%s, %s): (%s, %s._%s),\n" % ( amqp_class.attrib['index'], diff --git a/funtests/test_channel.py b/funtests/test_channel.py index dc21287..10b860f 100755 --- a/funtests/test_channel.py +++ b/funtests/test_channel.py @@ -166,8 +166,8 @@ class TestChannel(unittest.TestCase): self.ch.queue_declare('krjqheewq_bogus', passive=True) self.ch.queue_declare('funtest_survive') self.ch.queue_declare('funtest_survive', passive=True) - self.assertEqual(0, - self.ch.queue_delete('funtest_survive'), + self.assertEqual( + 0, self.ch.queue_delete('funtest_survive'), ) def test_invalid_header(self): @@ -273,9 +273,9 @@ class TestChannel(unittest.TestCase): self.ch.exchange_declare(source_exchange, 'topic', auto_delete=True) qname, _, _ = self.ch.queue_declare() - self.ch.exchange_bind(destination = dest_exchange, - source = source_exchange, - routing_key = test_routing_key) + self.ch.exchange_bind(destination=dest_exchange, + source=source_exchange, + routing_key=test_routing_key) self.ch.queue_bind(qname, dest_exchange, routing_key=test_routing_key) @@ -284,9 +284,8 @@ class TestChannel(unittest.TestCase): content_type='text/plain', application_headers={'foo': 7, 'bar': 'baz'}) - self.ch.basic_publish(msg, source_exchange, - routing_key = test_routing_key) + routing_key=test_routing_key) msg2 = self.ch.basic_get(qname, no_ack=True) self.assertEqual(msg, msg2) @@ -309,6 +308,7 @@ class TestChannel(unittest.TestCase): source=source_exchange, routing_key=test_routing_key) + def main(): suite = unittest.TestLoader().loadTestsFromTestCase(TestChannel) unittest.TextTestRunner(**settings.test_args).run(suite) diff --git a/funtests/test_serialization.py b/funtests/test_serialization.py index d683311..ce70438 100755 --- a/funtests/test_serialization.py +++ b/funtests/test_serialization.py @@ -321,7 +321,7 @@ class TestSerialization(unittest.TestCase): 'baz': 'this is some random string I typed', 'ubaz': u'And something in unicode', 'dday_aniv': datetime(1994, 6, 6), - 'nothing' : None, + 'nothing': None, 'more': { 'abc': -123, 'def': 'hello world', diff --git a/pavement.py b/pavement.py index 685ca15..f3a4175 100644 --- a/pavement.py +++ b/pavement.py @@ -1,13 +1,11 @@ -import os -import sys -from paver.easy import * -from paver import doctools -from paver.setuputils import setup -sys.path.insert(0, os.path.abspath('.')) +from paver.easy import * # noqa +from paver import doctools # noqa +from paver.setuputils import setup # noqa + PYCOMPILE_CACHES = ['*.pyc', '*$py.class'] options( - sphinx=Bunch(builddir='.build'), + sphinx=Bunch(builddir='.build'), ) @@ -34,7 +32,7 @@ def html(options): def qhtml(options): destdir = path('Documentation') builtdocs = sphinx_builddir(options) - sh('rsync -az {0}/ {1}'.format(builtdocs, destdir)) + sh('rsync -az %s/ %s' % (builtdocs, destdir)) @task @@ -42,18 +40,17 @@ def qhtml(options): def ghdocs(options): builtdocs = sphinx_builddir(options) sh("git checkout gh-pages && \ - cp -r {0}/* . && \ + cp -r %s/* . && \ git commit . -m 'Rendered documentation for Github Pages.' && \ git push origin gh-pages && \ - git checkout master".format(builtdocs)) + git checkout master" % builtdocs) @task @needs('clean_docs', 'paver.doctools.html') def upload_pypi_docs(options): builtdocs = path('docs') / options.builddir / 'html' - sh("{0} setup.py upload_sphinx --upload-dir='{1}'".format( - sys.executable, builtdocs)) + sh("python setup.py upload_sphinx --upload-dir='%s'" % (builtdocs)) @task @@ -73,38 +70,6 @@ def verifyindex(options): @task -@cmdopts([ - ('noerror', 'E', 'Ignore errors'), -]) -def flake8(options): - noerror = getattr(options, 'noerror', False) - complexity = getattr(options, 'complexity', 22) - sh("""flake8 amqp | perl -mstrict -mwarnings -nle' - my $ignore = m/too complex \((\d+)\)/ && $1 le {0}; - if (! $ignore) {{ print STDERR; our $FOUND_FLAKE = 1 }} - }}{{exit $FOUND_FLAKE; - '""".format(complexity), ignore_error=noerror) - - -@task -@cmdopts([ - ('noerror', 'E', 'Ignore errors'), -]) -def flakeplus(options): - noerror = getattr(options, 'noerror', False) - sh('flakeplus amqp', ignore_error=noerror) - - -@task -@cmdopts([ - ('noerror', 'E', 'Ignore errors') -]) -def flakes(options): - flake8(options) - flakeplus(options) - - -@task def clean_readme(options): path('README').unlink() path('README.rst').unlink() @@ -113,15 +78,21 @@ def clean_readme(options): @task @needs('clean_readme') def readme(options): - sh('{0} extra/release/sphinx-to-rst.py docs/templates/readme.txt \ - > README.rst'.format(sys.executable)) + sh('python extra/release/sphinx-to-rst.py docs/templates/readme.txt \ + > README.rst') + sh('ln -sf README.rst README') @task +@cmdopts([ + ('custom=', 'C', 'custom version'), +]) def bump(options): - sh("extra/release/bump_version.py \ - amqp/__init__.py docs/includes/intro.txt \ - --before-commit='paver readme'") + s = ("-- '%s'" % (options.custom, ) if getattr(options, 'custom', None) + else '') + sh('extra/release/bump_version.py \ + amqp/__init__.py README.rst %s' % (s, )) + @task @cmdopts([ @@ -133,6 +104,8 @@ def test(options): cmd = 'nosetests' if getattr(options, 'coverage', False): cmd += ' --with-coverage3' + if getattr(options, 'quick', False): + cmd = 'QUICKTEST=1 SKIP_RLIMITS=1 %s' % cmd if getattr(options, 'verbose', False): cmd += ' --verbosity=2' sh(cmd) @@ -142,18 +115,52 @@ def test(options): @cmdopts([ ('noerror', 'E', 'Ignore errors'), ]) +def flake8(options): + noerror = getattr(options, 'noerror', False) + complexity = getattr(options, 'complexity', 22) + sh("""flake8 amqp | perl -mstrict -mwarnings -nle' + my $ignore = (m/too complex \((\d+)\)/ && $1 le %s); + if (! $ignore) { print STDERR; our $FOUND_FLAKE = 1 } + }{exit $FOUND_FLAKE; + '""" % (complexity, ), ignore_error=noerror) + + +@task +@cmdopts([ + ('noerror', 'E', 'Ignore errors'), +]) +def flakeplus(options): + noerror = getattr(options, 'noerror', False) + sh('flakeplus amqp --2.6', + ignore_error=noerror) + + +@task +@cmdopts([ + ('noerror', 'E', 'Ignore errors'), +]) +def flakes(options): + flake8(options) + flakeplus(options) + + +@task +@cmdopts([ + ('noerror', 'E', 'Ignore errors'), +]) def pep8(options): noerror = getattr(options, 'noerror', False) - return sh("""find . -name "*.py" | xargs pep8 | perl -nle'\ + return sh("""find amqp -name "*.py" | xargs pep8 | perl -nle'\ print; $a=1 if $_}{exit($a)'""", ignore_error=noerror) @task def removepyc(options): - sh('find . -type f -a \\( {0} \\) | xargs rm'.format( - ' -o '.join("-name '{0}'".format(pat) for pat in PYCOMPILE_CACHES))) + sh('find . -type f -a \\( %s \\) | xargs rm' % ( + ' -o '.join("-name '%s'" % (pat, ) for pat in PYCOMPILE_CACHES), )) sh('find . -type d -name "__pycache__" | xargs rm -r') + @task @needs('removepyc') def gitclean(options): @@ -167,7 +174,7 @@ def gitcleanforce(options): @task -@needs('flakes', 'autodoc', 'verifyindex', 'gitclean') +@needs('flakes', 'autodoc', 'verifyindex', 'test', 'gitclean') def releaseok(options): pass @@ -176,13 +183,3 @@ def releaseok(options): @needs('releaseok', 'removepyc', 'upload_docs') def release(options): pass - - -@task -def testloc(options): - sh('sloccount tests') - - -@task -def loc(options): - sh('sloccount amqp') @@ -35,7 +35,8 @@ classes = """ Programming Language :: Python :: 3.1 Programming Language :: Python :: 3.2 Programming Language :: Python :: 3.3 - License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL) + License :: OSI Approved :: GNU Library or \ +Lesser General Public License (LGPL) Intended Audience :: Developers License :: OSI Approved :: BSD License Operating System :: OS Independent |