Changeset - 68eee0e7f4f5
[Not reviewed]
dev_requirements.txt
Show inline comments
 
@@ -5,5 +5,5 @@ pytest-localserver >= 0.5.0, < 0.6
 
mock >= 3.0.0, < 4.1
 
Sphinx >= 1.8.0, < 3.1
 
WebTest >= 2.0.6, < 2.1
 
isort == 4.3.21
 
isort == 5.1.2
 
pyflakes == 2.2.0
kallithea/config/app_cfg.py
Show inline comments
 
@@ -86,8 +86,8 @@ base_config.update_blueprint({
 
# 'debug = true' (not in production!)
 
# See the Kallithea documentation for more information.
 
try:
 
    import kajiki  # only to check its existence
 
    from tgext.debugbar import enable_debugbar
 
    import kajiki # only to check its existence
 
    assert kajiki
 
except ImportError:
 
    pass
kallithea/controllers/compare.py
Show inline comments
 
@@ -130,8 +130,8 @@ class CompareController(BaseRepoControll
 

	
 
        elif alias == 'git':
 
            if org_repo != other_repo:
 
                from dulwich.client import SubprocessGitClient
 
                from dulwich.repo import Repo
 
                from dulwich.client import SubprocessGitClient
 

	
 
                gitrepo = Repo(org_repo.path)
 
                SubprocessGitClient(thin_packs=False).fetch(other_repo.path, gitrepo)
kallithea/lib/celerylib/tasks.py
Show inline comments
 
@@ -323,8 +323,8 @@ def send_email(recipients, subject, body
 
@celerylib.task
 
@celerylib.dbsession
 
def create_repo(form_data, cur_user):
 
    from kallithea.model.db import Setting
 
    from kallithea.model.repo import RepoModel
 
    from kallithea.model.db import Setting
 

	
 
    DBS = celerylib.get_session()
 

	
kallithea/lib/db_manage.py
Show inline comments
 
@@ -163,11 +163,9 @@ class DbManage(object):
 
            self.create_user(username, password, email, True)
 
        else:
 
            log.info('creating admin and regular test users')
 
            from kallithea.tests.base import TEST_USER_ADMIN_LOGIN, \
 
                TEST_USER_ADMIN_PASS, TEST_USER_ADMIN_EMAIL, \
 
                TEST_USER_REGULAR_LOGIN, TEST_USER_REGULAR_PASS, \
 
                TEST_USER_REGULAR_EMAIL, TEST_USER_REGULAR2_LOGIN, \
 
                TEST_USER_REGULAR2_PASS, TEST_USER_REGULAR2_EMAIL
 
            from kallithea.tests.base import (TEST_USER_ADMIN_EMAIL, TEST_USER_ADMIN_LOGIN, TEST_USER_ADMIN_PASS, TEST_USER_REGULAR2_EMAIL,
 
                                              TEST_USER_REGULAR2_LOGIN, TEST_USER_REGULAR2_PASS, TEST_USER_REGULAR_EMAIL, TEST_USER_REGULAR_LOGIN,
 
                                              TEST_USER_REGULAR_PASS)
 

	
 
            self.create_user(TEST_USER_ADMIN_LOGIN, TEST_USER_ADMIN_PASS,
 
                             TEST_USER_ADMIN_EMAIL, True)
kallithea/lib/helpers.py
Show inline comments
 
@@ -632,6 +632,7 @@ def person(author, show_attr="username")
 
    """Find the user identified by 'author', return one of the users attributes,
 
    default to the username attribute, None if there is no user"""
 
    from kallithea.model.db import User
 

	
 
    # if author is already an instance use it for extraction
 
    if isinstance(author, User):
 
        return getattr(author, show_attr)
 
@@ -646,6 +647,7 @@ def person(author, show_attr="username")
 

	
 
def person_by_id(id_, show_attr="username"):
 
    from kallithea.model.db import User
 

	
 
    # maybe it's an ID ?
 
    if str(id_).isdigit() or isinstance(id_, int):
 
        id_ = int(id_)
 
@@ -974,10 +976,8 @@ def gravatar(email_address, cls='', size
 

	
 

	
 
def gravatar_url(email_address, size=30, default=''):
 
    # doh, we need to re-import those to mock it later
 
    from kallithea.config.routing import url
 
    from kallithea.model.db import User
 
    from tg import tmpl_context as c
 

	
 
    if not c.visual.use_gravatar:
 
        return ""
 

	
 
@@ -987,6 +987,10 @@ def gravatar_url(email_address, size=30,
 
    if email_address == _def:
 
        return default
 

	
 
    # re-import url so tests can mock it
 
    from kallithea.config.routing import url
 
    from kallithea.model.db import User
 

	
 
    parsed_url = urllib.parse.urlparse(url.current(qualified=True))
 
    url = (c.visual.gravatar_url or User.DEFAULT_GRAVATAR_URL) \
 
               .replace('{email}', email_address) \
 
@@ -1022,8 +1026,7 @@ def fancy_file_stats(stats):
 

	
 
    :param stats: two element list of added/deleted lines of code
 
    """
 
    from kallithea.lib.diffs import NEW_FILENODE, DEL_FILENODE, \
 
        MOD_FILENODE, RENAMED_FILENODE, CHMOD_FILENODE, BIN_FILENODE
 
    from kallithea.lib.diffs import BIN_FILENODE, CHMOD_FILENODE, DEL_FILENODE, MOD_FILENODE, NEW_FILENODE, RENAMED_FILENODE
 

	
 
    a, d = stats['added'], stats['deleted']
 
    width = 100
kallithea/lib/hooks.py
Show inline comments
 
@@ -307,6 +307,7 @@ def _hook_environment(repo_path):
 
    connect to the database.
 
    """
 
    import paste.deploy
 

	
 
    import kallithea.config.application
 

	
 
    extras = get_hook_environment()
kallithea/lib/middleware/pygrack.py
Show inline comments
 
@@ -168,8 +168,9 @@ class GitRepository(object):
 
        if git_command in ['git-receive-pack']:
 
            # updating refs manually after each push.
 
            # Needed for pre-1.7.0.4 git clients using regular HTTP mode.
 
            from dulwich.server import update_server_info
 

	
 
            from kallithea.lib.vcs import get_repo
 
            from dulwich.server import update_server_info
 
            repo = get_repo(self.content_path)
 
            if repo:
 
                update_server_info(repo._repo)
 
@@ -223,6 +224,6 @@ class GitDirectory(object):
 

	
 

	
 
def make_wsgi_app(repo_name, repo_root):
 
    from dulwich.web import LimitedInputFilter, GunzipFilter
 
    from dulwich.web import GunzipFilter, LimitedInputFilter
 
    app = GitDirectory(repo_root, repo_name)
 
    return GunzipFilter(LimitedInputFilter(app))
kallithea/lib/utils2.py
Show inline comments
 
@@ -331,9 +331,8 @@ def get_changeset_safe(repo, rev):
 
    :param repo:
 
    :param rev:
 
    """
 
    from kallithea.lib.vcs.backends.base import BaseRepository
 
    from kallithea.lib.vcs.backends.base import BaseRepository, EmptyChangeset
 
    from kallithea.lib.vcs.exceptions import RepositoryError
 
    from kallithea.lib.vcs.backends.base import EmptyChangeset
 
    if not isinstance(repo, BaseRepository):
 
        raise Exception('You must pass an Repository '
 
                        'object as first argument got %s' % type(repo))
kallithea/lib/vcs/utils/helpers.py
Show inline comments
 
@@ -108,8 +108,8 @@ def get_highlighted_code(name, code, typ
 
    except ImportError:
 
        return code
 
    from pygments import highlight
 
    from pygments.lexers import guess_lexer_for_filename, ClassNotFound
 
    from pygments.formatters import TerminalFormatter
 
    from pygments.lexers import ClassNotFound, guess_lexer_for_filename
 

	
 
    try:
 
        lexer = guess_lexer_for_filename(name, code)
kallithea/model/db.py
Show inline comments
 
@@ -307,8 +307,10 @@ class Setting(Base, BaseDbModel):
 

	
 
    @classmethod
 
    def get_server_info(cls):
 
        import platform
 

	
 
        import pkg_resources
 
        import platform
 

	
 
        from kallithea.lib.utils import check_git_version
 
        mods = [(p.project_name, p.version) for p in pkg_resources.working_set]
 
        info = {
 
@@ -595,7 +597,8 @@ class User(Base, BaseDbModel):
 

	
 
        :param author:
 
        """
 
        from kallithea.lib.helpers import email, author_name
 
        from kallithea.lib.helpers import author_name, email
 

	
 
        # Valid email in the attribute passed, see if they're in the system
 
        _email = email(author)
 
        if _email:
kallithea/model/repo.py
Show inline comments
 
@@ -109,7 +109,8 @@ class RepoModel(object):
 

	
 
    @classmethod
 
    def _render_datatable(cls, tmpl, *args, **kwargs):
 
        from tg import tmpl_context as c, request, app_globals
 
        from tg import app_globals, request
 
        from tg import tmpl_context as c
 
        from tg.i18n import ugettext as _
 

	
 
        _tmpl_lookup = app_globals.mako_lookup
 
@@ -128,7 +129,9 @@ class RepoModel(object):
 
        admin: return data for action column.
 
        """
 
        _render = self._render_datatable
 
        from tg import tmpl_context as c, request
 
        from tg import request
 
        from tg import tmpl_context as c
 

	
 
        from kallithea.model.scm import ScmModel
 

	
 
        def repo_lnk(name, rtype, rstate, private, fork_of):
kallithea/model/repo_group.py
Show inline comments
 
@@ -189,8 +189,8 @@ class RepoGroupModel(object):
 
    def _update_permissions(self, repo_group, perms_new=None,
 
                            perms_updates=None, recursive=None,
 
                            check_perms=True):
 
        from kallithea.lib.auth import HasUserGroupPermissionLevel
 
        from kallithea.model.repo import RepoModel
 
        from kallithea.lib.auth import HasUserGroupPermissionLevel
 

	
 
        if not perms_new:
 
            perms_new = []
kallithea/model/user.py
Show inline comments
 
@@ -59,8 +59,7 @@ class UserModel(object):
 
        if not cur_user:
 
            cur_user = getattr(get_current_authuser(), 'username', None)
 

	
 
        from kallithea.lib.hooks import log_create_user, \
 
            check_allowed_create_user
 
        from kallithea.lib.hooks import check_allowed_create_user, log_create_user
 
        _fd = form_data
 
        user_data = {
 
            'username': _fd['username'],
 
@@ -111,9 +110,8 @@ class UserModel(object):
 
        if not cur_user:
 
            cur_user = getattr(get_current_authuser(), 'username', None)
 

	
 
        from kallithea.lib.auth import get_crypt_password, check_password
 
        from kallithea.lib.hooks import log_create_user, \
 
            check_allowed_create_user
 
        from kallithea.lib.auth import check_password, get_crypt_password
 
        from kallithea.lib.hooks import check_allowed_create_user, log_create_user
 
        user_data = {
 
            'username': username, 'password': password,
 
            'email': email, 'firstname': firstname, 'lastname': lastname,
 
@@ -168,8 +166,8 @@ class UserModel(object):
 
            raise
 

	
 
    def create_registration(self, form_data):
 
        import kallithea.lib.helpers as h
 
        from kallithea.model.notification import NotificationModel
 
        import kallithea.lib.helpers as h
 

	
 
        form_data['admin'] = False
 
        form_data['extern_type'] = User.DEFAULT_AUTH_TYPE
 
@@ -317,9 +315,9 @@ class UserModel(object):
 
        allowing users to copy-paste or manually enter the token from the
 
        email.
 
        """
 
        import kallithea.lib.helpers as h
 
        from kallithea.lib.celerylib import tasks
 
        from kallithea.model.notification import EmailNotificationModel
 
        import kallithea.lib.helpers as h
 

	
 
        user_email = data['email']
 
        user = User.get_by_email(user_email)
 
@@ -386,8 +384,8 @@ class UserModel(object):
 
        return expected_token == token
 

	
 
    def reset_password(self, user_email, new_passwd):
 
        from kallithea.lib import auth
 
        from kallithea.lib.celerylib import tasks
 
        from kallithea.lib import auth
 
        user = User.get_by_email(user_email)
 
        if user is not None:
 
            if not self.can_change_password(user):
kallithea/tests/api/api_base.py
Show inline comments
 
@@ -145,7 +145,7 @@ class _BaseTestApi(object):
 
        assert 'trololo' == Optional.extract('trololo')
 

	
 
    def test_Optional_OAttr(self):
 
        from kallithea.controllers.api.api import Optional, OAttr
 
        from kallithea.controllers.api.api import OAttr, Optional
 

	
 
        option1 = Optional(OAttr('apiuser'))
 
        assert 'apiuser' == Optional.extract(option1)
kallithea/tests/other/test_libs.py
Show inline comments
 
@@ -156,8 +156,9 @@ class TestLibs(base.TestController):
 
        (dict(years= -3, months= -2), '3 years and 2 months ago'),
 
    ])
 
    def test_age(self, age_args, expected):
 
        from dateutil import relativedelta
 

	
 
        from kallithea.lib.utils2 import age
 
        from dateutil import relativedelta
 
        with test_context(self.app):
 
            n = datetime.datetime(year=2012, month=5, day=17)
 
            delt = lambda *args, **kwargs: relativedelta.relativedelta(*args, **kwargs)
 
@@ -181,8 +182,9 @@ class TestLibs(base.TestController):
 
        (dict(years= -4, months= -8), '5 years ago'),
 
    ])
 
    def test_age_short(self, age_args, expected):
 
        from dateutil import relativedelta
 

	
 
        from kallithea.lib.utils2 import age
 
        from dateutil import relativedelta
 
        with test_context(self.app):
 
            n = datetime.datetime(year=2012, month=5, day=17)
 
            delt = lambda *args, **kwargs: relativedelta.relativedelta(*args, **kwargs)
 
@@ -200,8 +202,9 @@ class TestLibs(base.TestController):
 
        (dict(years=1, months=1), 'in 1 year and 1 month')
 
    ])
 
    def test_age_in_future(self, age_args, expected):
 
        from dateutil import relativedelta
 

	
 
        from kallithea.lib.utils2 import age
 
        from dateutil import relativedelta
 
        with test_context(self.app):
 
            n = datetime.datetime(year=2012, month=5, day=17)
 
            delt = lambda *args, **kwargs: relativedelta.relativedelta(*args, **kwargs)
 
@@ -297,6 +300,7 @@ class TestLibs(base.TestController):
 
        :param text:
 
        """
 
        import re
 

	
 
        # quickly change expected url[] into a link
 
        url_pattern = re.compile(r'(?:url\[)(.+?)(?:\])')
 

	
 
@@ -570,11 +574,11 @@ class TestLibs(base.TestController):
 
        ('http://www.example.org/kallithea/repos/', 'abc/xyz/', 'http://www.example.org/kallithea/repos/abc/xyz/'),
 
    ])
 
    def test_canonical_url(self, canonical, test, expected):
 
        from kallithea.lib.helpers import canonical_url
 
        # setup url(), used by canonical_url
 
        import routes
 
        from tg import request
 

	
 
        # setup url(), used by canonical_url
 
        import routes
 
        from kallithea.lib.helpers import canonical_url
 
        m = routes.Mapper()
 
        m.connect('about', '/about-page')
 
        url = routes.URLGenerator(m, {'HTTP_HOST': 'http_host.example.org'})
 
@@ -594,11 +598,12 @@ class TestLibs(base.TestController):
 
        ('http://www.example.org/kallithea/repos/', 'www.example.org'),
 
    ])
 
    def test_canonical_hostname(self, canonical, expected):
 
        from kallithea.lib.helpers import canonical_hostname
 
        import routes
 
        from tg import request
 

	
 
        from kallithea.lib.helpers import canonical_hostname
 

	
 
        # setup url(), used by canonical_hostname
 
        import routes
 
        m = routes.Mapper()
 
        url = routes.URLGenerator(m, {'HTTP_HOST': 'http_host.example.org'})
 

	
kallithea/tests/vcs/test_workdirs.py
Show inline comments
 
@@ -68,6 +68,7 @@ class WorkdirTestCaseMixin(_BackendTestM
 

	
 
    def test_checkout_branch(self):
 
        from kallithea.lib.vcs.exceptions import BranchDoesNotExistError
 

	
 
        # first, 'foobranch' does not exist.
 
        with pytest.raises(BranchDoesNotExistError):
 
            self.repo.workdir.checkout_branch(branch='foobranch')
scripts/i18n
Show inline comments
 
@@ -19,7 +19,6 @@ import shutil
 
import sys
 

	
 
import click
 

	
 
import i18n_utils
 

	
 

	
 
@@ -90,11 +89,8 @@ def normalized_merge(local, base, other,
 

	
 
    and then invoke merge/rebase/graft with the additional argument '--tool i18n'.
 
    """
 
    from mercurial import (
 
        context,
 
        simplemerge,
 
        ui as uimod,
 
    )
 
    from mercurial import context, simplemerge
 
    from mercurial import ui as uimod
 

	
 
    print('i18n normalized-merge: normalizing and merging %s' % output)
 

	
0 comments (0 inline, 0 general)