changeset 2925:da84a2c42a92

fix #492 pep8 1.6.2 breaks 83 additional tests
author RogerHaase <haaserd@gmail.com>
date Sun, 22 Feb 2015 11:21:01 -0700
parents 60116a78e932
children 25e0de2a082f
files MoinMoin/__init__.py MoinMoin/_tests/ldap_testbase.py MoinMoin/app.py MoinMoin/apps/feed/views.py MoinMoin/apps/frontend/views.py MoinMoin/apps/serve/views.py MoinMoin/auth/_tests/test_log.py MoinMoin/auth/http.py MoinMoin/auth/ldap_login.py MoinMoin/auth/log.py MoinMoin/auth/openidrp.py MoinMoin/auth/smb_mount.py MoinMoin/conftest.py MoinMoin/converter/_tests/test_docbook_in.py MoinMoin/converter/_tests/test_docbook_out.py MoinMoin/converter/_tests/test_html_in.py MoinMoin/converter/_tests/test_html_in_out.py MoinMoin/converter/_tests/test_html_out.py MoinMoin/converter/_wiki_macro.py MoinMoin/converter/archive_in.py MoinMoin/converter/docbook_in.py MoinMoin/converter/docbook_out.py MoinMoin/converter/html_in.py MoinMoin/converter/markdown_in.py MoinMoin/converter/mediawiki_in.py MoinMoin/converter/moinwiki19_in.py MoinMoin/converter/opendocument_in.py MoinMoin/converter/pdf_in.py MoinMoin/converter/pygments_in.py MoinMoin/converter/rst_in.py MoinMoin/converter/rst_out.py MoinMoin/converter/xml_in.py MoinMoin/mail/sendmail.py MoinMoin/script/maint/index.py MoinMoin/script/migration/moin19/import19.py MoinMoin/security/__init__.py MoinMoin/security/textcha.py MoinMoin/security/ticket.py MoinMoin/storage/backends/_tests/test_stores.py MoinMoin/storage/middleware/indexing.py MoinMoin/storage/middleware/protecting.py MoinMoin/user.py MoinMoin/util/clock.py MoinMoin/util/subscriptions.py MoinMoin/wikiutil.py setup.cfg
diffstat 46 files changed, 159 insertions(+), 163 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/__init__.py	Sat Feb 21 11:09:16 2015 -0700
+++ b/MoinMoin/__init__.py	Sun Feb 22 11:21:01 2015 -0700
@@ -9,16 +9,17 @@
 
 from __future__ import absolute_import, division
 
-project = "MoinMoin"
-
 import sys
 import platform
 
+from MoinMoin.util.version import Version
+
+
+project = "MoinMoin"
+
 
 if sys.hexversion < 0x2070000 or sys.hexversion > 0x2999999:
     sys.exit("Error: %s requires Python 2.7.x., current version is %s\n" % (project, platform.python_version()))
 
 
-from MoinMoin.util.version import Version
-
 version = Version(2, 0, 0, 'a0')
--- a/MoinMoin/_tests/ldap_testbase.py	Sat Feb 21 11:09:16 2015 -0700
+++ b/MoinMoin/_tests/ldap_testbase.py	Sun Feb 22 11:21:01 2015 -0700
@@ -36,10 +36,6 @@
 """
 
 
-# filename of LDAP server executable - if it is not
-# in your PATH, you have to give full path/filename.
-SLAPD_EXECUTABLE = 'slapd'
-
 import os
 import shutil
 import tempfile
@@ -59,6 +55,11 @@
     ldap = None
 
 
+# filename of LDAP server executable - if it is not
+# in your PATH, you have to give full path/filename.
+SLAPD_EXECUTABLE = 'slapd'
+
+
 def check_environ():
     """ Check the system environment whether we are able to run.
         Either return some failure reason if we can't or None if everything
--- a/MoinMoin/app.py	Sat Feb 21 11:09:16 2015 -0700
+++ b/MoinMoin/app.py	Sun Feb 22 11:21:01 2015 -0700
@@ -25,16 +25,16 @@
 
 from jinja2 import ChoiceLoader, FileSystemLoader
 
-from MoinMoin import log
-logging = log.getLogger(__name__)
-
 from MoinMoin.constants.misc import ANON
 from MoinMoin.i18n import i18n_init
 from MoinMoin.i18n import _, L_, N_
-
 from MoinMoin.themes import setup_jinja_env, themed_error
+from MoinMoin.util.clock import Clock
+from MoinMoin.storage.middleware import protecting, indexing, routing
+from MoinMoin import auth, config, user
 
-from MoinMoin.util.clock import Clock
+from MoinMoin import log
+logging = log.getLogger(__name__)
 
 
 def create_app(config=None, create_index=False, create_storage=False):
@@ -165,10 +165,6 @@
     deinit_backends(app)
 
 
-from MoinMoin.storage.middleware import protecting, indexing, routing
-from MoinMoin import auth, config, user
-
-
 def init_backends(app):
     """
     initialize the backends
--- a/MoinMoin/apps/feed/views.py	Sat Feb 21 11:09:16 2015 -0700
+++ b/MoinMoin/apps/feed/views.py	Sun Feb 22 11:21:01 2015 -0700
@@ -20,9 +20,6 @@
 
 from whoosh.query import Term, And
 
-from MoinMoin import log
-logging = log.getLogger(__name__)
-
 from MoinMoin.i18n import _, L_, N_
 from MoinMoin.apps.feed import feed
 from MoinMoin.constants.keys import NAME, NAME_EXACT, WIKINAME, COMMENT, MTIME, REVID, ALL_REVS, PARENTID, LATEST_REVS
@@ -31,6 +28,9 @@
 from MoinMoin.util.crypto import cache_key
 from MoinMoin.util.interwiki import url_for_item
 
+from MoinMoin import log
+logging = log.getLogger(__name__)
+
 
 @feed.route('/atom/<itemname:item_name>')
 @feed.route('/atom', defaults=dict(item_name=''))
--- a/MoinMoin/apps/frontend/views.py	Sat Feb 21 11:09:16 2015 -0700
+++ b/MoinMoin/apps/frontend/views.py	Sun Feb 22 11:21:01 2015 -0700
@@ -1411,8 +1411,7 @@
     name_or_email_needed_msg = L_('Your user name or your email address is needed.')
 
     def validate(self, element, state):
-        if not(element['username'].valid and element['username'].value
-               or
+        if not(element['username'].valid and element['username'].value or
                element['email'].valid and element['email'].value):
             return self.note_error(element, state, 'name_or_email_needed_msg')
 
--- a/MoinMoin/apps/serve/views.py	Sat Feb 21 11:09:16 2015 -0700
+++ b/MoinMoin/apps/serve/views.py	Sun Feb 22 11:21:01 2015 -0700
@@ -11,11 +11,11 @@
 
 from flask import current_app as app
 
+from MoinMoin.apps.serve import serve
+
 from MoinMoin import log
 logging = log.getLogger(__name__)
 
-from MoinMoin.apps.serve import serve
-
 
 @serve.route('/')
 def index():
--- a/MoinMoin/auth/_tests/test_log.py	Sat Feb 21 11:09:16 2015 -0700
+++ b/MoinMoin/auth/_tests/test_log.py	Sun Feb 22 11:21:01 2015 -0700
@@ -5,14 +5,15 @@
 Test for auth.log
 """
 
-from MoinMoin import log
-logging = log.getLogger(__name__)
 
 from flask import g as flaskg
 
 from MoinMoin.auth.log import AuthLog
 from MoinMoin.constants.misc import ANON
 
+from MoinMoin import log
+logging = log.getLogger(__name__)
+
 
 class TestAuthLog(object):
     """ Test: TestAuthLog """
--- a/MoinMoin/auth/http.py	Sat Feb 21 11:09:16 2015 -0700
+++ b/MoinMoin/auth/http.py	Sun Feb 22 11:21:01 2015 -0700
@@ -17,15 +17,15 @@
 """
 
 
-from MoinMoin import log
-logging = log.getLogger(__name__)
-
 from flask import request
 
 from MoinMoin import user
 from MoinMoin.i18n import _, L_, N_
 from MoinMoin.auth import BaseAuth, GivenAuth
 
+from MoinMoin import log
+logging = log.getLogger(__name__)
+
 
 class HTTPAuthMoin(BaseAuth):
     """ authenticate via http (basic) auth """
--- a/MoinMoin/auth/ldap_login.py	Sat Feb 21 11:09:16 2015 -0700
+++ b/MoinMoin/auth/ldap_login.py	Sun Feb 22 11:21:01 2015 -0700
@@ -17,8 +17,6 @@
     TODO: allow more configuration (display name, ...) by using callables as parameters
 """
 
-from MoinMoin import log
-logging = log.getLogger(__name__)
 
 try:
     import ldap
@@ -30,6 +28,9 @@
 from MoinMoin.i18n import _, L_, N_
 from MoinMoin.auth import BaseAuth, CancelLogin, ContinueLogin
 
+from MoinMoin import log
+logging = log.getLogger(__name__)
+
 
 class LDAPAuth(BaseAuth):
     """ get authentication data from form, authenticate against LDAP (or Active
--- a/MoinMoin/auth/log.py	Sat Feb 21 11:09:16 2015 -0700
+++ b/MoinMoin/auth/log.py	Sun Feb 22 11:21:01 2015 -0700
@@ -9,11 +9,11 @@
 """
 
 
+from MoinMoin.auth import BaseAuth, ContinueLogin
+
 from MoinMoin import log
 logging = log.getLogger(__name__)
 
-from MoinMoin.auth import BaseAuth, ContinueLogin
-
 
 class AuthLog(BaseAuth):
     """ just log the call, do nothing else """
--- a/MoinMoin/auth/openidrp.py	Sat Feb 21 11:09:16 2015 -0700
+++ b/MoinMoin/auth/openidrp.py	Sun Feb 22 11:21:01 2015 -0700
@@ -8,9 +8,6 @@
 """
 
 
-from MoinMoin import log
-logging = log.getLogger(__name__)
-
 from openid.store.memstore import MemoryStore
 from openid.consumer import consumer
 from openid.yadis.discover import DiscoveryFailure
@@ -24,6 +21,9 @@
 from MoinMoin import user
 from MoinMoin.i18n import _, L_, N_
 
+from MoinMoin import log
+logging = log.getLogger(__name__)
+
 
 class OpenIDAuth(BaseAuth):
     def __init__(self, trusted_providers=[], **kw):
--- a/MoinMoin/auth/smb_mount.py	Sat Feb 21 11:09:16 2015 -0700
+++ b/MoinMoin/auth/smb_mount.py	Sun Feb 22 11:21:01 2015 -0700
@@ -11,11 +11,11 @@
 """
 
 
+from MoinMoin.auth import BaseAuth, CancelLogin, ContinueLogin
+
 from MoinMoin import log
 logging = log.getLogger(__name__)
 
-from MoinMoin.auth import BaseAuth, CancelLogin, ContinueLogin
-
 
 class SMBMount(BaseAuth):
     """ auth plugin for (un)mounting an smb share,
--- a/MoinMoin/conftest.py	Sat Feb 21 11:09:16 2015 -0700
+++ b/MoinMoin/conftest.py	Sun Feb 22 11:21:01 2015 -0700
@@ -18,6 +18,16 @@
 
 from __future__ import absolute_import, division
 
+import pytest
+import py
+import MoinMoin.log
+import MoinMoin
+
+from MoinMoin.app import create_app_ext, destroy_app, before_wiki, teardown_wiki
+from MoinMoin._tests import wikiconfig
+from MoinMoin.storage import create_simple_mapping
+
+
 # exclude some directories from py.test test discovery, pathes relative to this file
 collect_ignore = [
     'static',  # same
@@ -25,20 +35,11 @@
     '../instance',  # tw likes to use this for wiki data (non-revisioned)
 ]
 
-import pytest
-import py
-import MoinMoin.log
-import MoinMoin
-
 # Logging for tests to avoid useless output like timing information on stderr on test failures
 Moindir = py.path.local(MoinMoin.__file__).dirname
 config_file = Moindir + '/_tests/test_logging.conf'
 MoinMoin.log.load_config(config_file)
 
-from MoinMoin.app import create_app_ext, destroy_app, before_wiki, teardown_wiki
-from MoinMoin._tests import wikiconfig
-from MoinMoin.storage import create_simple_mapping
-
 
 @pytest.fixture
 def cfg():
--- a/MoinMoin/converter/_tests/test_docbook_in.py	Sat Feb 21 11:09:16 2015 -0700
+++ b/MoinMoin/converter/_tests/test_docbook_in.py	Sun Feb 22 11:21:01 2015 -0700
@@ -16,11 +16,11 @@
 
 from emeraldtree.tree import *
 
+from MoinMoin.converter.docbook_in import *
+
 from MoinMoin import log
 logging = log.getLogger(__name__)
 
-from MoinMoin.converter.docbook_in import *
-
 
 class Base(object):
     input_namespaces = ns_all = u'xmlns="{0}" xmlns:xlink="{1}"'.format(docbook.namespace, xlink.namespace)
--- a/MoinMoin/converter/_tests/test_docbook_out.py	Sat Feb 21 11:09:16 2015 -0700
+++ b/MoinMoin/converter/_tests/test_docbook_out.py	Sun Feb 22 11:21:01 2015 -0700
@@ -15,11 +15,11 @@
 
 from emeraldtree.tree import *
 
+from MoinMoin.converter.docbook_out import *
+
 from MoinMoin import log
 logging = log.getLogger(__name__)
 
-from MoinMoin.converter.docbook_out import *
-
 
 class Base(object):
     input_namespaces = ns_all = 'xmlns="{0}" xmlns:page="{1}" xmlns:html="{2}" xmlns:xlink="{3}" xmlns:xml="{4}"'.format(moin_page.namespace, moin_page.namespace, html.namespace, xlink.namespace, xml.namespace)
--- a/MoinMoin/converter/_tests/test_html_in.py	Sat Feb 21 11:09:16 2015 -0700
+++ b/MoinMoin/converter/_tests/test_html_in.py	Sun Feb 22 11:21:01 2015 -0700
@@ -15,9 +15,10 @@
 
 from emeraldtree.tree import *
 
+from MoinMoin.converter.html_in import *
+
 from MoinMoin import log
 logging = log.getLogger(__name__)
-from MoinMoin.converter.html_in import *
 
 
 class Base(object):
--- a/MoinMoin/converter/_tests/test_html_in_out.py	Sat Feb 21 11:09:16 2015 -0700
+++ b/MoinMoin/converter/_tests/test_html_in_out.py	Sun Feb 22 11:21:01 2015 -0700
@@ -16,13 +16,13 @@
 
 etree = pytest.importorskip('lxml.etree')
 
-from MoinMoin import log
-logging = log.getLogger(__name__)
-
 from MoinMoin.converter.html_in import Converter as HTML_IN
 from MoinMoin.converter.html_out import Converter as HTML_OUT
 from MoinMoin.util.tree import html, moin_page, xlink
 
+from MoinMoin import log
+logging = log.getLogger(__name__)
+
 
 class Base(object):
 
--- a/MoinMoin/converter/_tests/test_html_out.py	Sat Feb 21 11:09:16 2015 -0700
+++ b/MoinMoin/converter/_tests/test_html_out.py	Sun Feb 22 11:21:01 2015 -0700
@@ -16,11 +16,11 @@
 
 from emeraldtree.tree import *
 
+from MoinMoin.converter.html_out import *
+
 from MoinMoin import log
 logging = log.getLogger(__name__)
 
-from MoinMoin.converter.html_out import *
-
 
 class Base(object):
     input_namespaces = ns_all = 'xmlns="{0}" xmlns:page="{1}" xmlns:html="{2}" xmlns:xlink="{3}" xmlns:xml="{4}"'.format(moin_page.namespace, moin_page.namespace, html.namespace, xlink.namespace, xml.namespace)
--- a/MoinMoin/converter/_wiki_macro.py	Sat Feb 21 11:09:16 2015 -0700
+++ b/MoinMoin/converter/_wiki_macro.py	Sun Feb 22 11:21:01 2015 -0700
@@ -7,8 +7,6 @@
 Base class for wiki parser with macro support.
 """
 
-from MoinMoin import log
-logging = log.getLogger(__name__)
 
 from emeraldtree import ElementTree as ET
 
@@ -16,6 +14,9 @@
 from MoinMoin.util.mime import Type
 from MoinMoin.util.tree import moin_page, xinclude
 
+from MoinMoin import log
+logging = log.getLogger(__name__)
+
 
 class ConverterMacro(object):
     def _BR_repl(self, args, text, context_block):
--- a/MoinMoin/converter/archive_in.py	Sat Feb 21 11:09:16 2015 -0700
+++ b/MoinMoin/converter/archive_in.py	Sun Feb 22 11:21:01 2015 -0700
@@ -14,13 +14,13 @@
 
 from ._table import TableMixin
 
-from MoinMoin import log
-logging = log.getLogger(__name__)
-
 from MoinMoin.i18n import _, L_, N_
 from MoinMoin.util.iri import Iri
 from MoinMoin.util.tree import moin_page, xlink
 
+from MoinMoin import log
+logging = log.getLogger(__name__)
+
 
 class ArchiveException(Exception):
     """
--- a/MoinMoin/converter/docbook_in.py	Sat Feb 21 11:09:16 2015 -0700
+++ b/MoinMoin/converter/docbook_in.py	Sun Feb 22 11:21:01 2015 -0700
@@ -25,14 +25,13 @@
     # in case converters become an independent package
     flaskg = None
 
-from MoinMoin import log
-logging = log.getLogger(__name__)
-
 from MoinMoin.util.tree import moin_page, xlink, docbook, xml, html
 from MoinMoin.converter.html_out import mark_item_as_transclusion
 
 from ._wiki_macro import ConverterMacro
 from ._util import allowed_uri_scheme, decode_data, normalize_split_text
+from MoinMoin import log
+logging = log.getLogger(__name__)
 
 
 class NameSpaceError(Exception):
--- a/MoinMoin/converter/docbook_out.py	Sat Feb 21 11:09:16 2015 -0700
+++ b/MoinMoin/converter/docbook_out.py	Sun Feb 22 11:21:01 2015 -0700
@@ -13,12 +13,12 @@
 
 from emeraldtree import ElementTree as ET
 
+from MoinMoin.util.tree import html, moin_page, xlink, docbook, xml
+from MoinMoin.constants.contenttypes import CONTENTTYPE_NONEXISTENT
+
 from MoinMoin import log
 logging = log.getLogger(__name__)
 
-from MoinMoin.util.tree import html, moin_page, xlink, docbook, xml
-from MoinMoin.constants.contenttypes import CONTENTTYPE_NONEXISTENT
-
 
 class Converter(object):
     """
--- a/MoinMoin/converter/html_in.py	Sat Feb 21 11:09:16 2015 -0700
+++ b/MoinMoin/converter/html_in.py	Sun Feb 22 11:21:01 2015 -0700
@@ -17,14 +17,14 @@
 from emeraldtree import ElementTree as ET
 from emeraldtree.html import HTML
 
-from MoinMoin import log
-logging = log.getLogger(__name__)
-
 from MoinMoin.util.tree import html, moin_page, xlink, xml
 
 from ._wiki_macro import ConverterMacro
 from ._util import allowed_uri_scheme, decode_data, normalize_split_text
 
+from MoinMoin import log
+logging = log.getLogger(__name__)
+
 
 class Converter(object):
     """
--- a/MoinMoin/converter/markdown_in.py	Sat Feb 21 11:09:16 2015 -0700
+++ b/MoinMoin/converter/markdown_in.py	Sun Feb 22 11:21:01 2015 -0700
@@ -19,9 +19,6 @@
 from ._util import allowed_uri_scheme, decode_data
 from MoinMoin.util.iri import Iri
 
-from MoinMoin import log
-logging = log.getLogger(__name__)
-
 from emeraldtree import ElementTree as ET
 try:
     from flask import g as flaskg
@@ -31,6 +28,8 @@
 
 from markdown import Markdown
 import markdown.util as md_util
+from MoinMoin import log
+logging = log.getLogger(__name__)
 
 
 def postproc_text(markdown, text):
--- a/MoinMoin/converter/mediawiki_in.py	Sat Feb 21 11:09:16 2015 -0700
+++ b/MoinMoin/converter/mediawiki_in.py	Sun Feb 22 11:21:01 2015 -0700
@@ -17,9 +17,6 @@
 
 from werkzeug import url_encode
 
-from MoinMoin import log
-logging = log.getLogger(__name__)
-
 from MoinMoin.constants.contenttypes import CHARSET
 from MoinMoin.constants.misc import URI_SCHEMES
 from MoinMoin.util.iri import Iri
@@ -29,6 +26,9 @@
 from ._wiki_macro import ConverterMacro
 from ._util import decode_data, normalize_split_text, _Iter, _Stack
 
+from MoinMoin import log
+logging = log.getLogger(__name__)
+
 
 class _TableArguments(object):
     rules = r'''
--- a/MoinMoin/converter/moinwiki19_in.py	Sat Feb 21 11:09:16 2015 -0700
+++ b/MoinMoin/converter/moinwiki19_in.py	Sun Feb 22 11:21:01 2015 -0700
@@ -13,9 +13,6 @@
 
 import re
 
-from MoinMoin import log
-logging = log.getLogger(__name__)
-
 from MoinMoin import wikiutil
 from MoinMoin.constants.misc import URI_SCHEMES
 from MoinMoin.constants.chartypes import CHARS_LOWER, CHARS_UPPER
@@ -25,6 +22,9 @@
 
 from .moinwiki_in import Converter
 
+from MoinMoin import log
+logging = log.getLogger(__name__)
+
 
 class ConverterFormat19(Converter):
     @classmethod
--- a/MoinMoin/converter/opendocument_in.py	Sat Feb 21 11:09:16 2015 -0700
+++ b/MoinMoin/converter/opendocument_in.py	Sun Feb 22 11:21:01 2015 -0700
@@ -12,11 +12,11 @@
 
 import zipfile
 
+from .xml_in import strip_xml
+
 from MoinMoin import log
 logging = log.getLogger(__name__)
 
-from .xml_in import strip_xml
-
 
 class OpenDocumentIndexingConverter(object):
     @classmethod
--- a/MoinMoin/converter/pdf_in.py	Sat Feb 21 11:09:16 2015 -0700
+++ b/MoinMoin/converter/pdf_in.py	Sun Feb 22 11:21:01 2015 -0700
@@ -8,9 +8,6 @@
 
 from __future__ import absolute_import, division
 
-from MoinMoin import log
-logging = log.getLogger(__name__)
-
 from pdfminer.pdfparser import PDFDocument, PDFParser
 from pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreter, process_pdf
 from pdfminer.pdfdevice import PDFDevice
@@ -18,6 +15,9 @@
 from pdfminer.cmapdb import CMapDB
 from pdfminer.layout import LAParams
 
+from MoinMoin import log
+logging = log.getLogger(__name__)
+
 
 LAPARAMS = LAParams(
     # value is specified not as an actual length, but as a proportion of the length to the
--- a/MoinMoin/converter/pygments_in.py	Sat Feb 21 11:09:16 2015 -0700
+++ b/MoinMoin/converter/pygments_in.py	Sun Feb 22 11:21:01 2015 -0700
@@ -17,14 +17,13 @@
 except ImportError:
     pygments = None
 
+from MoinMoin.util.mime import Type, type_moin_document
+from MoinMoin.util.tree import moin_page
+from ._util import decode_data, normalize_split_text
 
 from MoinMoin import log
 logging = log.getLogger(__name__)
 
-from MoinMoin.util.mime import Type, type_moin_document
-from MoinMoin.util.tree import moin_page
-from ._util import decode_data, normalize_split_text
-
 
 if pygments:
     class TreeFormatter(pygments.formatter.Formatter):
--- a/MoinMoin/converter/rst_in.py	Sat Feb 21 11:09:16 2015 -0700
+++ b/MoinMoin/converter/rst_in.py	Sun Feb 22 11:21:01 2015 -0700
@@ -22,9 +22,6 @@
 
 from werkzeug import url_encode, url_decode
 
-from MoinMoin import log
-logging = log.getLogger(__name__)
-
 try:
     from flask import g as flaskg
 except ImportError:
@@ -47,6 +44,9 @@
 from docutils.parsers.rst import directives, roles
 # ####
 
+from MoinMoin import log
+logging = log.getLogger(__name__)
+
 
 class NodeVisitor(object):
     """
--- a/MoinMoin/converter/rst_out.py	Sat Feb 21 11:09:16 2015 -0700
+++ b/MoinMoin/converter/rst_out.py	Sun Feb 22 11:21:01 2015 -0700
@@ -338,9 +338,7 @@
                             u' ' * (len(u''.join(self.list_item_labels)) + len(self.list_item_labels)), m.group(1)), child)
                     if self.last_closed == "p":
                         childrens_output.append(
-                            u'\n' + u' '
-                            * (len(''.join(self.list_item_labels)) +
-                               len(self.list_item_labels)))
+                            u'\n' + u' ' * (len(''.join(self.list_item_labels)) + len(self.list_item_labels)))
                 elif self.status[-1] == "text":
                     if self.last_closed == "p":
                         childrens_output.append(self.define_references())
@@ -395,8 +393,8 @@
     def open_moinpage_blockcode(self, elem):
         text = u''.join(elem.itertext())
         max_subpage_lvl = 3
-        text = text.replace(u'\n', u'\n  '
-                            + u' ' * (len(u''.join(self.list_item_labels)) + len(self.list_item_labels)))
+        text = text.replace(u'\n', u'\n  ' +
+                            u' ' * (len(u''.join(self.list_item_labels)) + len(self.list_item_labels)))
 
         if self.list_level >= 0:
             self.delete_newlines = True
@@ -436,10 +434,7 @@
 
     def open_moinpage_line_break(self, elem):
         if self.status[-1] == "list":
-            return (ReST.linebreak
-                    + u' '
-                      * (len(u''.join(self.list_item_labels))
-                         + len(self.list_item_labels)))
+            return (ReST.linebreak + u' ' * (len(u''.join(self.list_item_labels)) + len(self.list_item_labels)))
         if self.last_closed == 'p':
             return u'\n\n'
         return ReST.linebreak
@@ -473,9 +468,7 @@
         if self.list_item_labels[-1] == u'' or self.list_item_labels[-1] == u' ':
             self.list_item_labels[-1] = u' '
             self.list_item_label = self.list_item_labels[-1] + u' '
-            ret = (u' '
-                   * (len(u''.join(self.list_item_labels[:-1]))
-                      + len(self.list_item_labels[:-1])))
+            ret = (u' ' * (len(u''.join(self.list_item_labels[:-1])) + len(self.list_item_labels[:-1])))
             if self.last_closed and self.last_closed != 'list':
                 ret = u'\n{0}'.format(ret)
             return ret + self.open_children(elem)
@@ -485,9 +478,8 @@
         ret = u''
         if self.last_closed:
             ret = u'\n'
-        ret += (u' ' * (len(u''.join(self.list_item_labels[:-1]))
-                        + len(self.list_item_labels[:-1]))
-                + self.list_item_label)
+        ret += (u' ' * (len(u''.join(self.list_item_labels[:-1])) +
+                        len(self.list_item_labels[:-1])) + self.list_item_label)
         if self.list_item_labels[-1] in [u'1.', u'i.', u'I.', u'a.', u'A.']:
             self.list_item_labels[-1] = u'#.'
 
@@ -558,13 +550,12 @@
                 and self.last_closed != 'list_item_header' \
                 and self.last_closed != 'list_item_footer' \
                 and self.last_closed != 'p':
-                ret = (ReST.linebreak + u' '
-                                        * (len(u''.join(self.list_item_labels))
-                                           + len(self.list_item_labels)) + self.open_children(elem))
+                ret = (ReST.linebreak + u' ' * (len(u''.join(self.list_item_labels)) +
+                                                len(self.list_item_labels)) + self.open_children(elem))
             elif self.last_closed and self.last_closed == 'p':
                 # return ReST.p +\
-                ret = (u"\n" + u' ' * (len(u''.join(self.list_item_labels))
-                                       + len(self.list_item_labels)) + self.open_children(elem))
+                ret = (u"\n" + u' ' * (len(u''.join(self.list_item_labels)) +
+                                       len(self.list_item_labels)) + self.open_children(elem))
             else:
                 ret = self.open_children(elem)
             if not self.delete_newlines:
@@ -747,10 +738,10 @@
         """
         ret = u''
         self.all_used_references.extend(self.used_references)
-        definitions = [u" " * (len(u''.join(self.list_item_labels)) + len(self.list_item_labels))
-                       + u".. _{0}: {1}".format(t, h) for t, h in self.used_references]
-        definitions.extend(u" " * (len(u''.join(self.list_item_labels)) + len(self.list_item_labels))
-                           + link for link in self.objects)
+        definitions = [u" " * (len(u''.join(self.list_item_labels)) + len(self.list_item_labels)) +
+                       u".. _{0}: {1}".format(t, h) for t, h in self.used_references]
+        definitions.extend(u" " * (len(u''.join(self.list_item_labels)) + len(self.list_item_labels)) +
+                           link for link in self.objects)
         definition_block = u"\n\n".join(definitions)
 
         if definitions:
--- a/MoinMoin/converter/xml_in.py	Sat Feb 21 11:09:16 2015 -0700
+++ b/MoinMoin/converter/xml_in.py	Sun Feb 22 11:21:01 2015 -0700
@@ -9,10 +9,11 @@
 
 import re
 
+from ._util import decode_data
+
 from MoinMoin import log
 logging = log.getLogger(__name__)
 
-from ._util import decode_data
 
 RX_STRIPXML = re.compile(u"<[^>]*?>", re.U | re.DOTALL | re.MULTILINE)
 
--- a/MoinMoin/mail/sendmail.py	Sat Feb 21 11:09:16 2015 -0700
+++ b/MoinMoin/mail/sendmail.py	Sun Feb 22 11:21:01 2015 -0700
@@ -12,14 +12,15 @@
 import re
 from email.header import Header
 
-from MoinMoin import log
-logging = log.getLogger(__name__)
-
 from flask import current_app as app
 
 from MoinMoin.constants.contenttypes import CHARSET
 from MoinMoin.i18n import _, L_, N_
 
+from MoinMoin import log
+logging = log.getLogger(__name__)
+
+
 _transdict = {"AT": "@", "DOT": ".", "DASH": "-"}
 
 
--- a/MoinMoin/script/maint/index.py	Sat Feb 21 11:09:16 2015 -0700
+++ b/MoinMoin/script/maint/index.py	Sun Feb 22 11:21:01 2015 -0700
@@ -10,11 +10,11 @@
 from flask.ext.script import Command, Option
 from flask import g as flaskg
 
+from MoinMoin.constants.keys import LATEST_REVS, ALL_REVS
+
 from MoinMoin import log
 logging = log.getLogger(__name__)
 
-from MoinMoin.constants.keys import LATEST_REVS, ALL_REVS
-
 
 class IndexCreate(Command):
     description = 'Create empty indexes.'
--- a/MoinMoin/script/migration/moin19/import19.py	Sat Feb 21 11:09:16 2015 -0700
+++ b/MoinMoin/script/migration/moin19/import19.py	Sun Feb 22 11:21:01 2015 -0700
@@ -23,9 +23,6 @@
 from flask import current_app as app
 from flask.ext.script import Command, Option
 
-from MoinMoin import log
-logging = log.getLogger(__name__)
-
 from ._utils19 import quoteWikinameFS, unquoteWikiname, split_body
 from ._logfile19 import LogFile
 
@@ -41,6 +38,9 @@
 from MoinMoin.util.crypto import make_uuid
 from MoinMoin import security
 
+from MoinMoin import log
+logging = log.getLogger(__name__)
+
 
 CHARSET = 'utf-8'
 
--- a/MoinMoin/security/__init__.py	Sat Feb 21 11:09:16 2015 -0700
+++ b/MoinMoin/security/__init__.py	Sun Feb 22 11:21:01 2015 -0700
@@ -74,8 +74,7 @@
            * READ - gives permission to read, unconditionally
            * PUBREAD - gives permission to read, when published
         """
-        return (flaskg.storage.may(itemname, rights.READ, usernames=self.names)
-                or
+        return (flaskg.storage.may(itemname, rights.READ, usernames=self.names) or
                 flaskg.storage.may(itemname, rights.PUBREAD, usernames=self.names))
 
     def __getattr__(self, attr):
--- a/MoinMoin/security/textcha.py	Sat Feb 21 11:09:16 2015 -0700
+++ b/MoinMoin/security/textcha.py	Sun Feb 22 11:21:01 2015 -0700
@@ -24,9 +24,6 @@
 import re
 import random
 
-from MoinMoin import log
-logging = log.getLogger(__name__)
-
 from flask import current_app as app
 from flask import g as flaskg
 from flask import request
@@ -41,6 +38,10 @@
 
 from MoinMoin.i18n import _, L_, N_
 
+from MoinMoin import log
+logging = log.getLogger(__name__)
+
+
 SHA1_LEN = 40  # length of hexdigest
 TIMESTAMP_LEN = 10  # length of timestamp
 
--- a/MoinMoin/security/ticket.py	Sat Feb 21 11:09:16 2015 -0700
+++ b/MoinMoin/security/ticket.py	Sun Feb 22 11:21:01 2015 -0700
@@ -13,12 +13,12 @@
 import hmac
 import hashlib
 
+from flask import current_app as app
+from flask import g as flaskg
+
 from MoinMoin import log
 logging = log.getLogger(__name__)
 
-from flask import current_app as app
-from flask import g as flaskg
-
 
 def createTicket(tm=None, **kw):
     """ Create a ticket using a configured secret
--- a/MoinMoin/storage/backends/_tests/test_stores.py	Sat Feb 21 11:09:16 2015 -0700
+++ b/MoinMoin/storage/backends/_tests/test_stores.py	Sun Feb 22 11:21:01 2015 -0700
@@ -11,11 +11,16 @@
 
 from __future__ import absolute_import, division
 
+import os
+import tempfile
+
 from ..stores import MutableBackend
 from . import MutableBackendTestBase
 
 from MoinMoin.storage.stores.memory import BytesStore as MemoryBytesStore
 from MoinMoin.storage.stores.memory import FileStore as MemoryFileStore
+from MoinMoin.storage.stores.fs import BytesStore as FSBytesStore
+from MoinMoin.storage.stores.fs import FileStore as FSFileStore
 
 
 class TestMemoryBackend(MutableBackendTestBase):
@@ -26,12 +31,6 @@
         self.be.create()
         self.be.open()
 
-import os
-import tempfile
-
-from MoinMoin.storage.stores.fs import BytesStore as FSBytesStore
-from MoinMoin.storage.stores.fs import FileStore as FSFileStore
-
 
 class TestFSBackend(MutableBackendTestBase):
     def setup_method(self, method):
--- a/MoinMoin/storage/middleware/indexing.py	Sat Feb 21 11:09:16 2015 -0700
+++ b/MoinMoin/storage/middleware/indexing.py	Sun Feb 22 11:21:01 2015 -0700
@@ -55,8 +55,7 @@
 import shutil
 import datetime
 
-from MoinMoin import log
-logging = log.getLogger(__name__)
+from collections import Mapping
 
 from flask import request
 from flask import g as flaskg
@@ -80,6 +79,15 @@
 from MoinMoin.storage.error import NoSuchItemError, ItemAlreadyExistsError
 from MoinMoin.util.interwiki import split_fqname, CompositeName
 
+from MoinMoin.util.mime import Type, type_moin_document
+from MoinMoin.util.tree import moin_page
+from MoinMoin.converter import default_registry
+from MoinMoin.util.iri import Iri
+
+from MoinMoin import log
+logging = log.getLogger(__name__)
+
+
 WHOOSH_FILESTORAGE = 'FileStorage'
 INDEXES = [LATEST_REVS, ALL_REVS, ]
 
@@ -166,12 +174,6 @@
     return subscription_ids, subscription_patterns
 
 
-from MoinMoin.util.mime import Type, type_moin_document
-from MoinMoin.util.tree import moin_page
-from MoinMoin.converter import default_registry
-from MoinMoin.util.iri import Iri
-
-
 def convert_to_indexable(meta, data, item_name=None, is_new=False):
     """
     Convert revision data to a indexable content.
@@ -1226,9 +1228,6 @@
         return cmp(self.meta, other.meta)
 
 
-from collections import Mapping
-
-
 class Meta(Mapping):
     def __init__(self, revision, doc, meta=None):
         self.revision = revision
--- a/MoinMoin/storage/middleware/protecting.py	Sat Feb 21 11:09:16 2015 -0700
+++ b/MoinMoin/storage/middleware/protecting.py	Sun Feb 22 11:21:01 2015 -0700
@@ -16,9 +16,6 @@
 
 import time
 
-from MoinMoin import log
-logging = log.getLogger(__name__)
-
 from whoosh.util.cache import lru_cache
 
 from MoinMoin.constants.rights import (CREATE, READ, PUBREAD, WRITE, ADMIN, DESTROY, ACL_RIGHTS_CONTENTS)
@@ -28,6 +25,10 @@
 
 from MoinMoin.util.interwiki import split_fqname
 
+from MoinMoin import log
+logging = log.getLogger(__name__)
+
+
 # max sizes of some lru caches:
 LOOKUP_CACHE = 100  # ACL lookup for some itemname
 PARSE_CACHE = 100  # ACL string -> ACL object parsing
--- a/MoinMoin/user.py	Sat Feb 21 11:09:16 2015 -0700
+++ b/MoinMoin/user.py	Sun Feb 22 11:21:01 2015 -0700
@@ -32,9 +32,6 @@
 from flask import session, request, url_for, render_template
 from jinja2.runtime import Undefined
 
-from MoinMoin import log
-logging = log.getLogger(__name__)
-
 from MoinMoin import wikiutil
 from MoinMoin.constants.contenttypes import CONTENTTYPE_USER
 from MoinMoin.constants.namespaces import NAMESPACE_USERPROFILES
@@ -47,6 +44,9 @@
 from MoinMoin.util.subscriptions import get_matched_subscription_patterns
 from MoinMoin.storage.error import NoSuchItemError, ItemAlreadyExistsError, NoSuchRevisionError
 
+from MoinMoin import log
+logging = log.getLogger(__name__)
+
 
 def create_user(username, password, email, validate=True, is_encrypted=False, **meta):
     """
--- a/MoinMoin/util/clock.py	Sat Feb 21 11:09:16 2015 -0700
+++ b/MoinMoin/util/clock.py	Sun Feb 22 11:21:01 2015 -0700
@@ -10,11 +10,11 @@
 import time
 from functools import wraps, partial
 
+from flask import g as flaskg
+
 from MoinMoin import log
 logging = log.getLogger(__name__)
 
-from flask import g as flaskg
-
 
 class Clock(object):
     """
--- a/MoinMoin/util/subscriptions.py	Sat Feb 21 11:09:16 2015 -0700
+++ b/MoinMoin/util/subscriptions.py	Sun Feb 22 11:21:01 2015 -0700
@@ -16,9 +16,11 @@
 from MoinMoin.constants.keys import (DEFAULT_LOCALE, EMAIL, EMAIL_UNVALIDATED, ITEMID,
                                      LATEST_REVS, LOCALE, NAME, NAMERE, NAMEPREFIX,
                                      NAMESPACE, SUBSCRIPTION_IDS, SUBSCRIPTION_PATTERNS, TAGS)
+
+from MoinMoin.util.interwiki import CompositeName
+
 from MoinMoin import log
 logging = log.getLogger(__name__)
-from MoinMoin.util.interwiki import CompositeName
 
 
 Subscriber = namedtuple('Subscriber', [ITEMID, NAME, EMAIL, LOCALE])
--- a/MoinMoin/wikiutil.py	Sat Feb 21 11:09:16 2015 -0700
+++ b/MoinMoin/wikiutil.py	Sun Feb 22 11:21:01 2015 -0700
@@ -15,13 +15,12 @@
 
 import os
 
-from MoinMoin import log
-logging = log.getLogger(__name__)
-
 from flask import current_app as app
 from flask import g as flaskg
 from flask import request
 
+import werkzeug
+
 from MoinMoin.constants.contenttypes import CHARSET
 from MoinMoin.constants.keys import CURRENT
 from MoinMoin.constants.misc import URI_SCHEMES, CLEAN_INPUT_TRANSLATION_MAP, ITEM_INVALID_CHARS_REGEX
@@ -31,7 +30,9 @@
 from MoinMoin.util.mimetype import MimeType
 from MoinMoin.storage.error import NoSuchItemError, NoSuchRevisionError
 
-import werkzeug
+from MoinMoin import log
+logging = log.getLogger(__name__)
+
 
 # constants for page names
 PARENT_PREFIX = "../"
--- a/setup.cfg	Sat Feb 21 11:09:16 2015 -0700
+++ b/setup.cfg	Sun Feb 22 11:21:01 2015 -0700
@@ -48,7 +48,9 @@
 pep8ignore =
  *.py E124  # closing bracket does not match visual indentation (behaves strange!?)
  *.py E125  # continuation line does not distinguish itself from next logical line (difficult to avoid!)
+ *.py E402  # module level import not at top of file
  *.py E501  # maximum line length (see also pep8maxlinelength)
+ */util/*.py E731  # do not assign a lambda expression, use a def
  MoinMoin/config/default.py E501  # maximum line length (long lines expected there)
  MoinMoin/config/default.py E122  # continuation line missing indentation or outdented
  MoinMoin/constants/chartypes.py E501  # auto-generated, long lines