diff --git a/conftest.py b/conftest.py
--- a/conftest.py
+++ b/conftest.py
@@ -1,7 +1,9 @@
+import os
+import sys
+
import mock
-import os
import pytest
-import sys
+
here = os.path.dirname(__file__)
diff --git a/docs/conf.py b/docs/conf.py
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -11,8 +11,11 @@
# All configuration values have a default; values that are commented out
# serve to show the default.
+import os
import sys
-import os
+
+from kallithea import __version__
+
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
@@ -53,7 +56,6 @@ copyright = u'2010-2019 by various autho
# The short X.Y version.
root = os.path.dirname(os.path.dirname(__file__))
sys.path.append(root)
-from kallithea import __version__
version = __version__
# The full version, including alpha/beta/rc tags.
release = __version__
diff --git a/kallithea/__init__.py b/kallithea/__init__.py
--- a/kallithea/__init__.py
+++ b/kallithea/__init__.py
@@ -27,8 +27,9 @@ Original author and date, and relevant c
:license: GPLv3, see LICENSE.md for more details.
"""
+import platform
import sys
-import platform
+
VERSION = (0, 4, 99)
BACKENDS = {
diff --git a/kallithea/alembic/versions/a020f7044fd6_rename_hooks.py b/kallithea/alembic/versions/a020f7044fd6_rename_hooks.py
--- a/kallithea/alembic/versions/a020f7044fd6_rename_hooks.py
+++ b/kallithea/alembic/versions/a020f7044fd6_rename_hooks.py
@@ -27,8 +27,10 @@ branch_labels = None
depends_on = None
from alembic import op
+from sqlalchemy import MetaData, Table
+
from kallithea.model.db import Ui
-from sqlalchemy import Table, MetaData
+
meta = MetaData()
diff --git a/kallithea/alembic/versions/ad357ccd9521_drop_locking.py b/kallithea/alembic/versions/ad357ccd9521_drop_locking.py
--- a/kallithea/alembic/versions/ad357ccd9521_drop_locking.py
+++ b/kallithea/alembic/versions/ad357ccd9521_drop_locking.py
@@ -26,10 +26,12 @@ down_revision = 'a020f7044fd6'
branch_labels = None
depends_on = None
+import sqlalchemy as sa
from alembic import op
-import sqlalchemy as sa
+from sqlalchemy import MetaData, Table
+
from kallithea.model.db import Ui
-from sqlalchemy import Table, MetaData
+
meta = MetaData()
diff --git a/kallithea/alembic/versions/b74907136bc1_create_table_for_ssh_keys.py b/kallithea/alembic/versions/b74907136bc1_create_table_for_ssh_keys.py
--- a/kallithea/alembic/versions/b74907136bc1_create_table_for_ssh_keys.py
+++ b/kallithea/alembic/versions/b74907136bc1_create_table_for_ssh_keys.py
@@ -26,8 +26,8 @@ down_revision = 'ad357ccd9521'
branch_labels = None
depends_on = None
+import sqlalchemy as sa
from alembic import op
-import sqlalchemy as sa
from kallithea.model import db
diff --git a/kallithea/bin/base.py b/kallithea/bin/base.py
--- a/kallithea/bin/base.py
+++ b/kallithea/bin/base.py
@@ -26,13 +26,14 @@ Original author and date, and relevant c
"""
import os
-import sys
+import pprint
import random
+import sys
import urllib2
-import pprint
from kallithea.lib.compat import json
+
CONFIG_NAME = '.config/kallithea'
FORMAT_PRETTY = 'pretty'
FORMAT_JSON = 'json'
diff --git a/kallithea/bin/kallithea_api.py b/kallithea/bin/kallithea_api.py
--- a/kallithea/bin/kallithea_api.py
+++ b/kallithea/bin/kallithea_api.py
@@ -25,10 +25,10 @@ Original author and date, and relevant c
:license: GPLv3, see LICENSE.md for more details.
"""
+import argparse
import sys
-import argparse
-from kallithea.bin.base import json, api_call, RcConf, FORMAT_JSON, FORMAT_PRETTY
+from kallithea.bin.base import FORMAT_JSON, FORMAT_PRETTY, RcConf, api_call, json
def argparser(argv):
diff --git a/kallithea/bin/kallithea_backup.py b/kallithea/bin/kallithea_backup.py
--- a/kallithea/bin/kallithea_backup.py
+++ b/kallithea/bin/kallithea_backup.py
@@ -26,14 +26,15 @@ Original author and date, and relevant c
:license: GPLv3, see LICENSE.md for more details.
"""
+import datetime
+import logging
import os
+import subprocess
import sys
-import logging
import tarfile
-import datetime
-import subprocess
import tempfile
+
logging.basicConfig(level=logging.DEBUG,
format="%(asctime)s %(levelname)-5.5s %(message)s")
diff --git a/kallithea/bin/kallithea_cli.py b/kallithea/bin/kallithea_cli.py
--- a/kallithea/bin/kallithea_cli.py
+++ b/kallithea/bin/kallithea_cli.py
@@ -12,9 +12,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-# 'cli' is the main entry point for 'kallithea-cli', specified in setup.py as entry_points console_scripts
-from kallithea.bin.kallithea_cli_base import cli
-
# import commands (they will add themselves to the 'cli' object)
import kallithea.bin.kallithea_cli_celery
import kallithea.bin.kallithea_cli_config
@@ -26,3 +23,5 @@ import kallithea.bin.kallithea_cli_index
import kallithea.bin.kallithea_cli_ishell
import kallithea.bin.kallithea_cli_repo
import kallithea.bin.kallithea_cli_ssh
+# 'cli' is the main entry point for 'kallithea-cli', specified in setup.py as entry_points console_scripts
+from kallithea.bin.kallithea_cli_base import cli
diff --git a/kallithea/bin/kallithea_cli_base.py b/kallithea/bin/kallithea_cli_base.py
--- a/kallithea/bin/kallithea_cli_base.py
+++ b/kallithea/bin/kallithea_cli_base.py
@@ -12,16 +12,17 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-import click
import cStringIO
import functools
+import logging.config
import os
import re
import sys
+import click
+import paste.deploy
+
import kallithea
-import logging.config
-import paste.deploy
# kallithea_cli is usually invoked through the 'kallithea-cli' wrapper script
diff --git a/kallithea/bin/kallithea_cli_celery.py b/kallithea/bin/kallithea_cli_celery.py
--- a/kallithea/bin/kallithea_cli_celery.py
+++ b/kallithea/bin/kallithea_cli_celery.py
@@ -13,9 +13,10 @@
# along with this program. If not, see .
import click
+
+import kallithea
import kallithea.bin.kallithea_cli_base as cli_base
-import kallithea
@cli_base.register_command(config_file_initialize_app=True)
@click.argument('celery_args', nargs=-1)
diff --git a/kallithea/bin/kallithea_cli_config.py b/kallithea/bin/kallithea_cli_config.py
--- a/kallithea/bin/kallithea_cli_config.py
+++ b/kallithea/bin/kallithea_cli_config.py
@@ -12,19 +12,19 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-import click
-import kallithea.bin.kallithea_cli_base as cli_base
-
import os
import sys
import uuid
from collections import defaultdict
+import click
import mako.exceptions
+import kallithea.bin.kallithea_cli_base as cli_base
import kallithea.lib.locale
from kallithea.lib import inifile
+
def show_defaults(ctx, param, value):
# Following construct is taken from the Click documentation:
# https://click.palletsprojects.com/en/7.x/options/#callbacks-and-eager-options
diff --git a/kallithea/bin/kallithea_cli_db.py b/kallithea/bin/kallithea_cli_db.py
--- a/kallithea/bin/kallithea_cli_db.py
+++ b/kallithea/bin/kallithea_cli_db.py
@@ -12,12 +12,13 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
import click
-import kallithea.bin.kallithea_cli_base as cli_base
import kallithea
+import kallithea.bin.kallithea_cli_base as cli_base
from kallithea.lib.db_manage import DbManage
from kallithea.model.meta import Session
+
@cli_base.register_command(config_file=True)
@click.option('--user', help='Username of administrator account.')
@click.option('--password', help='Password for administrator account.')
diff --git a/kallithea/bin/kallithea_cli_extensions.py b/kallithea/bin/kallithea_cli_extensions.py
--- a/kallithea/bin/kallithea_cli_extensions.py
+++ b/kallithea/bin/kallithea_cli_extensions.py
@@ -19,15 +19,16 @@ Original author and date, and relevant c
:copyright: (c) 2013 RhodeCode GmbH, and others.
:license: GPLv3, see LICENSE.md for more details.
"""
+import os
+
import click
-import kallithea.bin.kallithea_cli_base as cli_base
-
-import os
import pkg_resources
import kallithea
+import kallithea.bin.kallithea_cli_base as cli_base
from kallithea.lib.utils2 import ask_ok
+
@cli_base.register_command(config_file=True)
def extensions_create():
"""Write template file for extending Kallithea in Python.
diff --git a/kallithea/bin/kallithea_cli_front_end.py b/kallithea/bin/kallithea_cli_front_end.py
--- a/kallithea/bin/kallithea_cli_front_end.py
+++ b/kallithea/bin/kallithea_cli_front_end.py
@@ -12,15 +12,16 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-import click
-import kallithea.bin.kallithea_cli_base as cli_base
-
+import json
import os
import shutil
import subprocess
-import json
+
+import click
import kallithea
+import kallithea.bin.kallithea_cli_base as cli_base
+
@cli_base.register_command()
@click.option('--install-deps/--no-install-deps', default=True,
diff --git a/kallithea/bin/kallithea_cli_iis.py b/kallithea/bin/kallithea_cli_iis.py
--- a/kallithea/bin/kallithea_cli_iis.py
+++ b/kallithea/bin/kallithea_cli_iis.py
@@ -11,12 +11,14 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
+import os
+import sys
+
import click
+
import kallithea
import kallithea.bin.kallithea_cli_base as cli_base
-import os
-import sys
dispath_py_template = '''\
# Created by Kallithea 'kallithea-cli iis-install'
diff --git a/kallithea/bin/kallithea_cli_index.py b/kallithea/bin/kallithea_cli_index.py
--- a/kallithea/bin/kallithea_cli_index.py
+++ b/kallithea/bin/kallithea_cli_index.py
@@ -19,18 +19,19 @@ Original author and date, and relevant c
:copyright: (c) 2013 RhodeCode GmbH, and others.
:license: GPLv3, see LICENSE.md for more details.
"""
-import click
-import kallithea.bin.kallithea_cli_base as cli_base
-
import os
import sys
+import click
+
import kallithea
+import kallithea.bin.kallithea_cli_base as cli_base
from kallithea.lib.indexers.daemon import WhooshIndexingDaemon
-from kallithea.lib.pidlock import LockHeld, DaemonLock
+from kallithea.lib.pidlock import DaemonLock, LockHeld
from kallithea.lib.utils import load_rcextensions
from kallithea.model.repo import RepoModel
+
@cli_base.register_command(config_file_initialize_app=True)
@click.option('--repo-location', help='Base path of repositories to index. Default: all')
@click.option('--index-only', help='Comma-separated list of repositories to build index on. Default: all')
diff --git a/kallithea/bin/kallithea_cli_ishell.py b/kallithea/bin/kallithea_cli_ishell.py
--- a/kallithea/bin/kallithea_cli_ishell.py
+++ b/kallithea/bin/kallithea_cli_ishell.py
@@ -19,14 +19,14 @@ Original author and date, and relevant c
:copyright: (c) 2013 RhodeCode GmbH, and others.
:license: GPLv3, see LICENSE.md for more details.
"""
-import click
-import kallithea.bin.kallithea_cli_base as cli_base
-
import sys
-# make following imports directly available inside the ishell
+import click
+
+import kallithea.bin.kallithea_cli_base as cli_base
from kallithea.model.db import *
+
@cli_base.register_command(config_file_initialize_app=True)
def ishell():
"""Interactive shell for Kallithea."""
diff --git a/kallithea/bin/kallithea_cli_repo.py b/kallithea/bin/kallithea_cli_repo.py
--- a/kallithea/bin/kallithea_cli_repo.py
+++ b/kallithea/bin/kallithea_cli_repo.py
@@ -19,20 +19,21 @@ Original author and date, and relevant c
:copyright: (c) 2013 RhodeCode GmbH, and others.
:license: GPLv3, see LICENSE.md for more details.
"""
-import click
-import kallithea.bin.kallithea_cli_base as cli_base
-
import datetime
import os
import re
import shutil
-from kallithea.lib.utils import repo2db_mapper, REMOVED_REPO_PAT
-from kallithea.lib.utils2 import safe_unicode, safe_str, ask_ok
+import click
+
+import kallithea.bin.kallithea_cli_base as cli_base
+from kallithea.lib.utils import REMOVED_REPO_PAT, repo2db_mapper
+from kallithea.lib.utils2 import ask_ok, safe_str, safe_unicode
from kallithea.model.db import Repository, Ui
from kallithea.model.meta import Session
from kallithea.model.scm import ScmModel
+
@cli_base.register_command(config_file_initialize_app=True)
@click.option('--remove-missing', is_flag=True,
help='Remove missing repositories from the Kallithea database.')
diff --git a/kallithea/bin/kallithea_cli_ssh.py b/kallithea/bin/kallithea_cli_ssh.py
--- a/kallithea/bin/kallithea_cli_ssh.py
+++ b/kallithea/bin/kallithea_cli_ssh.py
@@ -12,21 +12,22 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-import click
-import kallithea.bin.kallithea_cli_base as cli_base
-
+import logging
import os
+import re
+import shlex
import sys
-import re
-import logging
-import shlex
+
+import click
import kallithea
+import kallithea.bin.kallithea_cli_base as cli_base
from kallithea.lib.utils2 import str2bool
from kallithea.lib.vcs.backends.git.ssh import GitSshHandler
from kallithea.lib.vcs.backends.hg.ssh import MercurialSshHandler
from kallithea.model.ssh_key import SshKeyModel
+
log = logging.getLogger(__name__)
diff --git a/kallithea/bin/kallithea_gist.py b/kallithea/bin/kallithea_gist.py
--- a/kallithea/bin/kallithea_gist.py
+++ b/kallithea/bin/kallithea_gist.py
@@ -25,13 +25,13 @@ Original author and date, and relevant c
:license: GPLv3, see LICENSE.md for more details.
"""
-import os
-import sys
-import stat
import argparse
import fileinput
+import os
+import stat
+import sys
-from kallithea.bin.base import json, api_call, RcConf, FORMAT_JSON, FORMAT_PRETTY
+from kallithea.bin.base import FORMAT_JSON, FORMAT_PRETTY, RcConf, api_call, json
def argparser(argv):
diff --git a/kallithea/bin/ldap_sync.py b/kallithea/bin/ldap_sync.py
--- a/kallithea/bin/ldap_sync.py
+++ b/kallithea/bin/ldap_sync.py
@@ -25,13 +25,14 @@ Original author and date, and relevant c
:license: GPLv3, see LICENSE.md for more details.
"""
-import ldap
import urllib2
import uuid
+from ConfigParser import ConfigParser
+
+import ldap
from kallithea.lib.compat import json
-from ConfigParser import ConfigParser
config = ConfigParser()
config.read('ldap_sync.conf')
diff --git a/kallithea/config/app_cfg.py b/kallithea/config/app_cfg.py
--- a/kallithea/config/app_cfg.py
+++ b/kallithea/config/app_cfg.py
@@ -17,32 +17,33 @@ Global configuration file for TurboGears
This file complements the .ini file.
"""
+import logging
+import os
import platform
-import os, sys, logging
+import sys
+import alembic.config
+import formencode
+import mercurial
import tg
+from alembic.migration import MigrationContext
+from alembic.script.base import ScriptDirectory
+from sqlalchemy import create_engine
from tg import hooks
from tg.configuration import AppConfig
from tg.support.converters import asbool
-import alembic.config
-from alembic.script.base import ScriptDirectory
-from alembic.migration import MigrationContext
-from sqlalchemy import create_engine
-import mercurial
import kallithea.lib.locale
+import kallithea.model.base
+from kallithea.lib.auth import set_available_permissions
+from kallithea.lib.middleware.https_fixup import HttpsFixup
from kallithea.lib.middleware.permanent_repo_url import PermanentRepoUrl
-from kallithea.lib.middleware.https_fixup import HttpsFixup
from kallithea.lib.middleware.simplegit import SimpleGit
from kallithea.lib.middleware.simplehg import SimpleHg
-from kallithea.lib.auth import set_available_permissions
-from kallithea.lib.utils import load_rcextensions, make_ui, set_app_settings, set_vcs_config, \
- set_indexer_config, check_git_version, repo2db_mapper
+from kallithea.lib.utils import check_git_version, load_rcextensions, make_ui, repo2db_mapper, set_app_settings, set_indexer_config, set_vcs_config
from kallithea.lib.utils2 import str2bool
-import kallithea.model.base
from kallithea.model.scm import ScmModel
-import formencode
log = logging.getLogger(__name__)
diff --git a/kallithea/config/environment.py b/kallithea/config/environment.py
--- a/kallithea/config/environment.py
+++ b/kallithea/config/environment.py
@@ -15,6 +15,7 @@
from kallithea.config.app_cfg import base_config
+
__all__ = ['load_environment']
# Use base_config to setup the environment loader function
diff --git a/kallithea/config/middleware.py b/kallithea/config/middleware.py
--- a/kallithea/config/middleware.py
+++ b/kallithea/config/middleware.py
@@ -14,9 +14,11 @@
"""WSGI middleware initialization for the Kallithea application."""
import logging.config
+
from kallithea.config.app_cfg import base_config
from kallithea.config.environment import load_environment
+
__all__ = ['make_app']
# Use base_config to setup the necessary PasteDeploy application factory.
diff --git a/kallithea/config/post_receive_tmpl.py b/kallithea/config/post_receive_tmpl.py
--- a/kallithea/config/post_receive_tmpl.py
+++ b/kallithea/config/post_receive_tmpl.py
@@ -11,6 +11,9 @@ hook will use.
import os
import sys
+import kallithea.lib.hooks
+
+
# Set output mode on windows to binary for stderr.
# This prevents python (or the windows console) from replacing \n with \r\n.
# Git doesn't display remote output lines that contain \r,
@@ -22,7 +25,6 @@ if sys.platform == "win32":
KALLITHEA_HOOK_VER = '_TMPL_'
os.environ['KALLITHEA_HOOK_VER'] = KALLITHEA_HOOK_VER
-import kallithea.lib.hooks
def main():
diff --git a/kallithea/config/pre_receive_tmpl.py b/kallithea/config/pre_receive_tmpl.py
--- a/kallithea/config/pre_receive_tmpl.py
+++ b/kallithea/config/pre_receive_tmpl.py
@@ -11,6 +11,9 @@ hook will use.
import os
import sys
+import kallithea.lib.hooks
+
+
# Set output mode on windows to binary for stderr.
# This prevents python (or the windows console) from replacing \n with \r\n.
# Git doesn't display remote output lines that contain \r,
@@ -22,7 +25,6 @@ if sys.platform == "win32":
KALLITHEA_HOOK_VER = '_TMPL_'
os.environ['KALLITHEA_HOOK_VER'] = KALLITHEA_HOOK_VER
-import kallithea.lib.hooks
def main():
diff --git a/kallithea/config/routing.py b/kallithea/config/routing.py
--- a/kallithea/config/routing.py
+++ b/kallithea/config/routing.py
@@ -19,8 +19,9 @@ may take precedent over the more generic
refer to the routes manual at http://routes.groovie.org/docs/
"""
+from routes import Mapper
from tg import request
-from routes import Mapper
+
# prefix for non repository related links needs to be prefixed with `/`
ADMIN_PREFIX = '/_admin'
diff --git a/kallithea/controllers/admin/admin.py b/kallithea/controllers/admin/admin.py
--- a/kallithea/controllers/admin/admin.py
+++ b/kallithea/controllers/admin/admin.py
@@ -28,20 +28,21 @@ Original author and date, and relevant c
import logging
-from tg import request, tmpl_context as c
from sqlalchemy.orm import joinedload
+from sqlalchemy.sql.expression import and_, func, or_
+from tg import request
+from tg import tmpl_context as c
+from whoosh import query
+from whoosh.qparser.dateparse import DateParserPlugin
from whoosh.qparser.default import QueryParser
-from whoosh.qparser.dateparse import DateParserPlugin
-from whoosh import query
-from sqlalchemy.sql.expression import or_, and_, func
from kallithea.config.routing import url
-from kallithea.model.db import UserLog
-from kallithea.lib.auth import LoginRequired, HasPermissionAnyDecorator
+from kallithea.lib.auth import HasPermissionAnyDecorator, LoginRequired
from kallithea.lib.base import BaseController, render
-from kallithea.lib.utils2 import safe_int, remove_prefix, remove_suffix
from kallithea.lib.indexers import JOURNAL_SCHEMA
from kallithea.lib.page import Page
+from kallithea.lib.utils2 import remove_prefix, remove_suffix, safe_int
+from kallithea.model.db import UserLog
log = logging.getLogger(__name__)
diff --git a/kallithea/controllers/admin/auth_settings.py b/kallithea/controllers/admin/auth_settings.py
--- a/kallithea/controllers/admin/auth_settings.py
+++ b/kallithea/controllers/admin/auth_settings.py
@@ -24,23 +24,25 @@ Original author and date, and relevant c
"""
import logging
-import formencode.htmlfill
import traceback
-from tg import request, tmpl_context as c
+import formencode.htmlfill
+from tg import request
+from tg import tmpl_context as c
from tg.i18n import ugettext as _
from webob.exc import HTTPFound
from kallithea.config.routing import url
+from kallithea.lib import auth_modules
from kallithea.lib import helpers as h
-from kallithea.lib.compat import formatted_json
+from kallithea.lib.auth import HasPermissionAnyDecorator, LoginRequired
from kallithea.lib.base import BaseController, render
-from kallithea.lib.auth import LoginRequired, HasPermissionAnyDecorator
-from kallithea.lib import auth_modules
+from kallithea.lib.compat import formatted_json
+from kallithea.model.db import Setting
from kallithea.model.forms import AuthSettingsForm
-from kallithea.model.db import Setting
from kallithea.model.meta import Session
+
log = logging.getLogger(__name__)
diff --git a/kallithea/controllers/admin/defaults.py b/kallithea/controllers/admin/defaults.py
--- a/kallithea/controllers/admin/defaults.py
+++ b/kallithea/controllers/admin/defaults.py
@@ -27,20 +27,22 @@ Original author and date, and relevant c
import logging
import traceback
+
import formencode
from formencode import htmlfill
-
-from tg import request, tmpl_context as c
+from tg import request
+from tg import tmpl_context as c
from tg.i18n import ugettext as _
from webob.exc import HTTPFound
from kallithea.config.routing import url
from kallithea.lib import helpers as h
-from kallithea.lib.auth import LoginRequired, HasPermissionAnyDecorator
+from kallithea.lib.auth import HasPermissionAnyDecorator, LoginRequired
from kallithea.lib.base import BaseController, render
+from kallithea.model.db import Setting
from kallithea.model.forms import DefaultsForm
from kallithea.model.meta import Session
-from kallithea.model.db import Setting
+
log = logging.getLogger(__name__)
diff --git a/kallithea/controllers/admin/gists.py b/kallithea/controllers/admin/gists.py
--- a/kallithea/controllers/admin/gists.py
+++ b/kallithea/controllers/admin/gists.py
@@ -25,27 +25,29 @@ Original author and date, and relevant c
:license: GPLv3, see LICENSE.md for more details.
"""
+import logging
import time
-import logging
import traceback
+
import formencode.htmlfill
-
-from tg import request, response, tmpl_context as c
+from sqlalchemy.sql.expression import or_
+from tg import request, response
+from tg import tmpl_context as c
from tg.i18n import ugettext as _
-from webob.exc import HTTPFound, HTTPNotFound, HTTPForbidden
+from webob.exc import HTTPForbidden, HTTPFound, HTTPNotFound
from kallithea.config.routing import url
+from kallithea.lib import helpers as h
+from kallithea.lib.auth import LoginRequired
+from kallithea.lib.base import BaseController, jsonify, render
+from kallithea.lib.page import Page
+from kallithea.lib.utils2 import safe_int, safe_unicode, time_to_datetime
+from kallithea.lib.vcs.exceptions import NodeNotChangedError, VCSError
+from kallithea.model.db import Gist, User
from kallithea.model.forms import GistForm
from kallithea.model.gist import GistModel
from kallithea.model.meta import Session
-from kallithea.model.db import Gist, User
-from kallithea.lib import helpers as h
-from kallithea.lib.base import BaseController, render, jsonify
-from kallithea.lib.auth import LoginRequired
-from kallithea.lib.utils2 import safe_int, safe_unicode, time_to_datetime
-from kallithea.lib.page import Page
-from sqlalchemy.sql.expression import or_
-from kallithea.lib.vcs.exceptions import VCSError, NodeNotChangedError
+
log = logging.getLogger(__name__)
diff --git a/kallithea/controllers/admin/my_account.py b/kallithea/controllers/admin/my_account.py
--- a/kallithea/controllers/admin/my_account.py
+++ b/kallithea/controllers/admin/my_account.py
@@ -27,27 +27,29 @@ Original author and date, and relevant c
import logging
import traceback
+
import formencode
-
+from formencode import htmlfill
from sqlalchemy import func
-from formencode import htmlfill
-from tg import request, tmpl_context as c
+from tg import request
+from tg import tmpl_context as c
from tg.i18n import ugettext as _
from webob.exc import HTTPFound
from kallithea.config.routing import url
+from kallithea.lib import auth_modules
from kallithea.lib import helpers as h
-from kallithea.lib import auth_modules
-from kallithea.lib.auth import LoginRequired, AuthUser
-from kallithea.lib.base import BaseController, render, IfSshEnabled
+from kallithea.lib.auth import AuthUser, LoginRequired
+from kallithea.lib.base import BaseController, IfSshEnabled, render
from kallithea.lib.utils2 import generate_api_key, safe_int
-from kallithea.model.db import Repository, UserEmailMap, User, UserFollowing
-from kallithea.model.forms import UserForm, PasswordChangeForm
-from kallithea.model.user import UserModel
+from kallithea.model.api_key import ApiKeyModel
+from kallithea.model.db import Repository, User, UserEmailMap, UserFollowing
+from kallithea.model.forms import PasswordChangeForm, UserForm
+from kallithea.model.meta import Session
from kallithea.model.repo import RepoModel
-from kallithea.model.api_key import ApiKeyModel
from kallithea.model.ssh_key import SshKeyModel, SshKeyModelException
-from kallithea.model.meta import Session
+from kallithea.model.user import UserModel
+
log = logging.getLogger(__name__)
diff --git a/kallithea/controllers/admin/permissions.py b/kallithea/controllers/admin/permissions.py
--- a/kallithea/controllers/admin/permissions.py
+++ b/kallithea/controllers/admin/permissions.py
@@ -28,21 +28,23 @@ Original author and date, and relevant c
import logging
import traceback
+
import formencode
from formencode import htmlfill
-
-from tg import request, tmpl_context as c
+from tg import request
+from tg import tmpl_context as c
from tg.i18n import ugettext as _
from webob.exc import HTTPFound
from kallithea.config.routing import url
from kallithea.lib import helpers as h
-from kallithea.lib.auth import LoginRequired, HasPermissionAnyDecorator, AuthUser
+from kallithea.lib.auth import AuthUser, HasPermissionAnyDecorator, LoginRequired
from kallithea.lib.base import BaseController, render
+from kallithea.model.db import User, UserIpMap
from kallithea.model.forms import DefaultPermissionsForm
+from kallithea.model.meta import Session
from kallithea.model.permission import PermissionModel
-from kallithea.model.db import User, UserIpMap
-from kallithea.model.meta import Session
+
log = logging.getLogger(__name__)
diff --git a/kallithea/controllers/admin/repo_groups.py b/kallithea/controllers/admin/repo_groups.py
--- a/kallithea/controllers/admin/repo_groups.py
+++ b/kallithea/controllers/admin/repo_groups.py
@@ -25,32 +25,31 @@ Original author and date, and relevant c
:license: GPLv3, see LICENSE.md for more details.
"""
+import itertools
import logging
import traceback
+
import formencode
-import itertools
-
from formencode import htmlfill
-
-from tg import request, tmpl_context as c, app_globals
-from tg.i18n import ugettext as _, ungettext
-from webob.exc import HTTPFound, HTTPForbidden, HTTPNotFound, HTTPInternalServerError
+from sqlalchemy.sql.expression import func
+from tg import app_globals, request
+from tg import tmpl_context as c
+from tg.i18n import ugettext as _
+from tg.i18n import ungettext
+from webob.exc import HTTPForbidden, HTTPFound, HTTPInternalServerError, HTTPNotFound
import kallithea
from kallithea.config.routing import url
from kallithea.lib import helpers as h
-from kallithea.lib.auth import LoginRequired, \
- HasRepoGroupPermissionLevelDecorator, HasRepoGroupPermissionLevel, \
- HasPermissionAny
+from kallithea.lib.auth import HasPermissionAny, HasRepoGroupPermissionLevel, HasRepoGroupPermissionLevelDecorator, LoginRequired
from kallithea.lib.base import BaseController, render
+from kallithea.lib.utils2 import safe_int
from kallithea.model.db import RepoGroup, Repository
-from kallithea.model.scm import RepoGroupList, AvailableRepoGroupChoices
-from kallithea.model.repo_group import RepoGroupModel
from kallithea.model.forms import RepoGroupForm, RepoGroupPermsForm
from kallithea.model.meta import Session
from kallithea.model.repo import RepoModel
-from kallithea.lib.utils2 import safe_int
-from sqlalchemy.sql.expression import func
+from kallithea.model.repo_group import RepoGroupModel
+from kallithea.model.scm import AvailableRepoGroupChoices, RepoGroupList
log = logging.getLogger(__name__)
diff --git a/kallithea/controllers/admin/repos.py b/kallithea/controllers/admin/repos.py
--- a/kallithea/controllers/admin/repos.py
+++ b/kallithea/controllers/admin/repos.py
@@ -27,28 +27,29 @@ Original author and date, and relevant c
import logging
import traceback
+
import formencode
from formencode import htmlfill
-from tg import request, tmpl_context as c
+from sqlalchemy.sql.expression import func
+from tg import request
+from tg import tmpl_context as c
from tg.i18n import ugettext as _
-from sqlalchemy.sql.expression import func
-from webob.exc import HTTPFound, HTTPInternalServerError, HTTPForbidden, HTTPNotFound
+from webob.exc import HTTPForbidden, HTTPFound, HTTPInternalServerError, HTTPNotFound
from kallithea.config.routing import url
from kallithea.lib import helpers as h
-from kallithea.lib.auth import LoginRequired, \
- HasRepoPermissionLevelDecorator, NotAnonymous, HasPermissionAny
-from kallithea.lib.base import BaseRepoController, render, jsonify
+from kallithea.lib.auth import HasPermissionAny, HasRepoPermissionLevelDecorator, LoginRequired, NotAnonymous
+from kallithea.lib.base import BaseRepoController, jsonify, render
+from kallithea.lib.exceptions import AttachedForksError
from kallithea.lib.utils import action_logger
+from kallithea.lib.utils2 import safe_int
from kallithea.lib.vcs import RepositoryError
+from kallithea.model.db import RepoGroup, Repository, RepositoryField, Setting, User, UserFollowing
+from kallithea.model.forms import RepoFieldForm, RepoForm, RepoPermsForm
from kallithea.model.meta import Session
-from kallithea.model.db import User, Repository, UserFollowing, RepoGroup, \
- Setting, RepositoryField
-from kallithea.model.forms import RepoForm, RepoFieldForm, RepoPermsForm
-from kallithea.model.scm import ScmModel, AvailableRepoGroupChoices, RepoList
from kallithea.model.repo import RepoModel
-from kallithea.lib.exceptions import AttachedForksError
-from kallithea.lib.utils2 import safe_int
+from kallithea.model.scm import AvailableRepoGroupChoices, RepoList, ScmModel
+
log = logging.getLogger(__name__)
diff --git a/kallithea/controllers/admin/settings.py b/kallithea/controllers/admin/settings.py
--- a/kallithea/controllers/admin/settings.py
+++ b/kallithea/controllers/admin/settings.py
@@ -27,28 +27,30 @@ Original author and date, and relevant c
import logging
import traceback
+
import formencode
-
from formencode import htmlfill
-from tg import request, tmpl_context as c, config
+from tg import config, request
+from tg import tmpl_context as c
from tg.i18n import ugettext as _
from webob.exc import HTTPFound
from kallithea.config.routing import url
from kallithea.lib import helpers as h
-from kallithea.lib.auth import LoginRequired, HasPermissionAnyDecorator
+from kallithea.lib.auth import HasPermissionAnyDecorator, LoginRequired
from kallithea.lib.base import BaseController, render
from kallithea.lib.celerylib import tasks
from kallithea.lib.exceptions import HgsubversionImportError
from kallithea.lib.utils import repo2db_mapper, set_app_settings
+from kallithea.lib.utils2 import safe_unicode, str2bool
from kallithea.lib.vcs import VCSError
-from kallithea.model.db import Ui, Repository, Setting
-from kallithea.model.forms import ApplicationSettingsForm, \
- ApplicationUiSettingsForm, ApplicationVisualisationForm
+from kallithea.model.db import Repository, Setting, Ui
+from kallithea.model.forms import ApplicationSettingsForm, ApplicationUiSettingsForm, ApplicationVisualisationForm
+from kallithea.model.meta import Session
+from kallithea.model.notification import EmailNotificationModel
from kallithea.model.scm import ScmModel
-from kallithea.model.notification import EmailNotificationModel
-from kallithea.model.meta import Session
-from kallithea.lib.utils2 import str2bool, safe_unicode
+
+
log = logging.getLogger(__name__)
diff --git a/kallithea/controllers/admin/user_groups.py b/kallithea/controllers/admin/user_groups.py
--- a/kallithea/controllers/admin/user_groups.py
+++ b/kallithea/controllers/admin/user_groups.py
@@ -27,35 +27,31 @@ Original author and date, and relevant c
import logging
import traceback
+
import formencode
-
from formencode import htmlfill
-from tg import request, tmpl_context as c, config, app_globals
-from tg.i18n import ugettext as _
-from webob.exc import HTTPFound
-
from sqlalchemy.orm import joinedload
from sqlalchemy.sql.expression import func
-from webob.exc import HTTPInternalServerError
+from tg import app_globals, config, request
+from tg import tmpl_context as c
+from tg.i18n import ugettext as _
+from webob.exc import HTTPFound, HTTPInternalServerError
import kallithea
from kallithea.config.routing import url
from kallithea.lib import helpers as h
-from kallithea.lib.exceptions import UserGroupsAssignedException, \
- RepoGroupAssignmentError
-from kallithea.lib.utils2 import safe_unicode, safe_int
-from kallithea.lib.auth import LoginRequired, \
- HasUserGroupPermissionLevelDecorator, HasPermissionAnyDecorator
+from kallithea.lib.auth import HasPermissionAnyDecorator, HasUserGroupPermissionLevelDecorator, LoginRequired
from kallithea.lib.base import BaseController, render
+from kallithea.lib.exceptions import RepoGroupAssignmentError, UserGroupsAssignedException
+from kallithea.lib.utils import action_logger
+from kallithea.lib.utils2 import safe_int, safe_unicode
+from kallithea.model.db import User, UserGroup, UserGroupRepoGroupToPerm, UserGroupRepoToPerm, UserGroupToPerm
+from kallithea.model.forms import CustomDefaultPermissionsForm, UserGroupForm, UserGroupPermsForm
+from kallithea.model.meta import Session
+from kallithea.model.repo import RepoModel
from kallithea.model.scm import UserGroupList
from kallithea.model.user_group import UserGroupModel
-from kallithea.model.repo import RepoModel
-from kallithea.model.db import User, UserGroup, UserGroupToPerm, \
- UserGroupRepoToPerm, UserGroupRepoGroupToPerm
-from kallithea.model.forms import UserGroupForm, UserGroupPermsForm, \
- CustomDefaultPermissionsForm
-from kallithea.model.meta import Session
-from kallithea.lib.utils import action_logger
+
log = logging.getLogger(__name__)
diff --git a/kallithea/controllers/admin/users.py b/kallithea/controllers/admin/users.py
--- a/kallithea/controllers/admin/users.py
+++ b/kallithea/controllers/admin/users.py
@@ -27,31 +27,31 @@ Original author and date, and relevant c
import logging
import traceback
+
import formencode
-
from formencode import htmlfill
-from tg import request, tmpl_context as c, config, app_globals
+from sqlalchemy.sql.expression import func
+from tg import app_globals, config, request
+from tg import tmpl_context as c
from tg.i18n import ugettext as _
-from sqlalchemy.sql.expression import func
from webob.exc import HTTPFound, HTTPNotFound
import kallithea
from kallithea.config.routing import url
-from kallithea.lib.exceptions import DefaultUserException, \
- UserOwnsReposException, UserCreationError
+from kallithea.lib import auth_modules
from kallithea.lib import helpers as h
-from kallithea.lib.auth import LoginRequired, HasPermissionAnyDecorator, \
- AuthUser
-from kallithea.lib import auth_modules
-from kallithea.lib.base import BaseController, render, IfSshEnabled
+from kallithea.lib.auth import AuthUser, HasPermissionAnyDecorator, LoginRequired
+from kallithea.lib.base import BaseController, IfSshEnabled, render
+from kallithea.lib.exceptions import DefaultUserException, UserCreationError, UserOwnsReposException
+from kallithea.lib.utils import action_logger
+from kallithea.lib.utils2 import datetime_to_time, generate_api_key, safe_int
from kallithea.model.api_key import ApiKeyModel
+from kallithea.model.db import User, UserEmailMap, UserIpMap, UserToPerm
+from kallithea.model.forms import CustomDefaultPermissionsForm, UserForm
+from kallithea.model.meta import Session
from kallithea.model.ssh_key import SshKeyModel, SshKeyModelException
-from kallithea.model.db import User, UserEmailMap, UserIpMap, UserToPerm
-from kallithea.model.forms import UserForm, CustomDefaultPermissionsForm
from kallithea.model.user import UserModel
-from kallithea.model.meta import Session
-from kallithea.lib.utils import action_logger
-from kallithea.lib.utils2 import datetime_to_time, safe_int, generate_api_key
+
log = logging.getLogger(__name__)
diff --git a/kallithea/controllers/api/__init__.py b/kallithea/controllers/api/__init__.py
--- a/kallithea/controllers/api/__init__.py
+++ b/kallithea/controllers/api/__init__.py
@@ -26,22 +26,23 @@ Original author and date, and relevant c
"""
import inspect
+import itertools
import logging
-import types
-import traceback
import time
-import itertools
+import traceback
+import types
-from tg import Response, response, request, TGController
-
+from tg import Response, TGController, request, response
from webob.exc import HTTPError, HTTPException, WSGIHTTPException
-from kallithea.model.db import User
-from kallithea.model import meta
+from kallithea.lib.auth import AuthUser
+from kallithea.lib.base import _get_access_path
+from kallithea.lib.base import _get_ip_addr as _get_ip
from kallithea.lib.compat import json
-from kallithea.lib.auth import AuthUser
-from kallithea.lib.base import _get_ip_addr as _get_ip, _get_access_path
-from kallithea.lib.utils2 import safe_unicode, safe_str
+from kallithea.lib.utils2 import safe_str, safe_unicode
+from kallithea.model import meta
+from kallithea.model.db import User
+
log = logging.getLogger('JSONRPC')
diff --git a/kallithea/controllers/api/api.py b/kallithea/controllers/api/api.py
--- a/kallithea/controllers/api/api.py
+++ b/kallithea/controllers/api/api.py
@@ -25,42 +25,35 @@ Original author and date, and relevant c
:license: GPLv3, see LICENSE.md for more details.
"""
+import logging
import time
import traceback
-import logging
+from datetime import datetime
-from datetime import datetime
from sqlalchemy import or_
-
from tg import request
from kallithea.controllers.api import JSONRPCController, JSONRPCError
from kallithea.lib.auth import (
- PasswordGenerator, AuthUser, HasPermissionAnyDecorator,
- HasPermissionAnyDecorator, HasPermissionAny, HasRepoPermissionLevel,
- HasRepoGroupPermissionLevel, HasUserGroupPermissionLevel)
-from kallithea.lib.utils import map_groups, repo2db_mapper
-from kallithea.lib.utils2 import (
- str2bool, time_to_datetime, safe_int, Optional, OAttr)
+ AuthUser, HasPermissionAny, HasPermissionAnyDecorator, HasRepoGroupPermissionLevel, HasRepoPermissionLevel, HasUserGroupPermissionLevel, PasswordGenerator)
+from kallithea.lib.compat import json
+from kallithea.lib.exceptions import DefaultUserException, UserGroupsAssignedException
+from kallithea.lib.utils import action_logger, map_groups, repo2db_mapper
+from kallithea.lib.utils2 import OAttr, Optional, safe_int, str2bool, time_to_datetime
+from kallithea.lib.vcs.backends.base import EmptyChangeset
+from kallithea.lib.vcs.exceptions import ChangesetDoesNotExistError, EmptyRepositoryError
+from kallithea.model.changeset_status import ChangesetStatusModel
+from kallithea.model.comment import ChangesetCommentsModel
+from kallithea.model.db import ChangesetStatus, Gist, Permission, PullRequest, RepoGroup, Repository, Setting, User, UserGroup, UserIpMap
+from kallithea.model.gist import GistModel
from kallithea.model.meta import Session
+from kallithea.model.pull_request import PullRequestModel
+from kallithea.model.repo import RepoModel
from kallithea.model.repo_group import RepoGroupModel
from kallithea.model.scm import ScmModel, UserGroupList
-from kallithea.model.repo import RepoModel
from kallithea.model.user import UserModel
from kallithea.model.user_group import UserGroupModel
-from kallithea.model.gist import GistModel
-from kallithea.model.changeset_status import ChangesetStatusModel
-from kallithea.model.comment import ChangesetCommentsModel
-from kallithea.model.pull_request import PullRequestModel
-from kallithea.model.db import (
- Repository, Setting, UserIpMap, Permission, User, Gist,
- RepoGroup, UserGroup, PullRequest, ChangesetStatus)
-from kallithea.lib.compat import json
-from kallithea.lib.exceptions import (
- DefaultUserException, UserGroupsAssignedException)
-from kallithea.lib.vcs.exceptions import ChangesetDoesNotExistError, EmptyRepositoryError
-from kallithea.lib.vcs.backends.base import EmptyChangeset
-from kallithea.lib.utils import action_logger
+
log = logging.getLogger(__name__)
diff --git a/kallithea/controllers/changelog.py b/kallithea/controllers/changelog.py
--- a/kallithea/controllers/changelog.py
+++ b/kallithea/controllers/changelog.py
@@ -28,19 +28,19 @@ Original author and date, and relevant c
import logging
import traceback
-from tg import request, session, tmpl_context as c
+from tg import request, session
+from tg import tmpl_context as c
from tg.i18n import ugettext as _
-from webob.exc import HTTPFound, HTTPNotFound, HTTPBadRequest
+from webob.exc import HTTPBadRequest, HTTPFound, HTTPNotFound
import kallithea.lib.helpers as h
from kallithea.config.routing import url
-from kallithea.lib.auth import LoginRequired, HasRepoPermissionLevelDecorator
+from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired
from kallithea.lib.base import BaseRepoController, render
from kallithea.lib.graphmod import graph_data
from kallithea.lib.page import RepoPage
-from kallithea.lib.vcs.exceptions import RepositoryError, ChangesetDoesNotExistError, \
- ChangesetError, NodeDoesNotExistError, EmptyRepositoryError
from kallithea.lib.utils2 import safe_int, safe_str
+from kallithea.lib.vcs.exceptions import ChangesetDoesNotExistError, ChangesetError, EmptyRepositoryError, NodeDoesNotExistError, RepositoryError
log = logging.getLogger(__name__)
diff --git a/kallithea/controllers/changeset.py b/kallithea/controllers/changeset.py
--- a/kallithea/controllers/changeset.py
+++ b/kallithea/controllers/changeset.py
@@ -27,29 +27,29 @@ Original author and date, and relevant c
import logging
import traceback
-from collections import defaultdict, OrderedDict
+from collections import OrderedDict, defaultdict
-from tg import tmpl_context as c, request, response
+from tg import request, response
+from tg import tmpl_context as c
from tg.i18n import ugettext as _
-from webob.exc import HTTPFound, HTTPForbidden, HTTPBadRequest, HTTPNotFound
-
-from kallithea.lib.vcs.exceptions import RepositoryError, \
- ChangesetDoesNotExistError, EmptyRepositoryError
+from webob.exc import HTTPBadRequest, HTTPForbidden, HTTPFound, HTTPNotFound
import kallithea.lib.helpers as h
-from kallithea.lib.auth import LoginRequired, HasRepoPermissionLevelDecorator
-from kallithea.lib.base import BaseRepoController, render, jsonify
+from kallithea.lib import diffs
+from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired
+from kallithea.lib.base import BaseRepoController, jsonify, render
+from kallithea.lib.graphmod import graph_data
from kallithea.lib.utils import action_logger
-from kallithea.lib import diffs
+from kallithea.lib.utils2 import safe_unicode
+from kallithea.lib.vcs.backends.base import EmptyChangeset
+from kallithea.lib.vcs.exceptions import ChangesetDoesNotExistError, EmptyRepositoryError, RepositoryError
+from kallithea.model.changeset_status import ChangesetStatusModel
+from kallithea.model.comment import ChangesetCommentsModel
from kallithea.model.db import ChangesetComment, ChangesetStatus
-from kallithea.model.comment import ChangesetCommentsModel
-from kallithea.model.changeset_status import ChangesetStatusModel
from kallithea.model.meta import Session
from kallithea.model.pull_request import PullRequestModel
from kallithea.model.repo import RepoModel
-from kallithea.lib.vcs.backends.base import EmptyChangeset
-from kallithea.lib.utils2 import safe_unicode
-from kallithea.lib.graphmod import graph_data
+
log = logging.getLogger(__name__)
diff --git a/kallithea/controllers/compare.py b/kallithea/controllers/compare.py
--- a/kallithea/controllers/compare.py
+++ b/kallithea/controllers/compare.py
@@ -30,20 +30,22 @@ Original author and date, and relevant c
import logging
import re
-from tg import request, tmpl_context as c
+from tg import request
+from tg import tmpl_context as c
from tg.i18n import ugettext as _
-from webob.exc import HTTPFound, HTTPBadRequest, HTTPNotFound
+from webob.exc import HTTPBadRequest, HTTPFound, HTTPNotFound
from kallithea.config.routing import url
-from kallithea.lib.utils2 import safe_str, safe_int
-from kallithea.lib.vcs.utils.hgcompat import unionrepo
+from kallithea.controllers.changeset import _context_url, _ignorews_url
+from kallithea.lib import diffs
from kallithea.lib import helpers as h
+from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired
from kallithea.lib.base import BaseRepoController, render
-from kallithea.lib.auth import LoginRequired, HasRepoPermissionLevelDecorator
-from kallithea.lib import diffs
+from kallithea.lib.graphmod import graph_data
+from kallithea.lib.utils2 import safe_int, safe_str
+from kallithea.lib.vcs.utils.hgcompat import unionrepo
from kallithea.model.db import Repository
-from kallithea.controllers.changeset import _ignorews_url, _context_url
-from kallithea.lib.graphmod import graph_data
+
log = logging.getLogger(__name__)
diff --git a/kallithea/controllers/error.py b/kallithea/controllers/error.py
--- a/kallithea/controllers/error.py
+++ b/kallithea/controllers/error.py
@@ -25,15 +25,17 @@ Original author and date, and relevant c
:license: GPLv3, see LICENSE.md for more details.
"""
-import os
import cgi
import logging
+import os
-from tg import tmpl_context as c, request, config, expose
+from tg import config, expose, request
+from tg import tmpl_context as c
from tg.i18n import ugettext as _
from kallithea.lib.base import BaseController, render
+
log = logging.getLogger(__name__)
diff --git a/kallithea/controllers/feed.py b/kallithea/controllers/feed.py
--- a/kallithea/controllers/feed.py
+++ b/kallithea/controllers/feed.py
@@ -28,19 +28,20 @@ Original author and date, and relevant c
import logging
-from tg import response, tmpl_context as c
+from beaker.cache import cache_region, region_invalidate
+from tg import response
+from tg import tmpl_context as c
from tg.i18n import ugettext as _
-
-from beaker.cache import cache_region, region_invalidate
from webhelpers.feedgenerator import Atom1Feed, Rss201rev2Feed
from kallithea import CONFIG
from kallithea.lib import helpers as h
-from kallithea.lib.auth import LoginRequired, HasRepoPermissionLevelDecorator
+from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired
from kallithea.lib.base import BaseRepoController
from kallithea.lib.diffs import DiffProcessor
+from kallithea.lib.utils2 import safe_int, safe_unicode, str2bool
from kallithea.model.db import CacheInvalidation
-from kallithea.lib.utils2 import safe_int, str2bool, safe_unicode
+
log = logging.getLogger(__name__)
diff --git a/kallithea/controllers/files.py b/kallithea/controllers/files.py
--- a/kallithea/controllers/files.py
+++ b/kallithea/controllers/files.py
@@ -25,43 +25,36 @@ Original author and date, and relevant c
:license: GPLv3, see LICENSE.md for more details.
"""
+import logging
import os
import posixpath
-import logging
+import shutil
+import tempfile
import traceback
-import tempfile
-import shutil
from collections import OrderedDict
-from tg import request, response, tmpl_context as c
+from tg import request, response
+from tg import tmpl_context as c
from tg.i18n import ugettext as _
-from webob.exc import HTTPFound
+from webob.exc import HTTPFound, HTTPNotFound
from kallithea.config.routing import url
-from kallithea.lib.utils import action_logger
+from kallithea.controllers.changeset import _context_url, _ignorews_url, anchor_url, get_ignore_ws, get_line_ctx
from kallithea.lib import diffs
from kallithea.lib import helpers as h
-
-from kallithea.lib.utils2 import convert_line_endings, detect_mode, safe_str, \
- str2bool, safe_int
-from kallithea.lib.auth import LoginRequired, HasRepoPermissionLevelDecorator
-from kallithea.lib.base import BaseRepoController, render, jsonify
+from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired
+from kallithea.lib.base import BaseRepoController, jsonify, render
+from kallithea.lib.exceptions import NonRelativePathError
+from kallithea.lib.utils import action_logger
+from kallithea.lib.utils2 import convert_line_endings, detect_mode, safe_int, safe_str, str2bool
from kallithea.lib.vcs.backends.base import EmptyChangeset
from kallithea.lib.vcs.conf import settings
-from kallithea.lib.vcs.exceptions import RepositoryError, \
- ChangesetDoesNotExistError, EmptyRepositoryError, \
- ImproperArchiveTypeError, VCSError, NodeAlreadyExistsError, \
- NodeDoesNotExistError, ChangesetError, NodeError
+from kallithea.lib.vcs.exceptions import (
+ ChangesetDoesNotExistError, ChangesetError, EmptyRepositoryError, ImproperArchiveTypeError, NodeAlreadyExistsError, NodeDoesNotExistError, NodeError, RepositoryError, VCSError)
from kallithea.lib.vcs.nodes import FileNode
-
+from kallithea.model.db import Repository
from kallithea.model.repo import RepoModel
from kallithea.model.scm import ScmModel
-from kallithea.model.db import Repository
-
-from kallithea.controllers.changeset import anchor_url, _ignorews_url, \
- _context_url, get_line_ctx, get_ignore_ws
-from webob.exc import HTTPNotFound
-from kallithea.lib.exceptions import NonRelativePathError
log = logging.getLogger(__name__)
diff --git a/kallithea/controllers/followers.py b/kallithea/controllers/followers.py
--- a/kallithea/controllers/followers.py
+++ b/kallithea/controllers/followers.py
@@ -27,14 +27,16 @@ Original author and date, and relevant c
import logging
-from tg import tmpl_context as c, request
+from tg import request
+from tg import tmpl_context as c
-from kallithea.lib.auth import LoginRequired, HasRepoPermissionLevelDecorator
+from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired
from kallithea.lib.base import BaseRepoController, render
from kallithea.lib.page import Page
from kallithea.lib.utils2 import safe_int
from kallithea.model.db import UserFollowing
+
log = logging.getLogger(__name__)
diff --git a/kallithea/controllers/forks.py b/kallithea/controllers/forks.py
--- a/kallithea/controllers/forks.py
+++ b/kallithea/controllers/forks.py
@@ -26,26 +26,26 @@ Original author and date, and relevant c
"""
import logging
+import traceback
+
import formencode
-import traceback
from formencode import htmlfill
-
-from tg import tmpl_context as c, request
+from tg import request
+from tg import tmpl_context as c
from tg.i18n import ugettext as _
from webob.exc import HTTPFound
import kallithea.lib.helpers as h
-
from kallithea.config.routing import url
-from kallithea.lib.auth import LoginRequired, HasRepoPermissionLevelDecorator, \
- HasRepoPermissionLevel, HasPermissionAnyDecorator, HasPermissionAny
+from kallithea.lib.auth import HasPermissionAny, HasPermissionAnyDecorator, HasRepoPermissionLevel, HasRepoPermissionLevelDecorator, LoginRequired
from kallithea.lib.base import BaseRepoController, render
from kallithea.lib.page import Page
from kallithea.lib.utils2 import safe_int
-from kallithea.model.db import Repository, UserFollowing, User, Ui
+from kallithea.model.db import Repository, Ui, User, UserFollowing
+from kallithea.model.forms import RepoForkForm
from kallithea.model.repo import RepoModel
-from kallithea.model.forms import RepoForkForm
-from kallithea.model.scm import ScmModel, AvailableRepoGroupChoices
+from kallithea.model.scm import AvailableRepoGroupChoices, ScmModel
+
log = logging.getLogger(__name__)
diff --git a/kallithea/controllers/home.py b/kallithea/controllers/home.py
--- a/kallithea/controllers/home.py
+++ b/kallithea/controllers/home.py
@@ -28,20 +28,22 @@ Original author and date, and relevant c
import logging
-from tg import tmpl_context as c, request
+from sqlalchemy import and_, or_
+from sqlalchemy.sql.expression import func
+from tg import request
+from tg import tmpl_context as c
from tg.i18n import ugettext as _
from webob.exc import HTTPBadRequest
-from sqlalchemy.sql.expression import func
-from sqlalchemy import or_, and_
+from kallithea.lib import helpers as h
+from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired
+from kallithea.lib.base import BaseController, jsonify, render
from kallithea.lib.utils import conditional_cache
-from kallithea.lib.auth import LoginRequired, HasRepoPermissionLevelDecorator
-from kallithea.lib.base import BaseController, render, jsonify
-from kallithea.lib import helpers as h
-from kallithea.model.db import Repository, RepoGroup, User, UserGroup
+from kallithea.model.db import RepoGroup, Repository, User, UserGroup
from kallithea.model.repo import RepoModel
from kallithea.model.scm import UserGroupList
+
log = logging.getLogger(__name__)
diff --git a/kallithea/controllers/journal.py b/kallithea/controllers/journal.py
--- a/kallithea/controllers/journal.py
+++ b/kallithea/controllers/journal.py
@@ -33,23 +33,23 @@ from itertools import groupby
from sqlalchemy import or_
from sqlalchemy.orm import joinedload
from sqlalchemy.sql.expression import func
-
+from tg import request, response
+from tg import tmpl_context as c
+from tg.i18n import ugettext as _
from webhelpers.feedgenerator import Atom1Feed, Rss201rev2Feed
-
from webob.exc import HTTPBadRequest
-from tg import request, tmpl_context as c, response
-from tg.i18n import ugettext as _
+import kallithea.lib.helpers as h
from kallithea.config.routing import url
from kallithea.controllers.admin.admin import _journal_filter
-from kallithea.model.db import UserLog, UserFollowing, Repository, User
-from kallithea.model.meta import Session
-from kallithea.model.repo import RepoModel
-import kallithea.lib.helpers as h
from kallithea.lib.auth import LoginRequired
from kallithea.lib.base import BaseController, render
from kallithea.lib.page import Page
-from kallithea.lib.utils2 import safe_int, AttributeDict
+from kallithea.lib.utils2 import AttributeDict, safe_int
+from kallithea.model.db import Repository, User, UserFollowing, UserLog
+from kallithea.model.meta import Session
+from kallithea.model.repo import RepoModel
+
log = logging.getLogger(__name__)
diff --git a/kallithea/controllers/login.py b/kallithea/controllers/login.py
--- a/kallithea/controllers/login.py
+++ b/kallithea/controllers/login.py
@@ -28,12 +28,13 @@ Original author and date, and relevant c
import logging
import re
+
import formencode
-
from formencode import htmlfill
+from tg import request, session
+from tg import tmpl_context as c
from tg.i18n import ugettext as _
-from tg import request, session, tmpl_context as c
-from webob.exc import HTTPFound, HTTPBadRequest
+from webob.exc import HTTPBadRequest, HTTPFound
import kallithea.lib.helpers as h
from kallithea.config.routing import url
@@ -41,11 +42,10 @@ from kallithea.lib.auth import AuthUser,
from kallithea.lib.base import BaseController, log_in_user, render
from kallithea.lib.exceptions import UserCreationError
from kallithea.lib.utils2 import safe_str
-from kallithea.model.db import User, Setting
-from kallithea.model.forms import \
- LoginForm, RegisterForm, PasswordResetRequestForm, PasswordResetConfirmationForm
+from kallithea.model.db import Setting, User
+from kallithea.model.forms import LoginForm, PasswordResetConfirmationForm, PasswordResetRequestForm, RegisterForm
+from kallithea.model.meta import Session
from kallithea.model.user import UserModel
-from kallithea.model.meta import Session
log = logging.getLogger(__name__)
diff --git a/kallithea/controllers/pullrequests.py b/kallithea/controllers/pullrequests.py
--- a/kallithea/controllers/pullrequests.py
+++ b/kallithea/controllers/pullrequests.py
@@ -27,35 +27,35 @@ Original author and date, and relevant c
import logging
import traceback
+
import formencode
-
-from tg import request, tmpl_context as c
+from tg import request
+from tg import tmpl_context as c
from tg.i18n import ugettext as _
-from webob.exc import HTTPFound, HTTPNotFound, HTTPForbidden, HTTPBadRequest
+from webob.exc import HTTPBadRequest, HTTPForbidden, HTTPFound, HTTPNotFound
from kallithea.config.routing import url
-from kallithea.lib import helpers as h
+from kallithea.controllers.changeset import _context_url, _ignorews_url, create_cs_pr_comment, delete_cs_pr_comment
+from kallithea.controllers.compare import CompareController
from kallithea.lib import diffs
-from kallithea.lib.auth import LoginRequired, HasRepoPermissionLevelDecorator
-from kallithea.lib.base import BaseRepoController, render, jsonify
+from kallithea.lib import helpers as h
+from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired
+from kallithea.lib.base import BaseRepoController, jsonify, render
+from kallithea.lib.graphmod import graph_data
from kallithea.lib.page import Page
from kallithea.lib.utils import action_logger
-from kallithea.lib.vcs.exceptions import EmptyRepositoryError, ChangesetDoesNotExistError
+from kallithea.lib.utils2 import safe_int
+from kallithea.lib.vcs.exceptions import ChangesetDoesNotExistError, EmptyRepositoryError
from kallithea.lib.vcs.utils import safe_str
from kallithea.lib.vcs.utils.hgcompat import unionrepo
-from kallithea.model.db import PullRequest, ChangesetStatus, \
- PullRequestReviewer, Repository, User
-from kallithea.model.pull_request import CreatePullRequestAction, CreatePullRequestIterationAction, PullRequestModel
-from kallithea.model.meta import Session
-from kallithea.model.repo import RepoModel
+from kallithea.model.changeset_status import ChangesetStatusModel
from kallithea.model.comment import ChangesetCommentsModel
-from kallithea.model.changeset_status import ChangesetStatusModel
+from kallithea.model.db import ChangesetStatus, PullRequest, PullRequestReviewer, Repository, User
from kallithea.model.forms import PullRequestForm, PullRequestPostForm
-from kallithea.lib.utils2 import safe_int
-from kallithea.controllers.changeset import _ignorews_url, _context_url, \
- create_cs_pr_comment, delete_cs_pr_comment
-from kallithea.controllers.compare import CompareController
-from kallithea.lib.graphmod import graph_data
+from kallithea.model.meta import Session
+from kallithea.model.pull_request import CreatePullRequestAction, CreatePullRequestIterationAction, PullRequestModel
+from kallithea.model.repo import RepoModel
+
log = logging.getLogger(__name__)
diff --git a/kallithea/controllers/root.py b/kallithea/controllers/root.py
--- a/kallithea/controllers/root.py
+++ b/kallithea/controllers/root.py
@@ -11,11 +11,12 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
+from tg import config
from tgext.routes import RoutedController
+
from kallithea.config.routing import make_map
+from kallithea.controllers.error import ErrorController
from kallithea.lib.base import BaseController
-from kallithea.controllers.error import ErrorController
-from tg import config
# This is the main Kallithea entry point; TurboGears will forward all requests
diff --git a/kallithea/controllers/search.py b/kallithea/controllers/search.py
--- a/kallithea/controllers/search.py
+++ b/kallithea/controllers/search.py
@@ -28,22 +28,23 @@ Original author and date, and relevant c
import logging
import traceback
import urllib
+
+from tg import config, request
+from tg import tmpl_context as c
from tg.i18n import ugettext as _
-from tg import request, config, tmpl_context as c
-
-from whoosh.index import open_dir, exists_in, EmptyIndexError
+from webhelpers2.html.tools import update_params
+from whoosh.index import EmptyIndexError, exists_in, open_dir
from whoosh.qparser import QueryParser, QueryParserError
from whoosh.query import Phrase, Prefix
-from webhelpers2.html.tools import update_params
from kallithea.lib.auth import LoginRequired
from kallithea.lib.base import BaseRepoController, render
-from kallithea.lib.indexers import CHGSETS_SCHEMA, SCHEMA, CHGSET_IDX_NAME, \
- IDX_NAME, WhooshResultWrapper
+from kallithea.lib.indexers import CHGSET_IDX_NAME, CHGSETS_SCHEMA, IDX_NAME, SCHEMA, WhooshResultWrapper
from kallithea.lib.page import Page
-from kallithea.lib.utils2 import safe_str, safe_int
+from kallithea.lib.utils2 import safe_int, safe_str
from kallithea.model.repo import RepoModel
+
log = logging.getLogger(__name__)
diff --git a/kallithea/controllers/summary.py b/kallithea/controllers/summary.py
--- a/kallithea/controllers/summary.py
+++ b/kallithea/controllers/summary.py
@@ -25,32 +25,32 @@ Original author and date, and relevant c
:license: GPLv3, see LICENSE.md for more details.
"""
-import traceback
import calendar
-import logging
import itertools
+import logging
+import traceback
+from datetime import date, timedelta
from time import mktime
-from datetime import timedelta, date
-from tg import tmpl_context as c, request
+from beaker.cache import cache_region, region_invalidate
+from tg import request
+from tg import tmpl_context as c
from tg.i18n import ugettext as _
from webob.exc import HTTPBadRequest
-from beaker.cache import cache_region, region_invalidate
-
-from kallithea.lib.vcs.exceptions import ChangesetError, EmptyRepositoryError, \
- NodeDoesNotExistError
-from kallithea.config.conf import ALL_READMES, ALL_EXTS, LANGUAGES_EXTENSIONS_MAP
-from kallithea.model.db import Statistics, CacheInvalidation, User
-from kallithea.lib.utils2 import safe_int, safe_str
-from kallithea.lib.auth import LoginRequired, HasRepoPermissionLevelDecorator
-from kallithea.lib.base import BaseRepoController, render, jsonify
-from kallithea.lib.vcs.backends.base import EmptyChangeset
-from kallithea.lib.markup_renderer import MarkupRenderer
+from kallithea.config.conf import ALL_EXTS, ALL_READMES, LANGUAGES_EXTENSIONS_MAP
+from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired
+from kallithea.lib.base import BaseRepoController, jsonify, render
from kallithea.lib.celerylib.tasks import get_commits_stats
from kallithea.lib.compat import json
+from kallithea.lib.markup_renderer import MarkupRenderer
+from kallithea.lib.page import RepoPage
+from kallithea.lib.utils2 import safe_int, safe_str
+from kallithea.lib.vcs.backends.base import EmptyChangeset
+from kallithea.lib.vcs.exceptions import ChangesetError, EmptyRepositoryError, NodeDoesNotExistError
from kallithea.lib.vcs.nodes import FileNode
-from kallithea.lib.page import RepoPage
+from kallithea.model.db import CacheInvalidation, Statistics, User
+
log = logging.getLogger(__name__)
diff --git a/kallithea/lib/annotate.py b/kallithea/lib/annotate.py
--- a/kallithea/lib/annotate.py
+++ b/kallithea/lib/annotate.py
@@ -27,10 +27,11 @@ Original author and date, and relevant c
import StringIO
+from pygments import highlight
+from pygments.formatters import HtmlFormatter
+
from kallithea.lib.vcs.exceptions import VCSError
from kallithea.lib.vcs.nodes import FileNode
-from pygments.formatters import HtmlFormatter
-from pygments import highlight
def annotate_highlight(filenode, annotate_from_changeset_func=None,
diff --git a/kallithea/lib/auth.py b/kallithea/lib/auth.py
--- a/kallithea/lib/auth.py
+++ b/kallithea/lib/auth.py
@@ -24,36 +24,31 @@ Original author and date, and relevant c
:copyright: (c) 2013 RhodeCode GmbH, and others.
:license: GPLv3, see LICENSE.md for more details.
"""
-import os
-import logging
-import traceback
+import collections
import hashlib
import itertools
-import collections
-
-from decorator import decorator
+import logging
+import os
+import traceback
import ipaddr
+from decorator import decorator
+from sqlalchemy.orm import joinedload
+from sqlalchemy.orm.exc import ObjectDeletedError
from tg import request, session
from tg.i18n import ugettext as _
-from sqlalchemy.orm.exc import ObjectDeletedError
-from sqlalchemy.orm import joinedload
-from webob.exc import HTTPFound, HTTPBadRequest, HTTPForbidden, HTTPMethodNotAllowed
+from webob.exc import HTTPBadRequest, HTTPForbidden, HTTPFound, HTTPMethodNotAllowed
-from kallithea import __platform__, is_windows, is_unix
+from kallithea import __platform__, is_unix, is_windows
from kallithea.config.routing import url
+from kallithea.lib.caching_query import FromCache
+from kallithea.lib.utils import conditional_cache, get_repo_group_slug, get_repo_slug, get_user_group_slug
+from kallithea.lib.utils2 import aslist, safe_str, safe_unicode
from kallithea.lib.vcs.utils.lazy import LazyProperty
+from kallithea.model.db import (
+ Permission, RepoGroup, Repository, User, UserApiKeys, UserGroup, UserGroupMember, UserGroupRepoGroupToPerm, UserGroupRepoToPerm, UserGroupToPerm, UserGroupUserGroupToPerm, UserIpMap, UserToPerm)
from kallithea.model.meta import Session
from kallithea.model.user import UserModel
-from kallithea.model.db import User, Repository, Permission, \
- UserToPerm, UserGroupRepoToPerm, UserGroupToPerm, UserGroupMember, \
- RepoGroup, UserGroupRepoGroupToPerm, UserIpMap, UserGroupUserGroupToPerm, \
- UserGroup, UserApiKeys
-
-from kallithea.lib.utils2 import safe_str, safe_unicode, aslist
-from kallithea.lib.utils import get_repo_slug, get_repo_group_slug, \
- get_user_group_slug, conditional_cache
-from kallithea.lib.caching_query import FromCache
log = logging.getLogger(__name__)
diff --git a/kallithea/lib/auth_modules/__init__.py b/kallithea/lib/auth_modules/__init__.py
--- a/kallithea/lib/auth_modules/__init__.py
+++ b/kallithea/lib/auth_modules/__init__.py
@@ -15,18 +15,19 @@
Authentication modules
"""
+import importlib
import logging
import traceback
-import importlib
+from kallithea.lib.auth import AuthUser, PasswordGenerator
+from kallithea.lib.compat import formatted_json, hybrid_property
from kallithea.lib.utils2 import str2bool
-from kallithea.lib.compat import formatted_json, hybrid_property
-from kallithea.lib.auth import PasswordGenerator, AuthUser
-from kallithea.model.user import UserModel
from kallithea.model.db import Setting, User
from kallithea.model.meta import Session
+from kallithea.model.user import UserModel
from kallithea.model.user_group import UserGroupModel
+
log = logging.getLogger(__name__)
diff --git a/kallithea/lib/auth_modules/auth_container.py b/kallithea/lib/auth_modules/auth_container.py
--- a/kallithea/lib/auth_modules/auth_container.py
+++ b/kallithea/lib/auth_modules/auth_container.py
@@ -26,10 +26,12 @@ Original author and date, and relevant c
"""
import logging
+
from kallithea.lib import auth_modules
-from kallithea.lib.utils2 import str2bool, safe_unicode, safe_str
from kallithea.lib.compat import hybrid_property
-from kallithea.model.db import User, Setting
+from kallithea.lib.utils2 import safe_str, safe_unicode, str2bool
+from kallithea.model.db import Setting, User
+
log = logging.getLogger(__name__)
diff --git a/kallithea/lib/auth_modules/auth_crowd.py b/kallithea/lib/auth_modules/auth_crowd.py
--- a/kallithea/lib/auth_modules/auth_crowd.py
+++ b/kallithea/lib/auth_modules/auth_crowd.py
@@ -29,10 +29,12 @@ Original author and date, and relevant c
import base64
import logging
import urllib2
+
from kallithea.lib import auth_modules
-from kallithea.lib.compat import json, formatted_json, hybrid_property
+from kallithea.lib.compat import formatted_json, hybrid_property, json
from kallithea.model.db import User
+
log = logging.getLogger(__name__)
diff --git a/kallithea/lib/auth_modules/auth_internal.py b/kallithea/lib/auth_modules/auth_internal.py
--- a/kallithea/lib/auth_modules/auth_internal.py
+++ b/kallithea/lib/auth_modules/auth_internal.py
@@ -32,6 +32,7 @@ from kallithea.lib import auth_modules
from kallithea.lib.compat import formatted_json, hybrid_property
from kallithea.model.db import User
+
log = logging.getLogger(__name__)
diff --git a/kallithea/lib/auth_modules/auth_ldap.py b/kallithea/lib/auth_modules/auth_ldap.py
--- a/kallithea/lib/auth_modules/auth_ldap.py
+++ b/kallithea/lib/auth_modules/auth_ldap.py
@@ -31,12 +31,11 @@ import traceback
from kallithea.lib import auth_modules
from kallithea.lib.compat import hybrid_property
-from kallithea.lib.utils2 import safe_unicode, safe_str
-from kallithea.lib.exceptions import (
- LdapConnectionError, LdapUsernameError, LdapPasswordError, LdapImportError
-)
+from kallithea.lib.exceptions import LdapConnectionError, LdapImportError, LdapPasswordError, LdapUsernameError
+from kallithea.lib.utils2 import safe_str, safe_unicode
from kallithea.model.db import User
+
log = logging.getLogger(__name__)
try:
diff --git a/kallithea/lib/auth_modules/auth_pam.py b/kallithea/lib/auth_modules/auth_pam.py
--- a/kallithea/lib/auth_modules/auth_pam.py
+++ b/kallithea/lib/auth_modules/auth_pam.py
@@ -23,9 +23,18 @@ Original author and date, and relevant c
:author: Alexey Larikov
"""
+import grp
import logging
+import pwd
+import re
+import socket
+import threading
import time
+from kallithea.lib import auth_modules
+from kallithea.lib.compat import formatted_json, hybrid_property
+
+
try:
from pam import authenticate as pam_authenticate
except ImportError:
@@ -33,14 +42,7 @@ except ImportError:
from pam import pam
pam_authenticate = pam().authenticate
-import pwd
-import grp
-import re
-import socket
-import threading
-from kallithea.lib import auth_modules
-from kallithea.lib.compat import formatted_json, hybrid_property
log = logging.getLogger(__name__)
diff --git a/kallithea/lib/base.py b/kallithea/lib/base.py
--- a/kallithea/lib/base.py
+++ b/kallithea/lib/base.py
@@ -29,36 +29,33 @@ Original author and date, and relevant c
"""
import datetime
-import decorator
import logging
import time
import traceback
import warnings
-import webob.exc
+import decorator
+import paste.auth.basic
import paste.httpexceptions
-import paste.auth.basic
import paste.httpheaders
-
-from tg import config, tmpl_context as c, request, response, session, render_template
-from tg import TGController
+import webob.exc
+from tg import TGController, config, render_template, request, response, session
+from tg import tmpl_context as c
from tg.i18n import ugettext as _
-from kallithea import __version__, BACKENDS
-
+from kallithea import BACKENDS, __version__
from kallithea.config.routing import url
-from kallithea.lib.utils2 import str2bool, safe_unicode, AttributeDict, \
- safe_str, safe_int, set_hook_environment
from kallithea.lib import auth_modules
from kallithea.lib.auth import AuthUser, HasPermissionAnyMiddleware
from kallithea.lib.compat import json
+from kallithea.lib.exceptions import UserCreationError
from kallithea.lib.utils import get_repo_slug, is_valid_repo
-from kallithea.lib.exceptions import UserCreationError
-from kallithea.lib.vcs.exceptions import RepositoryError, EmptyRepositoryError, ChangesetDoesNotExistError
+from kallithea.lib.utils2 import AttributeDict, safe_int, safe_str, safe_unicode, set_hook_environment, str2bool
+from kallithea.lib.vcs.exceptions import ChangesetDoesNotExistError, EmptyRepositoryError, RepositoryError
from kallithea.model import meta
+from kallithea.model.db import PullRequest, Repository, Setting, User
+from kallithea.model.scm import ScmModel
-from kallithea.model.db import PullRequest, Repository, User, Setting
-from kallithea.model.scm import ScmModel
log = logging.getLogger(__name__)
diff --git a/kallithea/lib/caching_query.py b/kallithea/lib/caching_query.py
--- a/kallithea/lib/caching_query.py
+++ b/kallithea/lib/caching_query.py
@@ -18,10 +18,10 @@ Beaker constructs.
"""
import beaker
from beaker.exceptions import BeakerException
-
from sqlalchemy.orm.interfaces import MapperOption
from sqlalchemy.orm.query import Query
from sqlalchemy.sql import visitors
+
from kallithea.lib.utils2 import safe_str
diff --git a/kallithea/lib/celerylib/__init__.py b/kallithea/lib/celerylib/__init__.py
--- a/kallithea/lib/celerylib/__init__.py
+++ b/kallithea/lib/celerylib/__init__.py
@@ -26,19 +26,18 @@ Original author and date, and relevant c
"""
+import logging
import os
-import logging
+from hashlib import md5
+from decorator import decorator
from tg import config
-from hashlib import md5
-from decorator import decorator
-
-from kallithea import CELERY_ON, CELERY_EAGER
+from kallithea import CELERY_EAGER, CELERY_ON
+from kallithea.lib.pidlock import DaemonLock, LockHeld
from kallithea.lib.utils2 import safe_str
-from kallithea.lib.pidlock import DaemonLock, LockHeld
+from kallithea.model import meta
from kallithea.model.base import init_model
-from kallithea.model import meta
log = logging.getLogger(__name__)
diff --git a/kallithea/lib/celerylib/tasks.py b/kallithea/lib/celerylib/tasks.py
--- a/kallithea/lib/celerylib/tasks.py
+++ b/kallithea/lib/celerylib/tasks.py
@@ -26,28 +26,26 @@ Original author and date, and relevant c
:license: GPLv3, see LICENSE.md for more details.
"""
+import logging
import os
-import traceback
-import logging
import rfc822
-
+import traceback
from collections import OrderedDict
+from operator import itemgetter
from time import mktime
-from operator import itemgetter
from tg import config
from kallithea import CELERY_ON
from kallithea.lib import celerylib
+from kallithea.lib.compat import json
from kallithea.lib.helpers import person
+from kallithea.lib.hooks import log_create_repository
from kallithea.lib.rcmail.smtp_mailer import SmtpMailer
from kallithea.lib.utils import action_logger
from kallithea.lib.utils2 import str2bool
from kallithea.lib.vcs.utils import author_email
-from kallithea.lib.compat import json
-from kallithea.lib.hooks import log_create_repository
-
-from kallithea.model.db import Statistics, RepoGroup, Repository, User
+from kallithea.model.db import RepoGroup, Repository, Statistics, User
__all__ = ['whoosh_index', 'get_commits_stats', 'send_email']
diff --git a/kallithea/lib/celerypylons/__init__.py b/kallithea/lib/celerypylons/__init__.py
--- a/kallithea/lib/celerypylons/__init__.py
+++ b/kallithea/lib/celerypylons/__init__.py
@@ -17,8 +17,11 @@ mandatory settings.
import os
import warnings
+import celery
+import celery.result as result
import tg
-import celery
+from celery.bin import worker
+from celery.task import task
def celery_config(config):
@@ -56,7 +59,3 @@ def celery_config(config):
# Create celery app from the TurboGears configuration file
app = celery.Celery()
app.config_from_object(celery_config(tg.config))
-
-import celery.result as result
-from celery.task import task
-from celery.bin import worker
diff --git a/kallithea/lib/colored_formatter.py b/kallithea/lib/colored_formatter.py
--- a/kallithea/lib/colored_formatter.py
+++ b/kallithea/lib/colored_formatter.py
@@ -14,6 +14,7 @@
import logging
+
BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = xrange(30, 38)
# Sequences
diff --git a/kallithea/lib/compat.py b/kallithea/lib/compat.py
--- a/kallithea/lib/compat.py
+++ b/kallithea/lib/compat.py
@@ -27,29 +27,31 @@ Original author and date, and relevant c
"""
-import sys
+import functools
import os
-import functools
+import sys
+
+#==============================================================================
+# Hybrid property/method
+#==============================================================================
+from sqlalchemy.ext.hybrid import hybrid_property
+#==============================================================================
+# OrderedSet
+#==============================================================================
+from sqlalchemy.util import OrderedSet
#==============================================================================
# json
#==============================================================================
from kallithea.lib.ext_json import json
+
# alias for formatted json
formatted_json = functools.partial(json.dumps, indent=4, sort_keys=True)
-#==============================================================================
-# OrderedSet
-#==============================================================================
-from sqlalchemy.util import OrderedSet
-#==============================================================================
-# Hybrid property/method
-#==============================================================================
-from sqlalchemy.ext.hybrid import hybrid_property
#==============================================================================
diff --git a/kallithea/lib/db_manage.py b/kallithea/lib/db_manage.py
--- a/kallithea/lib/db_manage.py
+++ b/kallithea/lib/db_manage.py
@@ -26,29 +26,26 @@ Original author and date, and relevant c
:license: GPLv3, see LICENSE.md for more details.
"""
+import logging
import os
import sys
import time
import uuid
-import logging
-import sqlalchemy
from os.path import dirname
+import alembic.command
import alembic.config
-import alembic.command
+import sqlalchemy
+from sqlalchemy.engine import create_engine
-from kallithea.model.user import UserModel
from kallithea.model.base import init_model
-from kallithea.model.db import User, Permission, Ui, \
- Setting, UserToPerm, RepoGroup, \
- UserRepoGroupToPerm, CacheInvalidation, Repository
-
-from sqlalchemy.engine import create_engine
+from kallithea.model.db import CacheInvalidation, Permission, RepoGroup, Repository, Setting, Ui, User, UserRepoGroupToPerm, UserToPerm
+#from kallithea.model import meta
+from kallithea.model.meta import Base, Session
+from kallithea.model.permission import PermissionModel
+from kallithea.model.repo import RepoModel
from kallithea.model.repo_group import RepoGroupModel
-#from kallithea.model import meta
-from kallithea.model.meta import Session, Base
-from kallithea.model.repo import RepoModel
-from kallithea.model.permission import PermissionModel
+from kallithea.model.user import UserModel
log = logging.getLogger(__name__)
diff --git a/kallithea/lib/diffs.py b/kallithea/lib/diffs.py
--- a/kallithea/lib/diffs.py
+++ b/kallithea/lib/diffs.py
@@ -25,17 +25,18 @@ Original author and date, and relevant c
:copyright: (c) 2013 RhodeCode GmbH, and others.
:license: GPLv3, see LICENSE.md for more details.
"""
-import re
import difflib
import logging
+import re
from tg.i18n import ugettext as _
from kallithea.lib import helpers as h
+from kallithea.lib.utils2 import safe_unicode
+from kallithea.lib.vcs.backends.base import EmptyChangeset
from kallithea.lib.vcs.exceptions import VCSError
from kallithea.lib.vcs.nodes import FileNode, SubModuleNode
-from kallithea.lib.vcs.backends.base import EmptyChangeset
-from kallithea.lib.utils2 import safe_unicode
+
log = logging.getLogger(__name__)
diff --git a/kallithea/lib/ext_json.py b/kallithea/lib/ext_json.py
--- a/kallithea/lib/ext_json.py
+++ b/kallithea/lib/ext_json.py
@@ -5,9 +5,10 @@ json.org does not specify how date time
"""
import datetime
+import decimal
import functools
-import decimal
-import json # is re-exported after monkey patching
+import json # is re-exported after monkey patching
+
__all__ = ['json']
diff --git a/kallithea/lib/helpers.py b/kallithea/lib/helpers.py
--- a/kallithea/lib/helpers.py
+++ b/kallithea/lib/helpers.py
@@ -19,35 +19,45 @@ available to Controllers. This module is
"""
import hashlib
import json
-import StringIO
import logging
+import random
import re
-import urlparse
+import StringIO
import textwrap
-import random
+import urlparse
from beaker.cache import cache_region
+from pygments import highlight as code_highlight
from pygments.formatters.html import HtmlFormatter
-from pygments import highlight as code_highlight
from tg.i18n import ugettext as _
-
-from webhelpers2.html import literal, HTML, escape
-from webhelpers2.html.tags import checkbox, end_form, hidden, link_to, \
- select as webhelpers2_select, Option, Options, \
- submit, text, password, textarea, radio, form as insecure_form
+from webhelpers2.html import HTML, escape, literal
+from webhelpers2.html.tags import NotGiven, Option, Options, _input, _make_safe_id_component, checkbox, end_form
+from webhelpers2.html.tags import form as insecure_form
+from webhelpers2.html.tags import hidden, link_to, password, radio
+from webhelpers2.html.tags import select as webhelpers2_select
+from webhelpers2.html.tags import submit, text, textarea
from webhelpers2.number import format_byte_size
+from webhelpers2.text import chop_at, truncate, wrap_paragraphs
from webhelpers.pylonslib import Flash as _Flash
-from webhelpers2.text import chop_at, truncate, wrap_paragraphs
-from webhelpers2.html.tags import _input, NotGiven, _make_safe_id_component
from kallithea.config.routing import url
from kallithea.lib.annotate import annotate_highlight
+#==============================================================================
+# PERMS
+#==============================================================================
+from kallithea.lib.auth import HasPermissionAny, HasRepoGroupPermissionLevel, HasRepoPermissionLevel
+from kallithea.lib.markup_renderer import url_re
from kallithea.lib.pygmentsutils import get_custom_lexer
-from kallithea.lib.utils2 import str2bool, safe_unicode, safe_str, \
- time_to_datetime, AttributeDict, safe_int, MENTIONS_REGEX
-from kallithea.lib.markup_renderer import url_re
+from kallithea.lib.utils2 import MENTIONS_REGEX, AttributeDict
+from kallithea.lib.utils2 import age as _age
+from kallithea.lib.utils2 import credentials_filter, safe_int, safe_str, safe_unicode, str2bool, time_to_datetime
+from kallithea.lib.vcs.backends.base import BaseChangeset, EmptyChangeset
from kallithea.lib.vcs.exceptions import ChangesetDoesNotExistError
-from kallithea.lib.vcs.backends.base import BaseChangeset, EmptyChangeset
+#==============================================================================
+# SCM FILTERS available via h.
+#==============================================================================
+from kallithea.lib.vcs.utils import author_email, author_name
+
log = logging.getLogger(__name__)
@@ -454,11 +464,6 @@ class Flash(_Flash):
flash = Flash()
-#==============================================================================
-# SCM FILTERS available via h.
-#==============================================================================
-from kallithea.lib.vcs.utils import author_name, author_email
-from kallithea.lib.utils2 import credentials_filter, age as _age
age = lambda x, y=False: _age(x, y)
capitalize = lambda x: x.capitalize()
@@ -843,11 +848,6 @@ def action_parser(user_log, feed=False,
-#==============================================================================
-# PERMS
-#==============================================================================
-from kallithea.lib.auth import HasPermissionAny, \
- HasRepoPermissionLevel, HasRepoGroupPermissionLevel
#==============================================================================
diff --git a/kallithea/lib/hooks.py b/kallithea/lib/hooks.py
--- a/kallithea/lib/hooks.py
+++ b/kallithea/lib/hooks.py
@@ -25,18 +25,17 @@ Original author and date, and relevant c
:license: GPLv3, see LICENSE.md for more details.
"""
+import binascii
import os
import time
-import binascii
-from kallithea.lib.vcs.utils.hgcompat import nullrev, revrange
from kallithea.lib import helpers as h
-from kallithea.lib.utils import action_logger
+from kallithea.lib.exceptions import UserCreationError
+from kallithea.lib.utils import action_logger, make_ui, setup_cache_regions
+from kallithea.lib.utils2 import get_hook_environment, safe_str, safe_unicode
from kallithea.lib.vcs.backends.base import EmptyChangeset
-from kallithea.lib.exceptions import UserCreationError
-from kallithea.lib.utils import make_ui, setup_cache_regions
-from kallithea.lib.utils2 import safe_str, safe_unicode, get_hook_environment
-from kallithea.model.db import Repository, User, Ui
+from kallithea.lib.vcs.utils.hgcompat import nullrev, revrange
+from kallithea.model.db import Repository, Ui, User
def _get_scm_size(alias, root_path):
diff --git a/kallithea/lib/indexers/__init__.py b/kallithea/lib/indexers/__init__.py
--- a/kallithea/lib/indexers/__init__.py
+++ b/kallithea/lib/indexers/__init__.py
@@ -25,19 +25,23 @@ Original author and date, and relevant c
:license: GPLv3, see LICENSE.md for more details.
"""
+import logging
import os
import sys
-import logging
from os.path import dirname
+from whoosh.analysis import IDTokenizer, LowercaseFilter, RegexTokenizer
+from whoosh.fields import BOOLEAN, DATETIME, ID, NUMERIC, STORED, TEXT, FieldType, Schema
+from whoosh.formats import Characters
+from whoosh.highlight import ContextFragmenter, HtmlFormatter
+from whoosh.highlight import highlight as whoosh_highlight
+
+from kallithea.lib.utils2 import LazyProperty
+
+
# Add location of top level folder to sys.path
sys.path.append(dirname(dirname(dirname(os.path.realpath(__file__)))))
-from whoosh.analysis import RegexTokenizer, LowercaseFilter, IDTokenizer
-from whoosh.fields import TEXT, ID, STORED, NUMERIC, BOOLEAN, Schema, FieldType, DATETIME
-from whoosh.formats import Characters
-from whoosh.highlight import highlight as whoosh_highlight, HtmlFormatter, ContextFragmenter
-from kallithea.lib.utils2 import LazyProperty
log = logging.getLogger(__name__)
diff --git a/kallithea/lib/indexers/daemon.py b/kallithea/lib/indexers/daemon.py
--- a/kallithea/lib/indexers/daemon.py
+++ b/kallithea/lib/indexers/daemon.py
@@ -26,33 +26,32 @@ Original author and date, and relevant c
"""
+import logging
import os
import sys
-import logging
import traceback
-
+from os.path import dirname
from shutil import rmtree
from time import mktime
-from os.path import dirname
+from whoosh.index import create_in, exists_in, open_dir
+from whoosh.qparser import QueryParser
+from whoosh.query import *
+
+from kallithea.config.conf import INDEX_EXTENSIONS, INDEX_FILENAMES
+from kallithea.lib.indexers import CHGSET_IDX_NAME, CHGSETS_SCHEMA, IDX_NAME, SCHEMA
+from kallithea.lib.utils2 import safe_str, safe_unicode
+from kallithea.lib.vcs.exceptions import ChangesetError, NodeDoesNotExistError, RepositoryError
+from kallithea.model.db import Repository
+from kallithea.model.scm import ScmModel
+
# Add location of top level folder to sys.path
project_path = dirname(dirname(dirname(dirname(os.path.realpath(__file__)))))
sys.path.append(project_path)
-from kallithea.config.conf import INDEX_EXTENSIONS, INDEX_FILENAMES
-from kallithea.model.scm import ScmModel
-from kallithea.model.db import Repository
-from kallithea.lib.utils2 import safe_unicode, safe_str
-from kallithea.lib.indexers import SCHEMA, IDX_NAME, CHGSETS_SCHEMA, \
- CHGSET_IDX_NAME
-from kallithea.lib.vcs.exceptions import ChangesetError, RepositoryError, \
- NodeDoesNotExistError
-from whoosh.index import create_in, open_dir, exists_in
-from whoosh.query import *
-from whoosh.qparser import QueryParser
log = logging.getLogger('whoosh_indexer')
diff --git a/kallithea/lib/inifile.py b/kallithea/lib/inifile.py
--- a/kallithea/lib/inifile.py
+++ b/kallithea/lib/inifile.py
@@ -21,8 +21,8 @@ other custom values.
"""
import logging
+import os
import re
-import os
import mako.template
diff --git a/kallithea/lib/locale.py b/kallithea/lib/locale.py
--- a/kallithea/lib/locale.py
+++ b/kallithea/lib/locale.py
@@ -15,6 +15,7 @@ import logging
import os
import sys
+
log = logging.getLogger(__name__)
def current_locale_is_valid():
diff --git a/kallithea/lib/markup_renderer.py b/kallithea/lib/markup_renderer.py
--- a/kallithea/lib/markup_renderer.py
+++ b/kallithea/lib/markup_renderer.py
@@ -26,14 +26,15 @@ Original author and date, and relevant c
"""
+import logging
import re
-import logging
import traceback
+import bleach
import markdown as markdown_mod
-import bleach
-from kallithea.lib.utils2 import safe_unicode, MENTIONS_REGEX
+from kallithea.lib.utils2 import MENTIONS_REGEX, safe_unicode
+
log = logging.getLogger(__name__)
diff --git a/kallithea/lib/middleware/permanent_repo_url.py b/kallithea/lib/middleware/permanent_repo_url.py
--- a/kallithea/lib/middleware/permanent_repo_url.py
+++ b/kallithea/lib/middleware/permanent_repo_url.py
@@ -20,7 +20,7 @@ middleware to handle permanent repo URLs
"""
-from kallithea.lib.utils import safe_str, fix_repo_id_name
+from kallithea.lib.utils import fix_repo_id_name, safe_str
class PermanentRepoUrl(object):
diff --git a/kallithea/lib/middleware/pygrack.py b/kallithea/lib/middleware/pygrack.py
--- a/kallithea/lib/middleware/pygrack.py
+++ b/kallithea/lib/middleware/pygrack.py
@@ -25,16 +25,17 @@ Copyright (c) 2012 Marcin Kuzminski .
+import errno
import os
-import errno
-
from multiprocessing.util import Finalize
from kallithea.lib.compat import kill
diff --git a/kallithea/lib/rcmail/message.py b/kallithea/lib/rcmail/message.py
--- a/kallithea/lib/rcmail/message.py
+++ b/kallithea/lib/rcmail/message.py
@@ -1,8 +1,6 @@
+from kallithea.lib.rcmail.exceptions import BadHeaders, InvalidMessage
from kallithea.lib.rcmail.response import MailResponse
-from kallithea.lib.rcmail.exceptions import BadHeaders
-from kallithea.lib.rcmail.exceptions import InvalidMessage
-
class Attachment(object):
"""
diff --git a/kallithea/lib/rcmail/response.py b/kallithea/lib/rcmail/response.py
--- a/kallithea/lib/rcmail/response.py
+++ b/kallithea/lib/rcmail/response.py
@@ -33,13 +33,14 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
+import mimetypes
import os
-import mimetypes
import string
from email import encoders
from email.charset import Charset
+from email.mime.base import MIMEBase
from email.utils import parseaddr
-from email.mime.base import MIMEBase
+
ADDRESS_HEADERS_WHITELIST = ['From', 'To', 'Delivered-To', 'Cc']
DEFAULT_ENCODING = "utf-8"
diff --git a/kallithea/lib/rcmail/smtp_mailer.py b/kallithea/lib/rcmail/smtp_mailer.py
--- a/kallithea/lib/rcmail/smtp_mailer.py
+++ b/kallithea/lib/rcmail/smtp_mailer.py
@@ -25,11 +25,11 @@ Original author and date, and relevant c
:license: GPLv3, see LICENSE.md for more details.
"""
-import time
import logging
import smtplib
+import time
+from email.utils import formatdate
from ssl import SSLError
-from email.utils import formatdate
from kallithea.lib.rcmail.message import Message
from kallithea.lib.rcmail.utils import DNS_NAME
diff --git a/kallithea/lib/recaptcha.py b/kallithea/lib/recaptcha.py
--- a/kallithea/lib/recaptcha.py
+++ b/kallithea/lib/recaptcha.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
+import json
import urllib
import urllib2
-import json
class RecaptchaResponse(object):
diff --git a/kallithea/lib/ssh.py b/kallithea/lib/ssh.py
--- a/kallithea/lib/ssh.py
+++ b/kallithea/lib/ssh.py
@@ -21,12 +21,13 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
+import binascii
import logging
-import binascii
import re
from tg.i18n import ugettext as _
+
log = logging.getLogger(__name__)
diff --git a/kallithea/lib/timerproxy.py b/kallithea/lib/timerproxy.py
--- a/kallithea/lib/timerproxy.py
+++ b/kallithea/lib/timerproxy.py
@@ -12,10 +12,12 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
+import logging
import time
-import logging
+
from sqlalchemy.interfaces import ConnectionProxy
+
log = logging.getLogger('timerproxy')
BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = xrange(30, 38)
diff --git a/kallithea/lib/utils.py b/kallithea/lib/utils.py
--- a/kallithea/lib/utils.py
+++ b/kallithea/lib/utils.py
@@ -25,28 +25,27 @@ Original author and date, and relevant c
:license: GPLv3, see LICENSE.md for more details.
"""
+import datetime
+import logging
import os
import re
-import logging
-import datetime
import traceback
+
import beaker
-
+from beaker.cache import _cache_decorate
from tg import request, response
from tg.i18n import ugettext as _
-from beaker.cache import _cache_decorate
-
-from kallithea.lib.vcs.utils.hgcompat import ui, config
-from kallithea.lib.vcs.utils.helpers import get_scm
-from kallithea.lib.vcs.exceptions import VCSError
from kallithea.lib.exceptions import HgsubversionImportError
+from kallithea.lib.utils2 import get_current_authuser, safe_str, safe_unicode
+from kallithea.lib.vcs.exceptions import VCSError
+from kallithea.lib.vcs.utils.fakemod import create_module
+from kallithea.lib.vcs.utils.helpers import get_scm
+from kallithea.lib.vcs.utils.hgcompat import config, ui
from kallithea.model import meta
-from kallithea.model.db import Repository, User, Ui, \
- UserLog, RepoGroup, Setting, UserGroup
+from kallithea.model.db import RepoGroup, Repository, Setting, Ui, User, UserGroup, UserLog
from kallithea.model.repo_group import RepoGroupModel
-from kallithea.lib.utils2 import safe_str, safe_unicode, get_current_authuser
-from kallithea.lib.vcs.utils.fakemod import create_module
+
log = logging.getLogger(__name__)
diff --git a/kallithea/lib/utils2.py b/kallithea/lib/utils2.py
--- a/kallithea/lib/utils2.py
+++ b/kallithea/lib/utils2.py
@@ -28,23 +28,24 @@ Original author and date, and relevant c
"""
+import binascii
+import datetime
import os
+import pwd
import re
import sys
import time
+import urllib
import uuid
-import datetime
-import urllib
-import binascii
-import pwd
+import urlobject
import webob
-import urlobject
+from tg.i18n import ugettext as _
+from tg.i18n import ungettext
from webhelpers2.text import collapse, remove_formatting, strip_tags
-from tg.i18n import ugettext as _, ungettext
+from kallithea.lib.compat import json
from kallithea.lib.vcs.utils.lazy import LazyProperty
-from kallithea.lib.compat import json
def str2bool(_str):
diff --git a/kallithea/lib/vcs/__init__.py b/kallithea/lib/vcs/__init__.py
--- a/kallithea/lib/vcs/__init__.py
+++ b/kallithea/lib/vcs/__init__.py
@@ -20,8 +20,9 @@ __all__ = [
]
import sys
-from kallithea.lib.vcs.backends import get_repo, get_backend
-from kallithea.lib.vcs.exceptions import VCSError, RepositoryError, ChangesetError
+
+from kallithea.lib.vcs.backends import get_backend, get_repo
+from kallithea.lib.vcs.exceptions import ChangesetError, RepositoryError, VCSError
def get_version():
diff --git a/kallithea/lib/vcs/backends/__init__.py b/kallithea/lib/vcs/backends/__init__.py
--- a/kallithea/lib/vcs/backends/__init__.py
+++ b/kallithea/lib/vcs/backends/__init__.py
@@ -10,11 +10,12 @@
"""
import os
from pprint import pformat
+
from kallithea.lib.vcs.conf import settings
from kallithea.lib.vcs.exceptions import VCSError
from kallithea.lib.vcs.utils.helpers import get_scm
+from kallithea.lib.vcs.utils.imports import import_class
from kallithea.lib.vcs.utils.paths import abspath
-from kallithea.lib.vcs.utils.imports import import_class
def get_repo(path=None, alias=None, create=False):
diff --git a/kallithea/lib/vcs/backends/base.py b/kallithea/lib/vcs/backends/base.py
--- a/kallithea/lib/vcs/backends/base.py
+++ b/kallithea/lib/vcs/backends/base.py
@@ -12,16 +12,12 @@
import datetime
import itertools
-from kallithea.lib.vcs.utils import author_name, author_email, safe_unicode
-from kallithea.lib.vcs.utils.lazy import LazyProperty
+from kallithea.lib.vcs.conf import settings
+from kallithea.lib.vcs.exceptions import (
+ ChangesetError, EmptyRepositoryError, NodeAlreadyAddedError, NodeAlreadyChangedError, NodeAlreadyExistsError, NodeAlreadyRemovedError, NodeDoesNotExistError, NodeNotChangedError, RepositoryError)
+from kallithea.lib.vcs.utils import author_email, author_name, safe_unicode
from kallithea.lib.vcs.utils.helpers import get_dict_for_attrs
-from kallithea.lib.vcs.conf import settings
-
-from kallithea.lib.vcs.exceptions import (
- ChangesetError, EmptyRepositoryError, NodeAlreadyAddedError,
- NodeAlreadyChangedError, NodeAlreadyExistsError, NodeAlreadyRemovedError,
- NodeDoesNotExistError, NodeNotChangedError, RepositoryError
-)
+from kallithea.lib.vcs.utils.lazy import LazyProperty
class BaseRepository(object):
diff --git a/kallithea/lib/vcs/backends/git/__init__.py b/kallithea/lib/vcs/backends/git/__init__.py
--- a/kallithea/lib/vcs/backends/git/__init__.py
+++ b/kallithea/lib/vcs/backends/git/__init__.py
@@ -1,6 +1,6 @@
-from .repository import GitRepository
from .changeset import GitChangeset
from .inmemory import GitInMemoryChangeset
+from .repository import GitRepository
from .workdir import GitWorkdir
diff --git a/kallithea/lib/vcs/backends/git/changeset.py b/kallithea/lib/vcs/backends/git/changeset.py
--- a/kallithea/lib/vcs/backends/git/changeset.py
+++ b/kallithea/lib/vcs/backends/git/changeset.py
@@ -1,23 +1,17 @@
import re
+from io import BytesIO
from itertools import chain
+from subprocess import PIPE, Popen
+
from dulwich import objects
from dulwich.config import ConfigFile
-from subprocess import Popen, PIPE
-from io import BytesIO
-from kallithea.lib.vcs.conf import settings
from kallithea.lib.vcs.backends.base import BaseChangeset, EmptyChangeset
-from kallithea.lib.vcs.exceptions import (
- RepositoryError, ChangesetError, NodeDoesNotExistError, VCSError,
- ChangesetDoesNotExistError, ImproperArchiveTypeError
-)
+from kallithea.lib.vcs.conf import settings
+from kallithea.lib.vcs.exceptions import ChangesetDoesNotExistError, ChangesetError, ImproperArchiveTypeError, NodeDoesNotExistError, RepositoryError, VCSError
from kallithea.lib.vcs.nodes import (
- FileNode, DirNode, NodeKind, RootNode, SubModuleNode,
- ChangedFileNodesGenerator, AddedFileNodesGenerator, RemovedFileNodesGenerator
-)
-from kallithea.lib.vcs.utils import (
- safe_unicode, safe_str, safe_int, date_fromtimestamp
-)
+ AddedFileNodesGenerator, ChangedFileNodesGenerator, DirNode, FileNode, NodeKind, RemovedFileNodesGenerator, RootNode, SubModuleNode)
+from kallithea.lib.vcs.utils import date_fromtimestamp, safe_int, safe_str, safe_unicode
from kallithea.lib.vcs.utils.lazy import LazyProperty
diff --git a/kallithea/lib/vcs/backends/git/inmemory.py b/kallithea/lib/vcs/backends/git/inmemory.py
--- a/kallithea/lib/vcs/backends/git/inmemory.py
+++ b/kallithea/lib/vcs/backends/git/inmemory.py
@@ -1,8 +1,10 @@
-import time
import datetime
import posixpath
import stat
+import time
+
from dulwich import objects
+
from kallithea.lib.vcs.backends.base import BaseInMemoryChangeset
from kallithea.lib.vcs.exceptions import RepositoryError
from kallithea.lib.vcs.utils import safe_str
diff --git a/kallithea/lib/vcs/backends/git/repository.py b/kallithea/lib/vcs/backends/git/repository.py
--- a/kallithea/lib/vcs/backends/git/repository.py
+++ b/kallithea/lib/vcs/backends/git/repository.py
@@ -9,40 +9,35 @@
:copyright: (c) 2010-2011 by Marcin Kuzminski, Lukasz Balcerzak.
"""
+import errno
+import logging
import os
+import posixpath
import re
import time
-import errno
import urllib
import urllib2
-import logging
-import posixpath
from collections import OrderedDict
+from dulwich.config import ConfigFile
from dulwich.objects import Tag
-from dulwich.repo import Repo, NotGitRepository
-from dulwich.config import ConfigFile
+from dulwich.repo import NotGitRepository, Repo
from kallithea.lib.vcs import subprocessio
from kallithea.lib.vcs.backends.base import BaseRepository, CollectionGenerator
from kallithea.lib.vcs.conf import settings
-
from kallithea.lib.vcs.exceptions import (
- BranchDoesNotExistError, ChangesetDoesNotExistError, EmptyRepositoryError,
- RepositoryError, TagAlreadyExistError, TagDoesNotExistError
-)
-from kallithea.lib.vcs.utils import safe_str, safe_unicode, makedate, date_fromtimestamp
+ BranchDoesNotExistError, ChangesetDoesNotExistError, EmptyRepositoryError, RepositoryError, TagAlreadyExistError, TagDoesNotExistError)
+from kallithea.lib.vcs.utils import date_fromtimestamp, makedate, safe_str, safe_unicode
+from kallithea.lib.vcs.utils.hgcompat import hg_url, httpbasicauthhandler, httpdigestauthhandler
from kallithea.lib.vcs.utils.lazy import LazyProperty
from kallithea.lib.vcs.utils.paths import abspath, get_user_home
-from kallithea.lib.vcs.utils.hgcompat import (
- hg_url, httpbasicauthhandler, httpdigestauthhandler
-)
-
from .changeset import GitChangeset
from .inmemory import GitInMemoryChangeset
from .workdir import GitWorkdir
+
SHA_PATTERN = re.compile(r'^([0-9a-fA-F]{12}|[0-9a-fA-F]{40})$')
log = logging.getLogger(__name__)
diff --git a/kallithea/lib/vcs/backends/git/ssh.py b/kallithea/lib/vcs/backends/git/ssh.py
--- a/kallithea/lib/vcs/backends/git/ssh.py
+++ b/kallithea/lib/vcs/backends/git/ssh.py
@@ -12,12 +12,12 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
+import logging
import os
-import logging
from kallithea.lib.hooks import log_pull_action
from kallithea.lib.utils import make_ui
-from kallithea.lib.utils2 import safe_unicode, safe_str
+from kallithea.lib.utils2 import safe_str, safe_unicode
from kallithea.lib.vcs.backends.ssh import BaseSshHandler
diff --git a/kallithea/lib/vcs/backends/git/workdir.py b/kallithea/lib/vcs/backends/git/workdir.py
--- a/kallithea/lib/vcs/backends/git/workdir.py
+++ b/kallithea/lib/vcs/backends/git/workdir.py
@@ -1,7 +1,7 @@
import re
+
from kallithea.lib.vcs.backends.base import BaseWorkdir
-from kallithea.lib.vcs.exceptions import RepositoryError
-from kallithea.lib.vcs.exceptions import BranchDoesNotExistError
+from kallithea.lib.vcs.exceptions import BranchDoesNotExistError, RepositoryError
class GitWorkdir(BaseWorkdir):
diff --git a/kallithea/lib/vcs/backends/hg/__init__.py b/kallithea/lib/vcs/backends/hg/__init__.py
--- a/kallithea/lib/vcs/backends/hg/__init__.py
+++ b/kallithea/lib/vcs/backends/hg/__init__.py
@@ -9,9 +9,9 @@
:copyright: (c) 2010-2011 by Marcin Kuzminski, Lukasz Balcerzak.
"""
-from .repository import MercurialRepository
from .changeset import MercurialChangeset
from .inmemory import MercurialInMemoryChangeset
+from .repository import MercurialRepository
from .workdir import MercurialWorkdir
diff --git a/kallithea/lib/vcs/backends/hg/changeset.py b/kallithea/lib/vcs/backends/hg/changeset.py
--- a/kallithea/lib/vcs/backends/hg/changeset.py
+++ b/kallithea/lib/vcs/backends/hg/changeset.py
@@ -1,22 +1,17 @@
import os
import posixpath
-from kallithea.lib.vcs.conf import settings
+from mercurial import obsolete
+
from kallithea.lib.vcs.backends.base import BaseChangeset
-from kallithea.lib.vcs.exceptions import (
- ChangesetDoesNotExistError, ChangesetError, ImproperArchiveTypeError,
- NodeDoesNotExistError, VCSError
-)
+from kallithea.lib.vcs.conf import settings
+from kallithea.lib.vcs.exceptions import ChangesetDoesNotExistError, ChangesetError, ImproperArchiveTypeError, NodeDoesNotExistError, VCSError
from kallithea.lib.vcs.nodes import (
- AddedFileNodesGenerator, ChangedFileNodesGenerator, DirNode, FileNode,
- NodeKind, RemovedFileNodesGenerator, RootNode, SubModuleNode
-)
-from kallithea.lib.vcs.utils import safe_str, safe_unicode, date_fromtimestamp
+ AddedFileNodesGenerator, ChangedFileNodesGenerator, DirNode, FileNode, NodeKind, RemovedFileNodesGenerator, RootNode, SubModuleNode)
+from kallithea.lib.vcs.utils import date_fromtimestamp, safe_str, safe_unicode
+from kallithea.lib.vcs.utils.hgcompat import archival, hex, obsutil
from kallithea.lib.vcs.utils.lazy import LazyProperty
from kallithea.lib.vcs.utils.paths import get_dirs_for_path
-from kallithea.lib.vcs.utils.hgcompat import archival, hex, obsutil
-
-from mercurial import obsolete
class MercurialChangeset(BaseChangeset):
diff --git a/kallithea/lib/vcs/backends/hg/inmemory.py b/kallithea/lib/vcs/backends/hg/inmemory.py
--- a/kallithea/lib/vcs/backends/hg/inmemory.py
+++ b/kallithea/lib/vcs/backends/hg/inmemory.py
@@ -3,8 +3,7 @@ import errno
from kallithea.lib.vcs.backends.base import BaseInMemoryChangeset
from kallithea.lib.vcs.exceptions import RepositoryError
-
-from kallithea.lib.vcs.utils.hgcompat import memfilectx, memctx, hex, tolocal
+from kallithea.lib.vcs.utils.hgcompat import hex, memctx, memfilectx, tolocal
class MercurialInMemoryChangeset(BaseInMemoryChangeset):
diff --git a/kallithea/lib/vcs/backends/hg/repository.py b/kallithea/lib/vcs/backends/hg/repository.py
--- a/kallithea/lib/vcs/backends/hg/repository.py
+++ b/kallithea/lib/vcs/backends/hg/repository.py
@@ -9,34 +9,28 @@
:copyright: (c) 2010-2011 by Marcin Kuzminski, Lukasz Balcerzak.
"""
+import datetime
+import logging
import os
import time
import urllib
import urllib2
-import logging
-import datetime
from collections import OrderedDict
from kallithea.lib.vcs.backends.base import BaseRepository, CollectionGenerator
from kallithea.lib.vcs.exceptions import (
- BranchDoesNotExistError, ChangesetDoesNotExistError, EmptyRepositoryError,
- RepositoryError, VCSError, TagAlreadyExistError, TagDoesNotExistError
-)
-from kallithea.lib.vcs.utils import (
- author_email, author_name, date_fromtimestamp, makedate, safe_unicode, safe_str,
-)
+ BranchDoesNotExistError, ChangesetDoesNotExistError, EmptyRepositoryError, RepositoryError, TagAlreadyExistError, TagDoesNotExistError, VCSError)
+from kallithea.lib.vcs.utils import author_email, author_name, date_fromtimestamp, makedate, safe_str, safe_unicode
+from kallithea.lib.vcs.utils.hgcompat import (
+ Abort, RepoError, RepoLookupError, clone, diffopts, get_contact, hex, hg_url, httpbasicauthhandler, httpdigestauthhandler, httppeer, localrepo, match, match_exact, nullid, patch, peer, scmutil, sshpeer, tag, ui)
from kallithea.lib.vcs.utils.lazy import LazyProperty
from kallithea.lib.vcs.utils.paths import abspath
-from kallithea.lib.vcs.utils.hgcompat import (
- ui, nullid, match, match_exact, patch, diffopts, clone, get_contact,
- localrepo, RepoLookupError, Abort, RepoError, hex, scmutil, hg_url,
- httpbasicauthhandler, httpdigestauthhandler, peer, httppeer, sshpeer, tag
-)
from .changeset import MercurialChangeset
from .inmemory import MercurialInMemoryChangeset
from .workdir import MercurialWorkdir
+
log = logging.getLogger(__name__)
diff --git a/kallithea/lib/vcs/backends/hg/ssh.py b/kallithea/lib/vcs/backends/hg/ssh.py
--- a/kallithea/lib/vcs/backends/hg/ssh.py
+++ b/kallithea/lib/vcs/backends/hg/ssh.py
@@ -15,14 +15,17 @@
import logging
from mercurial import hg
+
+from kallithea.lib.utils import make_ui
+from kallithea.lib.utils2 import safe_str, safe_unicode
+from kallithea.lib.vcs.backends.ssh import BaseSshHandler
+
+
try:
from mercurial.wireprotoserver import sshserver
except ImportError:
from mercurial.sshserver import sshserver # moved in Mercurial 4.6 (1bf5263fe5cc)
-from kallithea.lib.utils import make_ui
-from kallithea.lib.utils2 import safe_unicode, safe_str
-from kallithea.lib.vcs.backends.ssh import BaseSshHandler
log = logging.getLogger(__name__)
diff --git a/kallithea/lib/vcs/backends/hg/workdir.py b/kallithea/lib/vcs/backends/hg/workdir.py
--- a/kallithea/lib/vcs/backends/hg/workdir.py
+++ b/kallithea/lib/vcs/backends/hg/workdir.py
@@ -1,6 +1,5 @@
from kallithea.lib.vcs.backends.base import BaseWorkdir
from kallithea.lib.vcs.exceptions import BranchDoesNotExistError
-
from kallithea.lib.vcs.utils.hgcompat import hg_merge
diff --git a/kallithea/lib/vcs/backends/ssh.py b/kallithea/lib/vcs/backends/ssh.py
--- a/kallithea/lib/vcs/backends/ssh.py
+++ b/kallithea/lib/vcs/backends/ssh.py
@@ -19,14 +19,14 @@ vcs.backends.ssh
SSH backend for all available SCMs
"""
-import sys
import datetime
import logging
+import sys
+from kallithea.lib.auth import AuthUser, HasPermissionAnyMiddleware
+from kallithea.lib.utils2 import safe_str, set_hook_environment
from kallithea.model.db import Repository, User, UserSshKeys
from kallithea.model.meta import Session
-from kallithea.lib.auth import HasPermissionAnyMiddleware, AuthUser
-from kallithea.lib.utils2 import safe_str, set_hook_environment
log = logging.getLogger(__name__)
diff --git a/kallithea/lib/vcs/conf/settings.py b/kallithea/lib/vcs/conf/settings.py
--- a/kallithea/lib/vcs/conf/settings.py
+++ b/kallithea/lib/vcs/conf/settings.py
@@ -1,8 +1,10 @@
import os
import tempfile
+
from kallithea.lib.vcs.utils import aslist
from kallithea.lib.vcs.utils.paths import get_user_home
+
abspath = lambda * p: os.path.abspath(os.path.join(*p))
VCSRC_PATH = os.environ.get('VCSRC_PATH')
diff --git a/kallithea/lib/vcs/nodes.py b/kallithea/lib/vcs/nodes.py
--- a/kallithea/lib/vcs/nodes.py
+++ b/kallithea/lib/vcs/nodes.py
@@ -9,14 +9,14 @@
:copyright: (c) 2010-2011 by Marcin Kuzminski, Lukasz Balcerzak.
"""
-import stat
+import mimetypes
import posixpath
-import mimetypes
+import stat
from kallithea.lib.vcs.backends.base import EmptyChangeset
from kallithea.lib.vcs.exceptions import NodeError, RemovedFileNodeError
+from kallithea.lib.vcs.utils import safe_str, safe_unicode
from kallithea.lib.vcs.utils.lazy import LazyProperty
-from kallithea.lib.vcs.utils import safe_unicode, safe_str
class NodeKind:
diff --git a/kallithea/lib/vcs/subprocessio.py b/kallithea/lib/vcs/subprocessio.py
--- a/kallithea/lib/vcs/subprocessio.py
+++ b/kallithea/lib/vcs/subprocessio.py
@@ -22,9 +22,9 @@ You should have received a copy of the G
along with git_http_backend.py Project.
If not, see .
"""
+import collections
import os
import subprocess
-import collections
import threading
diff --git a/kallithea/lib/vcs/utils/__init__.py b/kallithea/lib/vcs/utils/__init__.py
--- a/kallithea/lib/vcs/utils/__init__.py
+++ b/kallithea/lib/vcs/utils/__init__.py
@@ -3,9 +3,9 @@ This module provides some useful tools f
output. It also includes some internal helpers.
"""
-import time
import datetime
import re
+import time
def makedate():
diff --git a/kallithea/lib/vcs/utils/annotate.py b/kallithea/lib/vcs/utils/annotate.py
--- a/kallithea/lib/vcs/utils/annotate.py
+++ b/kallithea/lib/vcs/utils/annotate.py
@@ -1,7 +1,7 @@
import StringIO
+from pygments import highlight
from pygments.formatters import HtmlFormatter
-from pygments import highlight
from kallithea.lib.vcs.exceptions import VCSError
from kallithea.lib.vcs.nodes import FileNode
diff --git a/kallithea/lib/vcs/utils/helpers.py b/kallithea/lib/vcs/utils/helpers.py
--- a/kallithea/lib/vcs/utils/helpers.py
+++ b/kallithea/lib/vcs/utils/helpers.py
@@ -3,16 +3,16 @@ Utilities aimed to help achieve mostly b
"""
from __future__ import division
+import datetime
+import os
import re
-import os
import time
-import datetime
-from subprocess import Popen, PIPE
+from subprocess import PIPE, Popen
-from kallithea.lib.vcs.exceptions import VCSError
-from kallithea.lib.vcs.exceptions import RepositoryError
+from kallithea.lib.vcs.exceptions import RepositoryError, VCSError
from kallithea.lib.vcs.utils.paths import abspath
+
ALIASES = ['hg', 'git']
diff --git a/kallithea/lib/vcs/utils/hgcompat.py b/kallithea/lib/vcs/utils/hgcompat.py
--- a/kallithea/lib/vcs/utils/hgcompat.py
+++ b/kallithea/lib/vcs/utils/hgcompat.py
@@ -2,35 +2,33 @@
Mercurial libs compatibility
"""
+# Mercurial 5.0 550a172a603b renamed memfilectx argument `copied` to `copysource`
+import inspect
+
import mercurial
-from mercurial import demandimport
+from mercurial import archival, config, demandimport, discovery, httppeer, localrepo
+from mercurial import merge as hg_merge
+from mercurial import obsutil, patch, scmutil, sshpeer, ui, unionrepo
+from mercurial.commands import clone, nullid, pull
+from mercurial.context import memctx, memfilectx
+from mercurial.discovery import findcommonoutgoing
+from mercurial.encoding import tolocal
+from mercurial.error import Abort, RepoError, RepoLookupError
+from mercurial.hg import peer
+from mercurial.hgweb import hgweb_mod
+from mercurial.hgweb.common import get_contact
+from mercurial.match import exact as match_exact
+from mercurial.match import match
+from mercurial.mdiff import diffopts
+from mercurial.node import hex, nullrev
+from mercurial.scmutil import revrange
+from mercurial.tags import tag
+from mercurial.url import httpbasicauthhandler, httpdigestauthhandler
+from mercurial.util import url as hg_url
+
+
# patch demandimport, due to bug in mercurial when it always triggers demandimport.enable()
demandimport.enable = lambda *args, **kwargs: 1
-from mercurial import archival, merge as hg_merge, patch, ui
-from mercurial import discovery
-from mercurial import localrepo
-from mercurial import unionrepo
-from mercurial import scmutil
-from mercurial import config
-from mercurial.tags import tag
-from mercurial import httppeer
-from mercurial import sshpeer
-from mercurial import obsutil
-from mercurial.commands import clone, nullid, pull
-from mercurial.context import memctx, memfilectx
-from mercurial.error import RepoError, RepoLookupError, Abort
-from mercurial.hgweb import hgweb_mod
-from mercurial.hgweb.common import get_contact
-from mercurial.match import match, exact as match_exact
-from mercurial.mdiff import diffopts
-from mercurial.node import hex
-from mercurial.encoding import tolocal
-from mercurial.discovery import findcommonoutgoing
-from mercurial.hg import peer
-from mercurial.util import url as hg_url
-from mercurial.scmutil import revrange
-from mercurial.node import nullrev
-from mercurial.url import httpbasicauthhandler, httpdigestauthhandler
# workaround for 3.3 94ac64bcf6fe and not calling largefiles reposetup correctly
@@ -38,8 +36,6 @@ localrepo.localrepository._lfstatuswrite
# 3.5 7699d3212994 added the invariant that repo.lfstatus must exist before hitting overridearchive
localrepo.localrepository.lfstatus = False
-# Mercurial 5.0 550a172a603b renamed memfilectx argument `copied` to `copysource`
-import inspect
if inspect.getargspec(memfilectx.__init__).args[7] != 'copysource':
assert inspect.getargspec(memfilectx.__init__).args[7] == 'copied', inspect.getargspec(memfilectx.__init__).args
__org_memfilectx_ = memfilectx
diff --git a/kallithea/lib/vcs/utils/paths.py b/kallithea/lib/vcs/utils/paths.py
--- a/kallithea/lib/vcs/utils/paths.py
+++ b/kallithea/lib/vcs/utils/paths.py
@@ -1,5 +1,6 @@
import os
+
abspath = lambda * p: os.path.abspath(os.path.join(*p))
diff --git a/kallithea/lib/vcs/utils/progressbar.py b/kallithea/lib/vcs/utils/progressbar.py
--- a/kallithea/lib/vcs/utils/progressbar.py
+++ b/kallithea/lib/vcs/utils/progressbar.py
@@ -1,7 +1,7 @@
# encoding: UTF-8
-import sys
import datetime
import string
+import sys
from kallithea.lib.vcs.utils.filesize import filesizeformat
diff --git a/kallithea/model/api_key.py b/kallithea/model/api_key.py
--- a/kallithea/model/api_key.py
+++ b/kallithea/model/api_key.py
@@ -25,13 +25,14 @@ Original author and date, and relevant c
:license: GPLv3, see LICENSE.md for more details.
"""
+import logging
import time
-import logging
from kallithea.lib.utils2 import generate_api_key
from kallithea.model.db import User, UserApiKeys
from kallithea.model.meta import Session
+
log = logging.getLogger(__name__)
diff --git a/kallithea/model/base.py b/kallithea/model/base.py
--- a/kallithea/model/base.py
+++ b/kallithea/model/base.py
@@ -27,8 +27,10 @@ Original author and date, and relevant c
import logging
+
+from kallithea.lib.utils2 import obfuscate_url_pw
from kallithea.model import meta
-from kallithea.lib.utils2 import obfuscate_url_pw
+
log = logging.getLogger(__name__)
diff --git a/kallithea/model/changeset_status.py b/kallithea/model/changeset_status.py
--- a/kallithea/model/changeset_status.py
+++ b/kallithea/model/changeset_status.py
@@ -26,9 +26,11 @@ Original author and date, and relevant c
"""
import logging
+
from sqlalchemy.orm import joinedload
-from kallithea.model.db import ChangesetStatus, PullRequest, Repository, User, Session
+from kallithea.model.db import ChangesetStatus, PullRequest, Repository, Session, User
+
log = logging.getLogger(__name__)
diff --git a/kallithea/model/comment.py b/kallithea/model/comment.py
--- a/kallithea/model/comment.py
+++ b/kallithea/model/comment.py
@@ -26,16 +26,16 @@ Original author and date, and relevant c
"""
import logging
-
-from tg.i18n import ugettext as _
from collections import defaultdict
-from kallithea.lib.utils2 import extract_mentioned_users, safe_unicode
+from tg.i18n import ugettext as _
+
from kallithea.lib import helpers as h
-from kallithea.model.db import ChangesetComment, User, \
- PullRequest, Repository
+from kallithea.lib.utils2 import extract_mentioned_users, safe_unicode
+from kallithea.model.db import ChangesetComment, PullRequest, Repository, User
+from kallithea.model.meta import Session
from kallithea.model.notification import NotificationModel
-from kallithea.model.meta import Session
+
log = logging.getLogger(__name__)
diff --git a/kallithea/model/db.py b/kallithea/model/db.py
--- a/kallithea/model/db.py
+++ b/kallithea/model/db.py
@@ -25,40 +25,37 @@ Original author and date, and relevant c
:license: GPLv3, see LICENSE.md for more details.
"""
+import collections
+import datetime
+import functools
+import hashlib
+import logging
import os
import time
-import logging
-import datetime
import traceback
-import hashlib
-import collections
-import functools
-
+
+import ipaddr
import sqlalchemy
+from beaker.cache import cache_region, region_invalidate
from sqlalchemy import *
from sqlalchemy.ext.hybrid import hybrid_property
-from sqlalchemy.orm import relationship, joinedload, class_mapper, validates
-from beaker.cache import cache_region, region_invalidate
+from sqlalchemy.orm import class_mapper, joinedload, relationship, validates
+from tg.i18n import lazy_ugettext as _
from webob.exc import HTTPNotFound
-import ipaddr
-
-from tg.i18n import lazy_ugettext as _
import kallithea
+from kallithea.lib.caching_query import FromCache
+from kallithea.lib.compat import json
from kallithea.lib.exceptions import DefaultUserException
+from kallithea.lib.utils2 import (
+ Optional, aslist, get_changeset_safe, get_clone_url, remove_prefix, safe_int, safe_str, safe_unicode, str2bool, time_to_datetime, urlreadable)
from kallithea.lib.vcs import get_backend
+from kallithea.lib.vcs.backends.base import EmptyChangeset
from kallithea.lib.vcs.utils.helpers import get_scm
from kallithea.lib.vcs.utils.lazy import LazyProperty
-from kallithea.lib.vcs.backends.base import EmptyChangeset
-
-from kallithea.lib.utils2 import str2bool, safe_str, get_changeset_safe, \
- safe_unicode, remove_prefix, time_to_datetime, aslist, Optional, safe_int, \
- get_clone_url, urlreadable
-from kallithea.lib.compat import json
-from kallithea.lib.caching_query import FromCache
-
from kallithea.model.meta import Base, Session
+
URL_SEP = '/'
log = logging.getLogger(__name__)
diff --git a/kallithea/model/forms.py b/kallithea/model/forms.py
--- a/kallithea/model/forms.py
+++ b/kallithea/model/forms.py
@@ -37,12 +37,12 @@ import logging
import formencode
from formencode import All
-
from tg.i18n import ugettext as _
from kallithea import BACKENDS
from kallithea.model import validators as v
+
log = logging.getLogger(__name__)
diff --git a/kallithea/model/gist.py b/kallithea/model/gist.py
--- a/kallithea/model/gist.py
+++ b/kallithea/model/gist.py
@@ -25,20 +25,20 @@ Original author and date, and relevant c
:license: GPLv3, see LICENSE.md for more details.
"""
+import logging
import os
import random
+import shutil
import time
-import logging
import traceback
-import shutil
-from kallithea.lib.utils2 import safe_unicode, safe_int, \
- time_to_datetime, AttributeDict
from kallithea.lib.compat import json
+from kallithea.lib.utils2 import AttributeDict, safe_int, safe_unicode, time_to_datetime
from kallithea.model.db import Gist, Session, User
from kallithea.model.repo import RepoModel
from kallithea.model.scm import ScmModel
+
log = logging.getLogger(__name__)
GIST_STORE_LOC = '.rc_gist_store'
diff --git a/kallithea/model/meta.py b/kallithea/model/meta.py
--- a/kallithea/model/meta.py
+++ b/kallithea/model/meta.py
@@ -14,9 +14,9 @@
"""
SQLAlchemy Metadata and Session object
"""
+from beaker import cache
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import scoped_session, sessionmaker
-from beaker import cache
from kallithea.lib import caching_query
diff --git a/kallithea/model/notification.py b/kallithea/model/notification.py
--- a/kallithea/model/notification.py
+++ b/kallithea/model/notification.py
@@ -30,9 +30,10 @@ import datetime
import logging
import traceback
-from tg import tmpl_context as c, app_globals
+from sqlalchemy.orm import joinedload, subqueryload
+from tg import app_globals
+from tg import tmpl_context as c
from tg.i18n import ugettext as _
-from sqlalchemy.orm import joinedload, subqueryload
import kallithea
from kallithea.lib import helpers as h
@@ -40,6 +41,7 @@ from kallithea.lib.utils2 import safe_un
from kallithea.model.db import User
from kallithea.model.meta import Session
+
log = logging.getLogger(__name__)
diff --git a/kallithea/model/permission.py b/kallithea/model/permission.py
--- a/kallithea/model/permission.py
+++ b/kallithea/model/permission.py
@@ -31,9 +31,9 @@ import traceback
from sqlalchemy.exc import DatabaseError
-from kallithea.model.db import Permission, Session, User, \
- UserToPerm, UserRepoToPerm, UserRepoGroupToPerm, UserUserGroupToPerm
from kallithea.lib.utils2 import str2bool
+from kallithea.model.db import Permission, Session, User, UserRepoGroupToPerm, UserRepoToPerm, UserToPerm, UserUserGroupToPerm
+
log = logging.getLogger(__name__)
diff --git a/kallithea/model/pull_request.py b/kallithea/model/pull_request.py
--- a/kallithea/model/pull_request.py
+++ b/kallithea/model/pull_request.py
@@ -25,21 +25,19 @@ Original author and date, and relevant c
:license: GPLv3, see LICENSE.md for more details.
"""
+import datetime
import logging
-import datetime
import re
+from sqlalchemy.orm import joinedload
from tg import request
from tg.i18n import ugettext as _
-from sqlalchemy.orm import joinedload
-
+from kallithea.lib import helpers as h
+from kallithea.lib.utils2 import extract_mentioned_users, safe_str, safe_unicode
+from kallithea.model.db import ChangesetStatus, PullRequest, PullRequestReviewer, User
from kallithea.model.meta import Session
-from kallithea.lib import helpers as h
-from kallithea.model.db import PullRequest, PullRequestReviewer, \
- ChangesetStatus, User
from kallithea.model.notification import NotificationModel
-from kallithea.lib.utils2 import extract_mentioned_users, safe_str, safe_unicode
log = logging.getLogger(__name__)
diff --git a/kallithea/model/repo.py b/kallithea/model/repo.py
--- a/kallithea/model/repo.py
+++ b/kallithea/model/repo.py
@@ -26,30 +26,28 @@ Original author and date, and relevant c
"""
+import logging
import os
import shutil
-import logging
import traceback
from datetime import datetime
+
from sqlalchemy.orm import subqueryload
import kallithea.lib.utils2
-from kallithea.lib.utils import make_ui, is_valid_repo_uri
-from kallithea.lib.vcs.backends import get_backend
-from kallithea.lib.utils2 import LazyProperty, safe_str, safe_unicode, \
- remove_prefix, obfuscate_url_pw, get_current_authuser
-from kallithea.lib.caching_query import FromCache
-from kallithea.lib.hooks import log_delete_repository
-
-from kallithea.model.db import Repository, UserRepoToPerm, UserGroupRepoToPerm, \
- UserRepoGroupToPerm, UserGroupRepoGroupToPerm, User, Permission, Session, \
- Statistics, UserGroup, Ui, RepoGroup, RepositoryField
-
from kallithea.lib import helpers as h
from kallithea.lib.auth import HasRepoPermissionLevel, HasUserGroupPermissionLevel
+from kallithea.lib.caching_query import FromCache
from kallithea.lib.exceptions import AttachedForksError
+from kallithea.lib.hooks import log_delete_repository
+from kallithea.lib.utils import is_valid_repo_uri, make_ui
+from kallithea.lib.utils2 import LazyProperty, get_current_authuser, obfuscate_url_pw, remove_prefix, safe_str, safe_unicode
+from kallithea.lib.vcs.backends import get_backend
+from kallithea.model.db import (
+ Permission, RepoGroup, Repository, RepositoryField, Session, Statistics, Ui, User, UserGroup, UserGroupRepoGroupToPerm, UserGroupRepoToPerm, UserRepoGroupToPerm, UserRepoToPerm)
from kallithea.model.scm import UserGroupList
+
log = logging.getLogger(__name__)
diff --git a/kallithea/model/repo_group.py b/kallithea/model/repo_group.py
--- a/kallithea/model/repo_group.py
+++ b/kallithea/model/repo_group.py
@@ -26,17 +26,16 @@ Original author and date, and relevant c
"""
+import datetime
+import logging
import os
-import logging
+import shutil
import traceback
-import shutil
-import datetime
import kallithea.lib.utils2
from kallithea.lib.utils2 import LazyProperty
+from kallithea.model.db import Permission, RepoGroup, Repository, Session, Ui, User, UserGroup, UserGroupRepoGroupToPerm, UserRepoGroupToPerm
-from kallithea.model.db import RepoGroup, Session, Ui, UserRepoGroupToPerm, \
- User, Permission, UserGroupRepoGroupToPerm, UserGroup, Repository
log = logging.getLogger(__name__)
diff --git a/kallithea/model/repo_permission.py b/kallithea/model/repo_permission.py
--- a/kallithea/model/repo_permission.py
+++ b/kallithea/model/repo_permission.py
@@ -24,8 +24,9 @@ Original author and date, and relevant c
"""
import logging
-from kallithea.model.db import User, UserRepoToPerm, UserGroupRepoToPerm, \
- Permission, Repository, Session
+
+from kallithea.model.db import Permission, Repository, Session, User, UserGroupRepoToPerm, UserRepoToPerm
+
log = logging.getLogger(__name__)
diff --git a/kallithea/model/scm.py b/kallithea/model/scm.py
--- a/kallithea/model/scm.py
+++ b/kallithea/model/scm.py
@@ -25,37 +25,34 @@ Original author and date, and relevant c
:license: GPLv3, see LICENSE.md for more details.
"""
+import cStringIO
+import logging
import os
-import sys
import posixpath
import re
+import sys
import time
import traceback
-import logging
-import cStringIO
+
import pkg_resources
-
from sqlalchemy import func
from tg.i18n import ugettext as _
import kallithea
-from kallithea.lib.vcs import get_backend
-from kallithea.lib.vcs.exceptions import RepositoryError
-from kallithea.lib.vcs.utils.lazy import LazyProperty
-from kallithea.lib.vcs.nodes import FileNode
-from kallithea.lib.vcs.backends.base import EmptyChangeset
-
from kallithea import BACKENDS
from kallithea.lib import helpers as h
+from kallithea.lib.auth import HasPermissionAny, HasRepoGroupPermissionLevel, HasRepoPermissionLevel, HasUserGroupPermissionLevel
+from kallithea.lib.exceptions import IMCCommitError, NonRelativePathError
+from kallithea.lib.hooks import process_pushed_raw_ids
+from kallithea.lib.utils import action_logger, get_filesystem_repos, make_ui
from kallithea.lib.utils2 import safe_str, safe_unicode, set_hook_environment
-from kallithea.lib.auth import HasRepoPermissionLevel, HasRepoGroupPermissionLevel, \
- HasUserGroupPermissionLevel, HasPermissionAny, HasPermissionAny
-from kallithea.lib.utils import get_filesystem_repos, make_ui, \
- action_logger
-from kallithea.model.db import Repository, Session, Ui, CacheInvalidation, \
- UserFollowing, UserLog, User, RepoGroup, PullRequest
-from kallithea.lib.hooks import process_pushed_raw_ids
-from kallithea.lib.exceptions import NonRelativePathError, IMCCommitError
+from kallithea.lib.vcs import get_backend
+from kallithea.lib.vcs.backends.base import EmptyChangeset
+from kallithea.lib.vcs.exceptions import RepositoryError
+from kallithea.lib.vcs.nodes import FileNode
+from kallithea.lib.vcs.utils.lazy import LazyProperty
+from kallithea.model.db import CacheInvalidation, PullRequest, RepoGroup, Repository, Session, Ui, User, UserFollowing, UserLog
+
log = logging.getLogger(__name__)
diff --git a/kallithea/model/ssh_key.py b/kallithea/model/ssh_key.py
--- a/kallithea/model/ssh_key.py
+++ b/kallithea/model/ssh_key.py
@@ -19,19 +19,20 @@ SSH key model for Kallithea
"""
+import errno
import logging
import os
import stat
import tempfile
-import errno
from tg import config
from tg.i18n import ugettext as _
+from kallithea.lib import ssh
from kallithea.lib.utils2 import safe_str, str2bool
-from kallithea.model.db import UserSshKeys, User
+from kallithea.model.db import User, UserSshKeys
from kallithea.model.meta import Session
-from kallithea.lib import ssh
+
log = logging.getLogger(__name__)
diff --git a/kallithea/model/user.py b/kallithea/model/user.py
--- a/kallithea/model/user.py
+++ b/kallithea/model/user.py
@@ -32,17 +32,14 @@ import logging
import time
import traceback
+from sqlalchemy.exc import DatabaseError
from tg import config
from tg.i18n import ugettext as _
-from sqlalchemy.exc import DatabaseError
-
-from kallithea.lib.utils2 import safe_str, generate_api_key, get_current_authuser
from kallithea.lib.caching_query import FromCache
-from kallithea.model.db import Permission, User, UserToPerm, \
- UserEmailMap, UserIpMap
-from kallithea.lib.exceptions import DefaultUserException, \
- UserOwnsReposException
+from kallithea.lib.exceptions import DefaultUserException, UserOwnsReposException
+from kallithea.lib.utils2 import generate_api_key, get_current_authuser, safe_str
+from kallithea.model.db import Permission, User, UserEmailMap, UserIpMap, UserToPerm
from kallithea.model.meta import Session
diff --git a/kallithea/model/user_group.py b/kallithea/model/user_group.py
--- a/kallithea/model/user_group.py
+++ b/kallithea/model/user_group.py
@@ -27,11 +27,10 @@ Original author and date, and relevant c
import logging
import traceback
-from kallithea.model.db import Session, UserGroupMember, UserGroup, \
- UserGroupRepoToPerm, Permission, UserGroupToPerm, User, UserUserGroupToPerm, \
- UserGroupUserGroupToPerm
-from kallithea.lib.exceptions import UserGroupsAssignedException, \
- RepoGroupAssignmentError
+from kallithea.lib.exceptions import RepoGroupAssignmentError, UserGroupsAssignedException
+from kallithea.model.db import (
+ Permission, Session, User, UserGroup, UserGroupMember, UserGroupRepoToPerm, UserGroupToPerm, UserGroupUserGroupToPerm, UserUserGroupToPerm)
+
log = logging.getLogger(__name__)
diff --git a/kallithea/model/validators.py b/kallithea/model/validators.py
--- a/kallithea/model/validators.py
+++ b/kallithea/model/validators.py
@@ -15,28 +15,26 @@
Set of generic validators
"""
+import logging
import os
import re
-import formencode
-import logging
from collections import defaultdict
-from tg.i18n import ugettext as _
+import formencode
+import ipaddr
+import sqlalchemy
+from formencode.validators import CIDR, Bool, Email, FancyValidator, Int, IPAddress, NotEmpty, Number, OneOf, Regex, Set, String, StringBoolean, UnicodeString
from sqlalchemy import func
-import sqlalchemy
-import ipaddr
+from tg.i18n import ugettext as _
-from formencode.validators import (
- UnicodeString, OneOf, Int, Number, Regex, Email, Bool, StringBoolean, Set,
- NotEmpty, IPAddress, CIDR, String, FancyValidator
-)
+from kallithea.config.routing import ADMIN_PREFIX
+from kallithea.lib.auth import HasPermissionAny, HasRepoGroupPermissionLevel
from kallithea.lib.compat import OrderedSet
+from kallithea.lib.exceptions import LdapImportError
from kallithea.lib.utils import is_valid_repo_uri
-from kallithea.lib.utils2 import str2bool, aslist, repo_name_slug
-from kallithea.model.db import RepoGroup, Repository, UserGroup, User
-from kallithea.lib.exceptions import LdapImportError
-from kallithea.config.routing import ADMIN_PREFIX
-from kallithea.lib.auth import HasRepoGroupPermissionLevel, HasPermissionAny
+from kallithea.lib.utils2 import aslist, repo_name_slug, str2bool
+from kallithea.model.db import RepoGroup, Repository, User, UserGroup
+
# silence warnings and pylint
UnicodeString, OneOf, Int, Number, Regex, Email, Bool, StringBoolean, Set, \
diff --git a/kallithea/tests/__init__.py b/kallithea/tests/__init__.py
--- a/kallithea/tests/__init__.py
+++ b/kallithea/tests/__init__.py
@@ -20,6 +20,7 @@ Refer to docs/contributing.rst for detai
import pytest
+
if getattr(pytest, 'register_assert_rewrite', None):
# make sure that all asserts under kallithea/tests benefit from advanced
# assert reporting with pytest-3.0.0+, including api/api_base.py,
diff --git a/kallithea/tests/api/api_base.py b/kallithea/tests/api/api_base.py
--- a/kallithea/tests/api/api_base.py
+++ b/kallithea/tests/api/api_base.py
@@ -18,25 +18,25 @@ Tests for the JSON-RPC web api.
import os
import random
-import mock
import re
+import mock
import pytest
+from kallithea.lib.auth import AuthUser
+from kallithea.lib.compat import json
+from kallithea.lib.utils2 import time_to_datetime
+from kallithea.model.changeset_status import ChangesetStatusModel
+from kallithea.model.db import ChangesetStatus, PullRequest, RepoGroup, Repository, Setting, Ui, User
+from kallithea.model.gist import GistModel
+from kallithea.model.meta import Session
+from kallithea.model.repo import RepoModel
+from kallithea.model.repo_group import RepoGroupModel
+from kallithea.model.scm import ScmModel
+from kallithea.model.user import UserModel
+from kallithea.model.user_group import UserGroupModel
from kallithea.tests.base import *
from kallithea.tests.fixture import Fixture
-from kallithea.lib.compat import json
-from kallithea.lib.auth import AuthUser
-from kallithea.model.user import UserModel
-from kallithea.model.user_group import UserGroupModel
-from kallithea.model.repo import RepoModel
-from kallithea.model.repo_group import RepoGroupModel
-from kallithea.model.meta import Session
-from kallithea.model.scm import ScmModel
-from kallithea.model.gist import GistModel
-from kallithea.model.changeset_status import ChangesetStatusModel
-from kallithea.model.db import Repository, User, Setting, Ui, PullRequest, ChangesetStatus, RepoGroup
-from kallithea.lib.utils2 import time_to_datetime
API_URL = '/_admin/api'
diff --git a/kallithea/tests/api/test_api_git.py b/kallithea/tests/api/test_api_git.py
--- a/kallithea/tests/api/test_api_git.py
+++ b/kallithea/tests/api/test_api_git.py
@@ -12,8 +12,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-from kallithea.tests.base import TestController, GIT_REPO, GIT_TEST_REVISION
from kallithea.tests.api.api_base import _BaseTestApi
+from kallithea.tests.base import GIT_REPO, GIT_TEST_REVISION, TestController
class TestGitApi(_BaseTestApi, TestController):
diff --git a/kallithea/tests/api/test_api_hg.py b/kallithea/tests/api/test_api_hg.py
--- a/kallithea/tests/api/test_api_hg.py
+++ b/kallithea/tests/api/test_api_hg.py
@@ -12,8 +12,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-from kallithea.tests.base import TestController, HG_REPO, HG_TEST_REVISION
from kallithea.tests.api.api_base import _BaseTestApi
+from kallithea.tests.base import HG_REPO, HG_TEST_REVISION, TestController
class TestHgApi(_BaseTestApi, TestController):
diff --git a/kallithea/tests/base.py b/kallithea/tests/base.py
--- a/kallithea/tests/base.py
+++ b/kallithea/tests/base.py
@@ -15,18 +15,18 @@
import datetime
import logging
import os
-import pytest
import re
import tempfile
import time
+import pytest
from tg import config
from webtest import TestApp
from kallithea import model
+from kallithea.lib.utils2 import safe_str
from kallithea.model.db import User
from kallithea.model.meta import Session
-from kallithea.lib.utils2 import safe_str
log = logging.getLogger(__name__)
diff --git a/kallithea/tests/conftest.py b/kallithea/tests/conftest.py
--- a/kallithea/tests/conftest.py
+++ b/kallithea/tests/conftest.py
@@ -1,28 +1,26 @@
+import logging
import os
import re
import sys
-import logging
-import pkg_resources
import time
import formencode
-from paste.deploy import loadwsgi
-from routes.util import URLGenerator
+import pkg_resources
import pytest
+from paste.deploy import loadwsgi
from pytest_localserver.http import WSGIServer
+from routes.util import URLGenerator
+from tg.util.webtest import test_context
+import kallithea.tests.base # FIXME: needed for setting testapp instance!!!
from kallithea.controllers.root import RootController
from kallithea.lib import inifile
from kallithea.lib.utils import repo2db_mapper
-from kallithea.model.user import UserModel
+from kallithea.model.db import Setting, User, UserIpMap
from kallithea.model.meta import Session
-from kallithea.model.db import Setting, User, UserIpMap
from kallithea.model.scm import ScmModel
-from kallithea.tests.base import invalidate_all_caches, TEST_USER_REGULAR_LOGIN, TESTS_TMP_PATH, \
- TEST_USER_ADMIN_LOGIN, TEST_USER_ADMIN_PASS
-import kallithea.tests.base # FIXME: needed for setting testapp instance!!!
-
-from tg.util.webtest import test_context
+from kallithea.model.user import UserModel
+from kallithea.tests.base import TEST_USER_ADMIN_LOGIN, TEST_USER_ADMIN_PASS, TEST_USER_REGULAR_LOGIN, TESTS_TMP_PATH, invalidate_all_caches
def pytest_configure():
diff --git a/kallithea/tests/fixture.py b/kallithea/tests/fixture.py
--- a/kallithea/tests/fixture.py
+++ b/kallithea/tests/fixture.py
@@ -26,23 +26,23 @@ import mock
from tg import request
from tg.util.webtest import test_context
-from kallithea.model.db import Repository, User, RepoGroup, UserGroup, Gist, ChangesetStatus
-from kallithea.model.meta import Session
-from kallithea.model.repo import RepoModel
-from kallithea.model.user import UserModel
-from kallithea.model.repo_group import RepoGroupModel
-from kallithea.model.user_group import UserGroupModel
-from kallithea.model.gist import GistModel
-from kallithea.model.scm import ScmModel
-from kallithea.model.comment import ChangesetCommentsModel
-from kallithea.model.changeset_status import ChangesetStatusModel
-from kallithea.model.pull_request import CreatePullRequestAction#, CreatePullRequestIterationAction, PullRequestModel
from kallithea.lib import helpers
from kallithea.lib.auth import AuthUser
from kallithea.lib.db_manage import DbManage
from kallithea.lib.vcs.backends.base import EmptyChangeset
-from kallithea.tests.base import invalidate_all_caches, GIT_REPO, HG_REPO, \
- TESTS_TMP_PATH, TEST_USER_ADMIN_LOGIN, TEST_USER_REGULAR_LOGIN, TEST_USER_ADMIN_EMAIL, IP_ADDR
+from kallithea.model.changeset_status import ChangesetStatusModel
+from kallithea.model.comment import ChangesetCommentsModel
+from kallithea.model.db import ChangesetStatus, Gist, RepoGroup, Repository, User, UserGroup
+from kallithea.model.gist import GistModel
+from kallithea.model.meta import Session
+from kallithea.model.pull_request import CreatePullRequestAction # , CreatePullRequestIterationAction, PullRequestModel
+from kallithea.model.repo import RepoModel
+from kallithea.model.repo_group import RepoGroupModel
+from kallithea.model.scm import ScmModel
+from kallithea.model.user import UserModel
+from kallithea.model.user_group import UserGroupModel
+from kallithea.tests.base import (
+ GIT_REPO, HG_REPO, IP_ADDR, TEST_USER_ADMIN_EMAIL, TEST_USER_ADMIN_LOGIN, TEST_USER_REGULAR_LOGIN, TESTS_TMP_PATH, invalidate_all_caches)
log = logging.getLogger(__name__)
diff --git a/kallithea/tests/functional/test_admin.py b/kallithea/tests/functional/test_admin.py
--- a/kallithea/tests/functional/test_admin.py
+++ b/kallithea/tests/functional/test_admin.py
@@ -1,11 +1,13 @@
-import os
import csv
import datetime
-from kallithea.tests.base import *
+import os
+from os.path import dirname
+
+from kallithea.lib.utils2 import safe_unicode
from kallithea.model.db import UserLog
from kallithea.model.meta import Session
-from kallithea.lib.utils2 import safe_unicode
-from os.path import dirname
+from kallithea.tests.base import *
+
FIXTURES = os.path.join(dirname(dirname(os.path.abspath(__file__))), 'fixtures')
diff --git a/kallithea/tests/functional/test_admin_auth_settings.py b/kallithea/tests/functional/test_admin_auth_settings.py
--- a/kallithea/tests/functional/test_admin_auth_settings.py
+++ b/kallithea/tests/functional/test_admin_auth_settings.py
@@ -1,5 +1,5 @@
+from kallithea.model.db import Setting
from kallithea.tests.base import *
-from kallithea.model.db import Setting
class TestAuthSettingsController(TestController):
diff --git a/kallithea/tests/functional/test_admin_defaults.py b/kallithea/tests/functional/test_admin_defaults.py
--- a/kallithea/tests/functional/test_admin_defaults.py
+++ b/kallithea/tests/functional/test_admin_defaults.py
@@ -1,5 +1,5 @@
+from kallithea.model.db import Setting
from kallithea.tests.base import *
-from kallithea.model.db import Setting
class TestDefaultsController(TestController):
diff --git a/kallithea/tests/functional/test_admin_gists.py b/kallithea/tests/functional/test_admin_gists.py
--- a/kallithea/tests/functional/test_admin_gists.py
+++ b/kallithea/tests/functional/test_admin_gists.py
@@ -1,7 +1,7 @@
-from kallithea.tests.base import *
+from kallithea.model.db import Gist, User
from kallithea.model.gist import GistModel
from kallithea.model.meta import Session
-from kallithea.model.db import User, Gist
+from kallithea.tests.base import *
def _create_gist(f_name, content='some gist', lifetime=-1,
diff --git a/kallithea/tests/functional/test_admin_permissions.py b/kallithea/tests/functional/test_admin_permissions.py
--- a/kallithea/tests/functional/test_admin_permissions.py
+++ b/kallithea/tests/functional/test_admin_permissions.py
@@ -1,12 +1,12 @@
import time
+from tg.util.webtest import test_context
+
from kallithea.model.db import User, UserIpMap
+from kallithea.model.meta import Session
from kallithea.model.user import UserModel
-from kallithea.model.meta import Session
from kallithea.tests.base import *
-from tg.util.webtest import test_context
-
class TestAdminPermissionsController(TestController):
diff --git a/kallithea/tests/functional/test_admin_repos.py b/kallithea/tests/functional/test_admin_repos.py
--- a/kallithea/tests/functional/test_admin_repos.py
+++ b/kallithea/tests/functional/test_admin_repos.py
@@ -1,23 +1,23 @@
# -*- coding: utf-8 -*-
import os
-import mock
import urllib
+import mock
import pytest
from sqlalchemy import func
from kallithea.lib import vcs
from kallithea.lib.utils2 import safe_str, safe_unicode
-from kallithea.model.db import Repository, RepoGroup, UserRepoToPerm, User, \
- Permission, Ui
+from kallithea.model.db import Permission, RepoGroup, Repository, Ui, User, UserRepoToPerm
+from kallithea.model.meta import Base, Session
+from kallithea.model.repo import RepoModel
+from kallithea.model.repo_group import RepoGroupModel
from kallithea.model.user import UserModel
from kallithea.tests.base import *
-from kallithea.model.repo_group import RepoGroupModel
-from kallithea.model.repo import RepoModel
-from kallithea.model.meta import Session, Base
from kallithea.tests.fixture import Fixture, error_function
+
fixture = Fixture()
diff --git a/kallithea/tests/functional/test_admin_settings.py b/kallithea/tests/functional/test_admin_settings.py
--- a/kallithea/tests/functional/test_admin_settings.py
+++ b/kallithea/tests/functional/test_admin_settings.py
@@ -4,6 +4,7 @@ from kallithea.model.db import Setting,
from kallithea.tests.base import *
from kallithea.tests.fixture import Fixture
+
fixture = Fixture()
diff --git a/kallithea/tests/functional/test_admin_user_groups.py b/kallithea/tests/functional/test_admin_user_groups.py
--- a/kallithea/tests/functional/test_admin_user_groups.py
+++ b/kallithea/tests/functional/test_admin_user_groups.py
@@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-
+from kallithea.model.db import Permission, UserGroup, UserGroupToPerm
+from kallithea.model.meta import Session
from kallithea.tests.base import *
-from kallithea.model.db import UserGroup, UserGroupToPerm, Permission
-from kallithea.model.meta import Session
+
TEST_USER_GROUP = u'admins_test'
diff --git a/kallithea/tests/functional/test_admin_users.py b/kallithea/tests/functional/test_admin_users.py
--- a/kallithea/tests/functional/test_admin_users.py
+++ b/kallithea/tests/functional/test_admin_users.py
@@ -12,21 +12,21 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
+import pytest
from sqlalchemy.orm.exc import NoResultFound, ObjectDeletedError
+from tg.util.webtest import test_context
+from webob.exc import HTTPNotFound
-import pytest
+from kallithea.controllers.admin.users import UsersController
+from kallithea.lib import helpers as h
+from kallithea.lib.auth import check_password
+from kallithea.model import validators
+from kallithea.model.db import Permission, RepoGroup, User, UserApiKeys, UserIpMap, UserSshKeys
+from kallithea.model.meta import Session
+from kallithea.model.user import UserModel
from kallithea.tests.base import *
from kallithea.tests.fixture import Fixture
-from kallithea.controllers.admin.users import UsersController
-from kallithea.model.db import User, Permission, UserIpMap, UserApiKeys, RepoGroup, UserSshKeys
-from kallithea.lib.auth import check_password
-from kallithea.model.user import UserModel
-from kallithea.model import validators
-from kallithea.lib import helpers as h
-from kallithea.model.meta import Session
-from webob.exc import HTTPNotFound
-from tg.util.webtest import test_context
fixture = Fixture()
diff --git a/kallithea/tests/functional/test_changeset.py b/kallithea/tests/functional/test_changeset.py
--- a/kallithea/tests/functional/test_changeset.py
+++ b/kallithea/tests/functional/test_changeset.py
@@ -1,5 +1,6 @@
from kallithea.tests.base import *
+
class TestChangesetController(TestController):
def test_index(self):
diff --git a/kallithea/tests/functional/test_changeset_pullrequests_comments.py b/kallithea/tests/functional/test_changeset_pullrequests_comments.py
--- a/kallithea/tests/functional/test_changeset_pullrequests_comments.py
+++ b/kallithea/tests/functional/test_changeset_pullrequests_comments.py
@@ -1,9 +1,9 @@
import re
-from kallithea.tests.base import *
from kallithea.model.changeset_status import ChangesetStatusModel
from kallithea.model.db import ChangesetComment, PullRequest
from kallithea.model.meta import Session
+from kallithea.tests.base import *
class TestChangeSetCommentsController(TestController):
diff --git a/kallithea/tests/functional/test_compare.py b/kallithea/tests/functional/test_compare.py
--- a/kallithea/tests/functional/test_compare.py
+++ b/kallithea/tests/functional/test_compare.py
@@ -1,9 +1,10 @@
# -*- coding: utf-8 -*-
-from kallithea.tests.base import *
+from kallithea.model.meta import Session
from kallithea.model.repo import RepoModel
-from kallithea.model.meta import Session
+from kallithea.tests.base import *
from kallithea.tests.fixture import Fixture
+
fixture = Fixture()
diff --git a/kallithea/tests/functional/test_compare_local.py b/kallithea/tests/functional/test_compare_local.py
--- a/kallithea/tests/functional/test_compare_local.py
+++ b/kallithea/tests/functional/test_compare_local.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from kallithea.tests.base import *
+
class TestCompareController(TestController):
def test_compare_tag_hg(self):
diff --git a/kallithea/tests/functional/test_feed.py b/kallithea/tests/functional/test_feed.py
--- a/kallithea/tests/functional/test_feed.py
+++ b/kallithea/tests/functional/test_feed.py
@@ -1,5 +1,6 @@
from kallithea.tests.base import *
+
class TestFeedController(TestController):
def test_rss(self):
diff --git a/kallithea/tests/functional/test_files.py b/kallithea/tests/functional/test_files.py
--- a/kallithea/tests/functional/test_files.py
+++ b/kallithea/tests/functional/test_files.py
@@ -1,12 +1,14 @@
# -*- coding: utf-8 -*-
+import mimetypes
import os
import posixpath
-import mimetypes
-from kallithea.tests.base import *
+
from kallithea.model.db import Repository
from kallithea.model.meta import Session
+from kallithea.tests.base import *
from kallithea.tests.fixture import Fixture
+
fixture = Fixture()
ARCHIVE_SPECS = {
diff --git a/kallithea/tests/functional/test_forks.py b/kallithea/tests/functional/test_forks.py
--- a/kallithea/tests/functional/test_forks.py
+++ b/kallithea/tests/functional/test_forks.py
@@ -1,16 +1,16 @@
# -*- coding: utf-8 -*-
+import unittest
import urllib
-import unittest
+from kallithea.lib.utils2 import safe_str, safe_unicode
+from kallithea.model.db import Repository, User
+from kallithea.model.meta import Session
+from kallithea.model.repo import RepoModel
+from kallithea.model.user import UserModel
from kallithea.tests.base import *
from kallithea.tests.fixture import Fixture
-from kallithea.lib.utils2 import safe_str, safe_unicode
-from kallithea.model.db import Repository, User
-from kallithea.model.repo import RepoModel
-from kallithea.model.user import UserModel
-from kallithea.model.meta import Session
fixture = Fixture()
diff --git a/kallithea/tests/functional/test_home.py b/kallithea/tests/functional/test_home.py
--- a/kallithea/tests/functional/test_home.py
+++ b/kallithea/tests/functional/test_home.py
@@ -1,12 +1,12 @@
# -*- coding: utf-8 -*-
import json
+from kallithea.model.db import Repository
+from kallithea.model.meta import Session
+from kallithea.model.repo import RepoModel
+from kallithea.model.repo_group import RepoGroupModel
from kallithea.tests.base import *
from kallithea.tests.fixture import Fixture
-from kallithea.model.meta import Session
-from kallithea.model.db import Repository
-from kallithea.model.repo import RepoModel
-from kallithea.model.repo_group import RepoGroupModel
fixture = Fixture()
diff --git a/kallithea/tests/functional/test_journal.py b/kallithea/tests/functional/test_journal.py
--- a/kallithea/tests/functional/test_journal.py
+++ b/kallithea/tests/functional/test_journal.py
@@ -1,5 +1,6 @@
+import datetime
+
from kallithea.tests.base import *
-import datetime
class TestJournalController(TestController):
diff --git a/kallithea/tests/functional/test_login.py b/kallithea/tests/functional/test_login.py
--- a/kallithea/tests/functional/test_login.py
+++ b/kallithea/tests/functional/test_login.py
@@ -4,19 +4,19 @@ import time
import urlparse
import mock
+from tg.util.webtest import test_context
-from kallithea.tests.base import *
-from kallithea.tests.fixture import Fixture
+from kallithea.lib import helpers as h
+from kallithea.lib.auth import check_password
from kallithea.lib.utils2 import generate_api_key
-from kallithea.lib.auth import check_password
-from kallithea.lib import helpers as h
+from kallithea.model import validators
from kallithea.model.api_key import ApiKeyModel
-from kallithea.model import validators
from kallithea.model.db import User
from kallithea.model.meta import Session
from kallithea.model.user import UserModel
+from kallithea.tests.base import *
+from kallithea.tests.fixture import Fixture
-from tg.util.webtest import test_context
fixture = Fixture()
diff --git a/kallithea/tests/functional/test_my_account.py b/kallithea/tests/functional/test_my_account.py
--- a/kallithea/tests/functional/test_my_account.py
+++ b/kallithea/tests/functional/test_my_account.py
@@ -1,13 +1,14 @@
# -*- coding: utf-8 -*-
-from kallithea.model.db import User, UserFollowing, Repository, UserApiKeys, UserSshKeys
+from tg.util.webtest import test_context
+
+from kallithea.lib import helpers as h
+from kallithea.model.db import Repository, User, UserApiKeys, UserFollowing, UserSshKeys
+from kallithea.model.meta import Session
+from kallithea.model.user import UserModel
from kallithea.tests.base import *
from kallithea.tests.fixture import Fixture
-from kallithea.lib import helpers as h
-from kallithea.model.user import UserModel
-from kallithea.model.meta import Session
-from tg.util.webtest import test_context
fixture = Fixture()
diff --git a/kallithea/tests/functional/test_pullrequests.py b/kallithea/tests/functional/test_pullrequests.py
--- a/kallithea/tests/functional/test_pullrequests.py
+++ b/kallithea/tests/functional/test_pullrequests.py
@@ -1,14 +1,14 @@
import re
+
import pytest
-
from tg.util.webtest import test_context
+from kallithea.controllers.pullrequests import PullrequestsController
+from kallithea.model.db import PullRequest, User
+from kallithea.model.meta import Session
from kallithea.tests.base import *
from kallithea.tests.fixture import Fixture
-from kallithea.model.db import PullRequest, User
-from kallithea.model.meta import Session
-from kallithea.controllers.pullrequests import PullrequestsController
fixture = Fixture()
diff --git a/kallithea/tests/functional/test_search.py b/kallithea/tests/functional/test_search.py
--- a/kallithea/tests/functional/test_search.py
+++ b/kallithea/tests/functional/test_search.py
@@ -1,5 +1,7 @@
+import os
+
import mock
-import os
+
from kallithea.tests.base import *
diff --git a/kallithea/tests/functional/test_search_indexing.py b/kallithea/tests/functional/test_search_indexing.py
--- a/kallithea/tests/functional/test_search_indexing.py
+++ b/kallithea/tests/functional/test_search_indexing.py
@@ -6,7 +6,8 @@ from kallithea.model.meta import Session
from kallithea.model.repo import RepoModel
from kallithea.model.repo_group import RepoGroupModel
from kallithea.tests.base import *
-from kallithea.tests.fixture import create_test_index, Fixture
+from kallithea.tests.fixture import Fixture, create_test_index
+
fixture = Fixture()
diff --git a/kallithea/tests/functional/test_summary.py b/kallithea/tests/functional/test_summary.py
--- a/kallithea/tests/functional/test_summary.py
+++ b/kallithea/tests/functional/test_summary.py
@@ -12,14 +12,15 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
+import pytest
+
+from kallithea.model.db import Repository
+from kallithea.model.meta import Session
+from kallithea.model.repo import RepoModel
+from kallithea.model.scm import ScmModel
from kallithea.tests.base import *
from kallithea.tests.fixture import Fixture
-from kallithea.model.db import Repository
-from kallithea.model.repo import RepoModel
-from kallithea.model.meta import Session
-from kallithea.model.scm import ScmModel
-import pytest
fixture = Fixture()
diff --git a/kallithea/tests/models/common.py b/kallithea/tests/models/common.py
--- a/kallithea/tests/models/common.py
+++ b/kallithea/tests/models/common.py
@@ -1,14 +1,12 @@
+from kallithea.lib.auth import AuthUser
+from kallithea.model.db import RepoGroup, Repository, User
+from kallithea.model.meta import Session
+from kallithea.model.repo import RepoModel
+from kallithea.model.repo_group import RepoGroupModel
+from kallithea.model.user import UserModel
from kallithea.tests.base import *
from kallithea.tests.fixture import Fixture
-from kallithea.model.repo_group import RepoGroupModel
-from kallithea.model.repo import RepoModel
-from kallithea.model.db import RepoGroup, Repository, User
-from kallithea.model.user import UserModel
-
-from kallithea.lib.auth import AuthUser
-from kallithea.model.meta import Session
-
fixture = Fixture()
diff --git a/kallithea/tests/models/test_changeset_status.py b/kallithea/tests/models/test_changeset_status.py
--- a/kallithea/tests/models/test_changeset_status.py
+++ b/kallithea/tests/models/test_changeset_status.py
@@ -1,6 +1,6 @@
-from kallithea.tests.base import *
from kallithea.model.changeset_status import ChangesetStatusModel
from kallithea.model.db import ChangesetStatus as CS
+from kallithea.tests.base import *
class CSM(object): # ChangesetStatusMock
diff --git a/kallithea/tests/models/test_comments.py b/kallithea/tests/models/test_comments.py
--- a/kallithea/tests/models/test_comments.py
+++ b/kallithea/tests/models/test_comments.py
@@ -1,9 +1,10 @@
-from kallithea.tests.base import *
+import pytest
+from tg.util.webtest import test_context
+
from kallithea.model.comment import ChangesetCommentsModel
from kallithea.model.db import Repository
+from kallithea.tests.base import *
-import pytest
-from tg.util.webtest import test_context
class TestComments(TestController):
diff --git a/kallithea/tests/models/test_diff_parsers.py b/kallithea/tests/models/test_diff_parsers.py
--- a/kallithea/tests/models/test_diff_parsers.py
+++ b/kallithea/tests/models/test_diff_parsers.py
@@ -1,8 +1,8 @@
+from kallithea.lib.diffs import BIN_FILENODE, CHMOD_FILENODE, COPIED_FILENODE, DEL_FILENODE, MOD_FILENODE, NEW_FILENODE, RENAMED_FILENODE, DiffProcessor
from kallithea.tests.base import *
-from kallithea.lib.diffs import DiffProcessor, NEW_FILENODE, DEL_FILENODE, \
- MOD_FILENODE, RENAMED_FILENODE, CHMOD_FILENODE, BIN_FILENODE, COPIED_FILENODE
from kallithea.tests.fixture import Fixture
+
fixture = Fixture()
diff --git a/kallithea/tests/models/test_notifications.py b/kallithea/tests/models/test_notifications.py
--- a/kallithea/tests/models/test_notifications.py
+++ b/kallithea/tests/models/test_notifications.py
@@ -3,18 +3,16 @@ import re
import mock
import routes.util
-
-from kallithea.tests.base import *
-from kallithea.lib import helpers as h
-from kallithea.model.db import User
-from kallithea.model.user import UserModel
-from kallithea.model.meta import Session
-from kallithea.model.notification import NotificationModel, EmailNotificationModel
+from tg.util.webtest import test_context
import kallithea.lib.celerylib
import kallithea.lib.celerylib.tasks
-
-from tg.util.webtest import test_context
+from kallithea.lib import helpers as h
+from kallithea.model.db import User
+from kallithea.model.meta import Session
+from kallithea.model.notification import EmailNotificationModel, NotificationModel
+from kallithea.model.user import UserModel
+from kallithea.tests.base import *
class TestNotifications(TestController):
diff --git a/kallithea/tests/models/test_permissions.py b/kallithea/tests/models/test_permissions.py
--- a/kallithea/tests/models/test_permissions.py
+++ b/kallithea/tests/models/test_permissions.py
@@ -1,15 +1,13 @@
+from kallithea.lib.auth import AuthUser
+from kallithea.model.db import Permission, RepoGroup, User, UserGroupRepoGroupToPerm, UserToPerm
+from kallithea.model.meta import Session
+from kallithea.model.permission import PermissionModel
+from kallithea.model.repo import RepoModel
+from kallithea.model.repo_group import RepoGroupModel
+from kallithea.model.user import UserModel
+from kallithea.model.user_group import UserGroupModel
from kallithea.tests.base import *
from kallithea.tests.fixture import Fixture
-from kallithea.model.repo_group import RepoGroupModel
-from kallithea.model.repo import RepoModel
-from kallithea.model.db import RepoGroup, User, UserGroupRepoGroupToPerm, \
- Permission, UserToPerm
-from kallithea.model.user import UserModel
-
-from kallithea.model.meta import Session
-from kallithea.model.user_group import UserGroupModel
-from kallithea.lib.auth import AuthUser
-from kallithea.model.permission import PermissionModel
fixture = Fixture()
diff --git a/kallithea/tests/models/test_repo_groups.py b/kallithea/tests/models/test_repo_groups.py
--- a/kallithea/tests/models/test_repo_groups.py
+++ b/kallithea/tests/models/test_repo_groups.py
@@ -1,15 +1,15 @@
import os
+
import pytest
from sqlalchemy.exc import IntegrityError
+from kallithea.model.db import RepoGroup
+from kallithea.model.meta import Session
+from kallithea.model.repo import RepoModel
+from kallithea.model.repo_group import RepoGroupModel
from kallithea.tests.base import *
from kallithea.tests.fixture import Fixture
-from kallithea.model.repo_group import RepoGroupModel
-from kallithea.model.repo import RepoModel
-from kallithea.model.db import RepoGroup
-from kallithea.model.meta import Session
-
fixture = Fixture()
diff --git a/kallithea/tests/models/test_repos.py b/kallithea/tests/models/test_repos.py
--- a/kallithea/tests/models/test_repos.py
+++ b/kallithea/tests/models/test_repos.py
@@ -1,11 +1,12 @@
import pytest
-from kallithea.tests.base import *
+from kallithea.lib.exceptions import AttachedForksError
+from kallithea.model.db import Repository
from kallithea.model.meta import Session
+from kallithea.model.repo import RepoModel
+from kallithea.tests.base import *
from kallithea.tests.fixture import Fixture
-from kallithea.model.repo import RepoModel
-from kallithea.model.db import Repository
-from kallithea.lib.exceptions import AttachedForksError
+
fixture = Fixture()
diff --git a/kallithea/tests/models/test_settings.py b/kallithea/tests/models/test_settings.py
--- a/kallithea/tests/models/test_settings.py
+++ b/kallithea/tests/models/test_settings.py
@@ -1,5 +1,5 @@
+from kallithea.model.db import Setting
from kallithea.model.meta import Session
-from kallithea.model.db import Setting
name = 'spam-setting-name'
diff --git a/kallithea/tests/models/test_user_group_permissions_on_repo_groups.py b/kallithea/tests/models/test_user_group_permissions_on_repo_groups.py
--- a/kallithea/tests/models/test_user_group_permissions_on_repo_groups.py
+++ b/kallithea/tests/models/test_user_group_permissions_on_repo_groups.py
@@ -1,13 +1,12 @@
import functools
+from kallithea.model.db import RepoGroup
+from kallithea.model.meta import Session
from kallithea.model.repo_group import RepoGroupModel
-from kallithea.model.db import RepoGroup
-
-from kallithea.model.meta import Session
-from kallithea.tests.models.common import _create_project_tree, check_tree_perms, \
- _get_perms, _check_expected_count, expected_count, _destroy_project_tree
from kallithea.model.user_group import UserGroupModel
from kallithea.tests.fixture import Fixture
+from kallithea.tests.models.common import _check_expected_count, _create_project_tree, _destroy_project_tree, _get_perms, check_tree_perms, expected_count
+
fixture = Fixture()
diff --git a/kallithea/tests/models/test_user_groups.py b/kallithea/tests/models/test_user_groups.py
--- a/kallithea/tests/models/test_user_groups.py
+++ b/kallithea/tests/models/test_user_groups.py
@@ -1,11 +1,9 @@
from kallithea.model.db import User, UserGroup
-
+from kallithea.model.meta import Session
+from kallithea.model.user_group import UserGroupModel
from kallithea.tests.base import *
from kallithea.tests.fixture import Fixture
-from kallithea.model.user_group import UserGroupModel
-from kallithea.model.meta import Session
-
fixture = Fixture()
diff --git a/kallithea/tests/models/test_user_permissions_on_repo_groups.py b/kallithea/tests/models/test_user_permissions_on_repo_groups.py
--- a/kallithea/tests/models/test_user_permissions_on_repo_groups.py
+++ b/kallithea/tests/models/test_user_permissions_on_repo_groups.py
@@ -1,11 +1,9 @@
import functools
+from kallithea.model.db import RepoGroup, Repository, User
+from kallithea.model.meta import Session
from kallithea.model.repo_group import RepoGroupModel
-from kallithea.model.db import RepoGroup, Repository, User
-
-from kallithea.model.meta import Session
-from kallithea.tests.models.common import _create_project_tree, check_tree_perms, \
- _get_perms, _check_expected_count, expected_count, _destroy_project_tree
+from kallithea.tests.models.common import _check_expected_count, _create_project_tree, _destroy_project_tree, _get_perms, check_tree_perms, expected_count
test_u1_id = None
diff --git a/kallithea/tests/models/test_user_ssh_keys.py b/kallithea/tests/models/test_user_ssh_keys.py
--- a/kallithea/tests/models/test_user_ssh_keys.py
+++ b/kallithea/tests/models/test_user_ssh_keys.py
@@ -1,8 +1,8 @@
from kallithea.model.db import UserSshKeys
-
from kallithea.tests.base import TestController
from kallithea.tests.fixture import Fixture
+
fixture = Fixture()
public_key = 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC6Ycnc2oUZHQnQwuqgZqTTdMDZD7ataf3JM7oG2Fw8JR6cdmz4QZLe5mfDwaFwG2pWHLRpVqzfrD/Pn3rIO++bgCJH5ydczrl1WScfryV1hYMJ/4EzLGM657J1/q5EI+b9SntKjf4ax+KP322L0TNQGbZUHLbfG2MwHMrYBQpHUQ== kallithea@localhost'
diff --git a/kallithea/tests/models/test_users.py b/kallithea/tests/models/test_users.py
--- a/kallithea/tests/models/test_users.py
+++ b/kallithea/tests/models/test_users.py
@@ -1,13 +1,13 @@
import pytest
-from kallithea.tests.base import *
-from kallithea.model.db import User, UserGroup, UserGroupMember, UserEmailMap, \
- Permission
+from kallithea.model.db import Permission, User, UserEmailMap, UserGroup, UserGroupMember
+from kallithea.model.meta import Session
from kallithea.model.user import UserModel
-from kallithea.model.meta import Session
from kallithea.model.user_group import UserGroupModel
+from kallithea.tests.base import *
from kallithea.tests.fixture import Fixture
+
fixture = Fixture()
diff --git a/kallithea/tests/other/test_auth_ldap.py b/kallithea/tests/other/test_auth_ldap.py
--- a/kallithea/tests/other/test_auth_ldap.py
+++ b/kallithea/tests/other/test_auth_ldap.py
@@ -1,8 +1,10 @@
+import uuid
+
+import pytest
+
from kallithea.lib.auth_modules import auth_ldap, authenticate
from kallithea.model.db import Setting, User
from kallithea.model.meta import Session
-import uuid
-import pytest
@pytest.fixture
diff --git a/kallithea/tests/other/test_libs.py b/kallithea/tests/other/test_libs.py
--- a/kallithea/tests/other/test_libs.py
+++ b/kallithea/tests/other/test_libs.py
@@ -27,11 +27,14 @@ Original author and date, and relevant c
import datetime
import hashlib
+
import mock
-from kallithea.tests.base import *
+from tg.util.webtest import test_context
+
from kallithea.lib.utils2 import AttributeDict
from kallithea.model.db import Repository
-from tg.util.webtest import test_context
+from kallithea.tests.base import *
+
proto = 'http'
TEST_URLS = [
diff --git a/kallithea/tests/other/test_mail.py b/kallithea/tests/other/test_mail.py
--- a/kallithea/tests/other/test_mail.py
+++ b/kallithea/tests/other/test_mail.py
@@ -1,8 +1,8 @@
import mock
import kallithea
+from kallithea.model.db import User
from kallithea.tests.base import *
-from kallithea.model.db import User
class smtplib_mock(object):
diff --git a/kallithea/tests/other/test_validators.py b/kallithea/tests/other/test_validators.py
--- a/kallithea/tests/other/test_validators.py
+++ b/kallithea/tests/other/test_validators.py
@@ -2,15 +2,14 @@
import formencode
import pytest
-from kallithea.tests.base import *
-
from kallithea.model import validators as v
-from kallithea.model.user_group import UserGroupModel
-
from kallithea.model.meta import Session
from kallithea.model.repo_group import RepoGroupModel
+from kallithea.model.user_group import UserGroupModel
+from kallithea.tests.base import *
from kallithea.tests.fixture import Fixture
+
fixture = Fixture()
diff --git a/kallithea/tests/other/test_vcs_operations.py b/kallithea/tests/other/test_vcs_operations.py
--- a/kallithea/tests/other/test_vcs_operations.py
+++ b/kallithea/tests/other/test_vcs_operations.py
@@ -25,25 +25,26 @@ Original author and date, and relevant c
"""
+import json
import os
import re
import tempfile
import time
import urllib2
-import json
+from subprocess import PIPE, Popen
from tempfile import _RandomNameSequence
-from subprocess import Popen, PIPE
import pytest
+from kallithea import CONFIG
+from kallithea.model.db import CacheInvalidation, Repository, Ui, User, UserIpMap, UserLog
+from kallithea.model.meta import Session
+from kallithea.model.repo import RepoModel
+from kallithea.model.ssh_key import SshKeyModel
+from kallithea.model.user import UserModel
from kallithea.tests.base import *
from kallithea.tests.fixture import Fixture
-from kallithea.model.db import User, Repository, UserIpMap, CacheInvalidation, Ui, UserLog
-from kallithea.model.meta import Session
-from kallithea.model.repo import RepoModel
-from kallithea.model.user import UserModel
-from kallithea.model.ssh_key import SshKeyModel
-from kallithea import CONFIG
+
DEBUG = True
HOST = '127.0.0.1:4999' # test host
diff --git a/kallithea/tests/performance/test_vcs.py b/kallithea/tests/performance/test_vcs.py
--- a/kallithea/tests/performance/test_vcs.py
+++ b/kallithea/tests/performance/test_vcs.py
@@ -17,6 +17,7 @@ import pytest
from kallithea.model.db import Repository
from kallithea.tests.base import *
+
@pytest.mark.skipif("not os.environ.has_key('TEST_PERFORMANCE')", reason="skipping performance tests, set TEST_PERFORMANCE in environment if desired")
class TestVCSPerformance(TestController):
diff --git a/kallithea/tests/scripts/manual_test_concurrency.py b/kallithea/tests/scripts/manual_test_concurrency.py
--- a/kallithea/tests/scripts/manual_test_concurrency.py
+++ b/kallithea/tests/scripts/manual_test_concurrency.py
@@ -26,25 +26,25 @@ Original author and date, and relevant c
"""
+import logging
import os
+import shutil
import sys
-import shutil
-import logging
import tempfile
from os.path import dirname
-from subprocess import Popen, PIPE
+from subprocess import PIPE, Popen
from paste.deploy import appconfig
from sqlalchemy import engine_from_config
+from kallithea.config.environment import load_environment
+from kallithea.lib.auth import get_crypt_password
from kallithea.lib.utils import setup_cache_regions
-from kallithea.model.base import init_model
from kallithea.model import meta
-from kallithea.model.db import User, Repository, Ui
-from kallithea.lib.auth import get_crypt_password
+from kallithea.model.base import init_model
+from kallithea.model.db import Repository, Ui, User
+from kallithea.tests.base import HG_REPO, TEST_USER_ADMIN_LOGIN, TEST_USER_ADMIN_PASS
-from kallithea.tests.base import HG_REPO, TEST_USER_ADMIN_LOGIN, TEST_USER_ADMIN_PASS
-from kallithea.config.environment import load_environment
rel_path = dirname(dirname(dirname(dirname(os.path.abspath(__file__)))))
conf = appconfig('config:development.ini', relative_to=rel_path)
diff --git a/kallithea/tests/scripts/manual_test_crawler.py b/kallithea/tests/scripts/manual_test_crawler.py
--- a/kallithea/tests/scripts/manual_test_crawler.py
+++ b/kallithea/tests/scripts/manual_test_crawler.py
@@ -32,21 +32,23 @@ Original author and date, and relevant c
import cookielib
-import urllib
-import urllib2
-import time
import os
import sys
import tempfile
+import time
+import urllib
+import urllib2
from os.path import dirname
+from kallithea.lib import vcs
+from kallithea.lib.compat import OrderedSet
+from kallithea.lib.vcs.exceptions import RepositoryError
+
+
__here__ = os.path.abspath(__file__)
__root__ = dirname(dirname(dirname(__here__)))
sys.path.append(__root__)
-from kallithea.lib import vcs
-from kallithea.lib.compat import OrderedSet
-from kallithea.lib.vcs.exceptions import RepositoryError
PASES = 3
HOST = 'http://127.0.0.1'
diff --git a/kallithea/tests/vcs/__init__.py b/kallithea/tests/vcs/__init__.py
--- a/kallithea/tests/vcs/__init__.py
+++ b/kallithea/tests/vcs/__init__.py
@@ -22,7 +22,7 @@ at ``test_hg`` module.
import os
import shutil
-from kallithea.tests.base import TEST_HG_REPO, HG_REMOTE_REPO, TEST_GIT_REPO, GIT_REMOTE_REPO, TESTS_TMP_PATH
+from kallithea.tests.base import GIT_REMOTE_REPO, HG_REMOTE_REPO, TEST_GIT_REPO, TEST_HG_REPO, TESTS_TMP_PATH
from kallithea.tests.vcs.utils import SCMFetcher
diff --git a/kallithea/tests/vcs/base.py b/kallithea/tests/vcs/base.py
--- a/kallithea/tests/vcs/base.py
+++ b/kallithea/tests/vcs/base.py
@@ -1,14 +1,14 @@
"""
Module providing backend independent mixin class.
"""
+import datetime
import os
import time
-import datetime
+
import pytest
from kallithea.lib import vcs
from kallithea.lib.vcs.nodes import FileNode
-
from kallithea.tests.vcs.conf import get_new_dir
diff --git a/kallithea/tests/vcs/conf.py b/kallithea/tests/vcs/conf.py
--- a/kallithea/tests/vcs/conf.py
+++ b/kallithea/tests/vcs/conf.py
@@ -8,12 +8,8 @@ import uuid
# module. Some of these configuration options are subsequently
# consumed by the VCS test module.
from kallithea.tests.base import (
- TESTS_TMP_PATH,
- TEST_HG_REPO, HG_REMOTE_REPO,
- TEST_HG_REPO_CLONE, TEST_HG_REPO_PULL,
- TEST_GIT_REPO, GIT_REMOTE_REPO,
- TEST_GIT_REPO_CLONE,
-)
+ GIT_REMOTE_REPO, HG_REMOTE_REPO, TEST_GIT_REPO, TEST_GIT_REPO_CLONE, TEST_HG_REPO, TEST_HG_REPO_CLONE, TEST_HG_REPO_PULL, TESTS_TMP_PATH)
+
__all__ = (
'TEST_HG_REPO', 'TEST_GIT_REPO', 'HG_REMOTE_REPO', 'GIT_REMOTE_REPO',
diff --git a/kallithea/tests/vcs/test_archives.py b/kallithea/tests/vcs/test_archives.py
--- a/kallithea/tests/vcs/test_archives.py
+++ b/kallithea/tests/vcs/test_archives.py
@@ -1,15 +1,14 @@
+import datetime
import os
+import StringIO
import tarfile
+import tempfile
import zipfile
-import datetime
-import tempfile
-import StringIO
import pytest
from kallithea.lib.vcs.exceptions import VCSError
from kallithea.lib.vcs.nodes import FileNode
-
from kallithea.tests.vcs.base import _BackendTestMixin
from kallithea.tests.vcs.conf import TESTS_TMP_PATH
diff --git a/kallithea/tests/vcs/test_branches.py b/kallithea/tests/vcs/test_branches.py
--- a/kallithea/tests/vcs/test_branches.py
+++ b/kallithea/tests/vcs/test_branches.py
@@ -1,7 +1,7 @@
import datetime
+
from kallithea.lib import vcs
from kallithea.lib.vcs.nodes import FileNode
-
from kallithea.tests.vcs.base import _BackendTestMixin
diff --git a/kallithea/tests/vcs/test_changesets.py b/kallithea/tests/vcs/test_changesets.py
--- a/kallithea/tests/vcs/test_changesets.py
+++ b/kallithea/tests/vcs/test_changesets.py
@@ -1,22 +1,14 @@
# encoding: utf-8
+import datetime
import time
-import datetime
import pytest
from kallithea.lib import vcs
-
from kallithea.lib.vcs.backends.base import BaseChangeset
-from kallithea.lib.vcs.nodes import (
- FileNode, AddedFileNodesGenerator,
- ChangedFileNodesGenerator, RemovedFileNodesGenerator
-)
-from kallithea.lib.vcs.exceptions import (
- BranchDoesNotExistError, ChangesetDoesNotExistError,
- RepositoryError, EmptyRepositoryError
-)
-
+from kallithea.lib.vcs.exceptions import BranchDoesNotExistError, ChangesetDoesNotExistError, EmptyRepositoryError, RepositoryError
+from kallithea.lib.vcs.nodes import AddedFileNodesGenerator, ChangedFileNodesGenerator, FileNode, RemovedFileNodesGenerator
from kallithea.tests.vcs.base import _BackendTestMixin
from kallithea.tests.vcs.conf import get_new_dir
diff --git a/kallithea/tests/vcs/test_getitem.py b/kallithea/tests/vcs/test_getitem.py
--- a/kallithea/tests/vcs/test_getitem.py
+++ b/kallithea/tests/vcs/test_getitem.py
@@ -1,7 +1,7 @@
import datetime
+from kallithea.lib.vcs.nodes import FileNode
from kallithea.tests.vcs.base import _BackendTestMixin
-from kallithea.lib.vcs.nodes import FileNode
class GetitemTestCaseMixin(_BackendTestMixin):
diff --git a/kallithea/tests/vcs/test_getslice.py b/kallithea/tests/vcs/test_getslice.py
--- a/kallithea/tests/vcs/test_getslice.py
+++ b/kallithea/tests/vcs/test_getslice.py
@@ -1,7 +1,6 @@
import datetime
from kallithea.lib.vcs.nodes import FileNode
-
from kallithea.tests.vcs.base import _BackendTestMixin
diff --git a/kallithea/tests/vcs/test_git.py b/kallithea/tests/vcs/test_git.py
--- a/kallithea/tests/vcs/test_git.py
+++ b/kallithea/tests/vcs/test_git.py
@@ -1,16 +1,15 @@
+import datetime
import os
import sys
-import mock
-import datetime
import urllib2
+import mock
import pytest
-from kallithea.lib.vcs.backends.git import GitRepository, GitChangeset
-from kallithea.lib.vcs.exceptions import RepositoryError, VCSError, NodeDoesNotExistError
-from kallithea.lib.vcs.nodes import NodeKind, FileNode, DirNode, NodeState
+from kallithea.lib.vcs.backends.git import GitChangeset, GitRepository
+from kallithea.lib.vcs.exceptions import NodeDoesNotExistError, RepositoryError, VCSError
+from kallithea.lib.vcs.nodes import DirNode, FileNode, NodeKind, NodeState
from kallithea.model.scm import ScmModel
-
from kallithea.tests.vcs.base import _BackendTestMixin
from kallithea.tests.vcs.conf import TEST_GIT_REPO, TEST_GIT_REPO_CLONE, TESTS_TMP_PATH, get_new_dir
diff --git a/kallithea/tests/vcs/test_hg.py b/kallithea/tests/vcs/test_hg.py
--- a/kallithea/tests/vcs/test_hg.py
+++ b/kallithea/tests/vcs/test_hg.py
@@ -1,15 +1,13 @@
import os
+import mock
import pytest
-import mock
from kallithea.lib.utils2 import safe_str
-from kallithea.lib.vcs.backends.hg import MercurialRepository, MercurialChangeset
-from kallithea.lib.vcs.exceptions import RepositoryError, VCSError, NodeDoesNotExistError
+from kallithea.lib.vcs.backends.hg import MercurialChangeset, MercurialRepository
+from kallithea.lib.vcs.exceptions import NodeDoesNotExistError, RepositoryError, VCSError
from kallithea.lib.vcs.nodes import NodeKind, NodeState
-
-from kallithea.tests.vcs.conf import TEST_HG_REPO, TEST_HG_REPO_CLONE, \
- TEST_HG_REPO_PULL, TESTS_TMP_PATH
+from kallithea.tests.vcs.conf import TEST_HG_REPO, TEST_HG_REPO_CLONE, TEST_HG_REPO_PULL, TESTS_TMP_PATH
class TestMercurialRepository(object):
diff --git a/kallithea/tests/vcs/test_inmemchangesets.py b/kallithea/tests/vcs/test_inmemchangesets.py
--- a/kallithea/tests/vcs/test_inmemchangesets.py
+++ b/kallithea/tests/vcs/test_inmemchangesets.py
@@ -3,23 +3,16 @@
Tests so called "in memory changesets" commit API of vcs.
"""
+import datetime
import time
-import datetime
import pytest
from kallithea.lib import vcs
-from kallithea.lib.vcs.exceptions import EmptyRepositoryError
-from kallithea.lib.vcs.exceptions import NodeAlreadyAddedError
-from kallithea.lib.vcs.exceptions import NodeAlreadyExistsError
-from kallithea.lib.vcs.exceptions import NodeAlreadyRemovedError
-from kallithea.lib.vcs.exceptions import NodeAlreadyChangedError
-from kallithea.lib.vcs.exceptions import NodeDoesNotExistError
-from kallithea.lib.vcs.exceptions import NodeNotChangedError
-from kallithea.lib.vcs.nodes import DirNode
-from kallithea.lib.vcs.nodes import FileNode
+from kallithea.lib.vcs.exceptions import (
+ EmptyRepositoryError, NodeAlreadyAddedError, NodeAlreadyChangedError, NodeAlreadyExistsError, NodeAlreadyRemovedError, NodeDoesNotExistError, NodeNotChangedError)
+from kallithea.lib.vcs.nodes import DirNode, FileNode
from kallithea.lib.vcs.utils import safe_unicode
-
from kallithea.tests.vcs.base import _BackendTestMixin
diff --git a/kallithea/tests/vcs/test_nodes.py b/kallithea/tests/vcs/test_nodes.py
--- a/kallithea/tests/vcs/test_nodes.py
+++ b/kallithea/tests/vcs/test_nodes.py
@@ -1,13 +1,9 @@
+import mimetypes
import stat
-import mimetypes
import pytest
-from kallithea.lib.vcs.nodes import DirNode
-from kallithea.lib.vcs.nodes import FileNode
-from kallithea.lib.vcs.nodes import Node
-from kallithea.lib.vcs.nodes import NodeError
-from kallithea.lib.vcs.nodes import NodeKind
+from kallithea.lib.vcs.nodes import DirNode, FileNode, Node, NodeError, NodeKind
class TestNodeBasic(object):
diff --git a/kallithea/tests/vcs/test_repository.py b/kallithea/tests/vcs/test_repository.py
--- a/kallithea/tests/vcs/test_repository.py
+++ b/kallithea/tests/vcs/test_repository.py
@@ -2,11 +2,10 @@ import datetime
import pytest
+from kallithea.lib.vcs.exceptions import ChangesetDoesNotExistError
from kallithea.lib.vcs.nodes import FileNode
-from kallithea.lib.vcs.exceptions import ChangesetDoesNotExistError
-
+from kallithea.tests.vcs import TEST_USER_CONFIG_FILE
from kallithea.tests.vcs.base import _BackendTestMixin
-from kallithea.tests.vcs import TEST_USER_CONFIG_FILE
class RepositoryBaseTest(_BackendTestMixin):
diff --git a/kallithea/tests/vcs/test_tags.py b/kallithea/tests/vcs/test_tags.py
--- a/kallithea/tests/vcs/test_tags.py
+++ b/kallithea/tests/vcs/test_tags.py
@@ -1,8 +1,6 @@
import pytest
-from kallithea.lib.vcs.exceptions import TagAlreadyExistError
-from kallithea.lib.vcs.exceptions import TagDoesNotExistError
-
+from kallithea.lib.vcs.exceptions import TagAlreadyExistError, TagDoesNotExistError
from kallithea.tests.vcs.base import _BackendTestMixin
diff --git a/kallithea/tests/vcs/test_utils.py b/kallithea/tests/vcs/test_utils.py
--- a/kallithea/tests/vcs/test_utils.py
+++ b/kallithea/tests/vcs/test_utils.py
@@ -1,24 +1,18 @@
# -*- coding: utf-8 -*-
+import datetime
import os
-import mock
+import shutil
import time
-import shutil
-import datetime
+import mock
import pytest
-from kallithea.lib.vcs.utils.paths import get_dirs_for_path
-from kallithea.lib.vcs.utils.helpers import get_dict_for_attrs
-from kallithea.lib.vcs.utils.helpers import get_scm
-from kallithea.lib.vcs.utils.helpers import get_scms_for_path
-from kallithea.lib.vcs.utils.helpers import parse_changesets
-from kallithea.lib.vcs.utils.helpers import parse_datetime
+from kallithea.lib.vcs.exceptions import VCSError
from kallithea.lib.vcs.utils import author_email, author_name
-from kallithea.lib.vcs.utils.paths import get_user_home
-from kallithea.lib.vcs.exceptions import VCSError
-
-from kallithea.tests.vcs.conf import TEST_HG_REPO, TEST_GIT_REPO, TESTS_TMP_PATH
+from kallithea.lib.vcs.utils.helpers import get_dict_for_attrs, get_scm, get_scms_for_path, parse_changesets, parse_datetime
+from kallithea.lib.vcs.utils.paths import get_dirs_for_path, get_user_home
+from kallithea.tests.vcs.conf import TEST_GIT_REPO, TEST_HG_REPO, TESTS_TMP_PATH
class TestPaths(object):
diff --git a/kallithea/tests/vcs/test_vcs.py b/kallithea/tests/vcs/test_vcs.py
--- a/kallithea/tests/vcs/test_vcs.py
+++ b/kallithea/tests/vcs/test_vcs.py
@@ -4,10 +4,9 @@ import shutil
import pytest
from kallithea.lib.utils2 import safe_str
-from kallithea.lib.vcs import VCSError, get_repo, get_backend
+from kallithea.lib.vcs import VCSError, get_backend, get_repo
from kallithea.lib.vcs.backends.hg import MercurialRepository
-
-from kallithea.tests.vcs.conf import TEST_HG_REPO, TEST_GIT_REPO, TESTS_TMP_PATH
+from kallithea.tests.vcs.conf import TEST_GIT_REPO, TEST_HG_REPO, TESTS_TMP_PATH
class TestVCS(object):
diff --git a/kallithea/tests/vcs/test_workdirs.py b/kallithea/tests/vcs/test_workdirs.py
--- a/kallithea/tests/vcs/test_workdirs.py
+++ b/kallithea/tests/vcs/test_workdirs.py
@@ -3,7 +3,6 @@ import datetime
import pytest
from kallithea.lib.vcs.nodes import FileNode
-
from kallithea.tests.vcs.base import _BackendTestMixin
diff --git a/kallithea/tests/vcs/utils.py b/kallithea/tests/vcs/utils.py
--- a/kallithea/tests/vcs/utils.py
+++ b/kallithea/tests/vcs/utils.py
@@ -4,7 +4,6 @@ functions here are crafted as we don't w
"""
import os
import sys
-
from subprocess import Popen
diff --git a/scripts/docs-headings.py b/scripts/docs-headings.py
--- a/scripts/docs-headings.py
+++ b/scripts/docs-headings.py
@@ -7,6 +7,7 @@ Consistent formatting of rst section tit
import re
import subprocess
+
spaces = [
(0, 1), # we assume this is a over-and-underlined header
(2, 1),
diff --git a/scripts/generate-ini.py b/scripts/generate-ini.py
--- a/scripts/generate-ini.py
+++ b/scripts/generate-ini.py
@@ -7,6 +7,7 @@ import re
from kallithea.lib import inifile
+
# files to be generated from the mako template
ini_files = [
('development.ini',
diff --git a/scripts/logformat.py b/scripts/logformat.py
--- a/scripts/logformat.py
+++ b/scripts/logformat.py
@@ -3,6 +3,7 @@
import re
import sys
+
logre = r'''
(log\.(?:error|info|warning|debug)
[(][ \n]*
diff --git a/scripts/shortlog.py b/scripts/shortlog.py
--- a/scripts/shortlog.py
+++ b/scripts/shortlog.py
@@ -8,8 +8,10 @@ commit counts in a given revision set.
import argparse
import os
from collections import Counter
+
import contributor_data
+
def main():
parser = argparse.ArgumentParser(description='Generate a list of committers and commit counts.')
diff --git a/scripts/update-copyrights.py b/scripts/update-copyrights.py
--- a/scripts/update-copyrights.py
+++ b/scripts/update-copyrights.py
@@ -41,6 +41,7 @@ contributor, the legal entity is given c
import os
import re
from collections import defaultdict
+
import contributor_data
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -1,8 +1,13 @@
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
import os
+import platform
import sys
-import platform
+
+import setuptools
+# monkey patch setuptools to use distutils owner/group functionality
+from setuptools.command import sdist
+
if sys.version_info < (2, 6) or sys.version_info >= (3,):
raise Exception('Kallithea requires python 2.7')
@@ -110,10 +115,7 @@ except IOError as err:
)
long_description = description
-import setuptools
-# monkey patch setuptools to use distutils owner/group functionality
-from setuptools.command import sdist
sdist_org = sdist.sdist
class sdist_new(sdist_org):
def initialize_options(self):