diff --git a/docs/api/models.rst b/docs/api/models.rst
--- a/docs/api/models.rst
+++ b/docs/api/models.rst
@@ -13,9 +13,6 @@ The :mod:`models` module
.. automodule:: kallithea.model.permission
:members:
-.. automodule:: kallithea.model.repo_permission
- :members:
-
.. automodule:: kallithea.model.repo
:members:
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
@@ -101,7 +101,6 @@ class RepoGroupsController(BaseControlle
_list = RepoGroup.query(sorted=True).all()
group_iter = RepoGroupList(_list, perm_level='admin')
repo_groups_data = []
- total_records = len(group_iter)
_tmpl_lookup = app_globals.mako_lookup
template = _tmpl_lookup.get_template('data_table/_dt_elements.html')
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
@@ -86,7 +86,6 @@ class UserGroupsController(BaseControlle
.all()
group_iter = UserGroupList(_list, perm_level='admin')
user_groups_data = []
- total_records = len(group_iter)
_tmpl_lookup = app_globals.mako_lookup
template = _tmpl_lookup.get_template('data_table/_dt_elements.html')
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
@@ -70,7 +70,6 @@ class UsersController(BaseController):
.all()
users_data = []
- total_records = len(c.users_list)
_tmpl_lookup = app_globals.mako_lookup
template = _tmpl_lookup.get_template('data_table/_dt_elements.html')
diff --git a/kallithea/controllers/changeset.py b/kallithea/controllers/changeset.py
--- a/kallithea/controllers/changeset.py
+++ b/kallithea/controllers/changeset.py
@@ -215,7 +215,6 @@ def create_cs_pr_comment(repo_name, revi
return {
'location': h.url('my_pullrequests'), # or repo pr list?
}
- raise HTTPFound(location=h.url('my_pullrequests')) # or repo pr list?
raise HTTPForbidden()
text = request.POST.get('text', '').strip()
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
@@ -54,7 +54,6 @@ class DbManage(object):
self.tests = tests
self.root = root
self.dburi = dbconf
- self.db_exists = False
self.cli_args = cli_args or {}
self.init_db(SESSION=SESSION)
diff --git a/kallithea/lib/exceptions.py b/kallithea/lib/exceptions.py
--- a/kallithea/lib/exceptions.py
+++ b/kallithea/lib/exceptions.py
@@ -74,9 +74,5 @@ class UserCreationError(Exception):
pass
-class RepositoryCreationError(Exception):
- pass
-
-
class HgsubversionImportError(Exception):
pass
diff --git a/kallithea/lib/middleware/sessionmiddleware.py b/kallithea/lib/middleware/sessionmiddleware.py
deleted file mode 100644
--- a/kallithea/lib/middleware/sessionmiddleware.py
+++ /dev/null
@@ -1,63 +0,0 @@
-# -*- coding: utf-8 -*-
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see .
-"""
-kallithea.lib.middleware.sessionmiddleware
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-session management middleware
-
-This file overrides Beaker's built-in SessionMiddleware
-class to automagically use secure cookies over HTTPS.
-
-Original Beaker SessionMiddleware class written by Ben Bangert
-"""
-
-from beaker.middleware import SessionMiddleware
-from beaker.session import SessionObject
-
-
-class SecureSessionMiddleware(SessionMiddleware):
- def __call__(self, environ, start_response):
- """
- This function's implementation is taken directly from Beaker,
- with HTTPS detection added. When accessed over HTTPS, force
- setting cookie's secure flag.
-
- The only difference from that original code is that we switch
- the secure option on and off depending on the URL scheme (first
- two lines). To avoid concurrency issues, we use a local options
- variable.
- """
- options = dict(self.options)
- options["secure"] = environ['wsgi.url_scheme'] == 'https'
-
- session = SessionObject(environ, **options)
- if environ.get('paste.registry'):
- if environ['paste.registry'].reglist:
- environ['paste.registry'].register(self.session, session)
- environ[self.environ_key] = session
- environ['beaker.get_session'] = self._get_session
-
- if 'paste.testing_variables' in environ and 'webtest_varname' in options:
- environ['paste.testing_variables'][options['webtest_varname']] = session
-
- def session_start_response(status, headers, exc_info=None):
- if session.accessed():
- session.persist()
- if session.__dict__['_headers']['set_cookie']:
- cookie = session.__dict__['_headers']['cookie_out']
- if cookie:
- headers.append(('Set-cookie', cookie))
- return start_response(status, headers, exc_info)
- return self.wrap_app(environ, session_start_response)
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
@@ -2,35 +2,6 @@ from kallithea.lib.rcmail.exceptions imp
from kallithea.lib.rcmail.response import MailResponse
-class Attachment(object):
- """
- Encapsulates file attachment information.
-
- :param filename: filename of attachment
- :param content_type: file mimetype
- :param data: the raw file data, either as string or file obj
- :param disposition: content-disposition (if any)
- """
-
- def __init__(self,
- filename=None,
- content_type=None,
- data=None,
- disposition=None):
-
- self.filename = filename
- self.content_type = content_type
- self.disposition = disposition or 'attachment'
- self._data = data
-
- @property
- def data(self):
- if isinstance(self._data, str):
- return self._data
- self._data = self._data.read()
- return self._data
-
-
class Message(object):
"""
Encapsulates an email message.
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
@@ -392,7 +392,7 @@ class MIMEPart(MIMEBase):
if mail.body is None:
return # only None, '' is still ok
- ctype, ctype_params = mail.content_encoding['Content-Type']
+ ctype, _ctype_params = mail.content_encoding['Content-Type']
cdisp, cdisp_params = mail.content_encoding['Content-Disposition']
assert ctype, ("Extract payload requires that mail.content_encoding "
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
@@ -258,8 +258,6 @@ class BaseRepository(object):
"""
Persists current changes made on this repository and returns newly
created changeset.
-
- :raises ``NothingChangedError``: if no changes has been made
"""
raise NotImplementedError
diff --git a/kallithea/lib/vcs/exceptions.py b/kallithea/lib/vcs/exceptions.py
--- a/kallithea/lib/vcs/exceptions.py
+++ b/kallithea/lib/vcs/exceptions.py
@@ -30,10 +30,6 @@ class TagDoesNotExistError(RepositoryErr
pass
-class BranchAlreadyExistError(RepositoryError):
- pass
-
-
class BranchDoesNotExistError(RepositoryError):
pass
@@ -50,10 +46,6 @@ class CommitError(RepositoryError):
pass
-class NothingChangedError(CommitError):
- pass
-
-
class NodeError(VCSError):
pass
@@ -88,7 +80,3 @@ class NodeAlreadyRemovedError(CommitErro
class ImproperArchiveTypeError(VCSError):
pass
-
-
-class CommandError(VCSError):
- pass
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
@@ -221,17 +221,6 @@ class BufferedGenerator(object):
return not self.worker.keep_reading.is_set()
@property
- def done_reading_event(self):
- """
- Done_reading does not mean that the iterator's buffer is empty.
- Iterator might have done reading from underlying source, but the read
- chunks might still be available for serving through .next() method.
-
- :returns: An threading.Event class instance.
- """
- return self.worker.EOF
-
- @property
def done_reading(self):
"""
Done_reading does not mean that the iterator's buffer is empty.
diff --git a/kallithea/lib/vcs/utils/lazy.py b/kallithea/lib/vcs/utils/lazy.py
--- a/kallithea/lib/vcs/utils/lazy.py
+++ b/kallithea/lib/vcs/utils/lazy.py
@@ -1,6 +1,3 @@
-import threading
-
-
class _Missing(object):
def __repr__(self):
@@ -44,21 +41,3 @@ class LazyProperty(object):
value = self._func(obj)
obj.__dict__[self.__name__] = value
return value
-
-
-class ThreadLocalLazyProperty(LazyProperty):
- """
- Same as above but uses thread local dict for cache storage.
- """
-
- def __get__(self, obj, klass=None):
- if obj is None:
- return self
- if not hasattr(obj, '__tl_dict__'):
- obj.__tl_dict__ = threading.local().__dict__
-
- value = obj.__tl_dict__.get(self.__name__, _missing)
- if value is _missing:
- value = self._func(obj)
- obj.__tl_dict__[self.__name__] = value
- return value
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
@@ -11,7 +11,7 @@ def get_dirs_for_path(*paths):
for path in paths:
head = path
while head:
- head, tail = os.path.split(head)
+ head, _tail = os.path.split(head)
if head:
yield head
else:
diff --git a/kallithea/model/notification.py b/kallithea/model/notification.py
--- a/kallithea/model/notification.py
+++ b/kallithea/model/notification.py
@@ -33,7 +33,6 @@ from tg import app_globals
from tg import tmpl_context as c
from tg.i18n import ugettext as _
-import kallithea
from kallithea.lib import helpers as h
from kallithea.model.db import User
@@ -149,7 +148,6 @@ class EmailNotificationModel(object):
def __init__(self):
super(EmailNotificationModel, self).__init__()
- self._template_root = kallithea.CONFIG['paths']['templates'][0]
self._tmpl_lookup = app_globals.mako_lookup
self.email_types = {
self.TYPE_CHANGESET_COMMENT: 'changeset_comment',
diff --git a/kallithea/model/repo_permission.py b/kallithea/model/repo_permission.py
deleted file mode 100644
--- a/kallithea/model/repo_permission.py
+++ /dev/null
@@ -1,100 +0,0 @@
-# -*- coding: utf-8 -*-
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see .
-"""
-kallithea.model.repo_permission
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-repository permission model for Kallithea
-
-This file was forked by the Kallithea project in July 2014.
-Original author and date, and relevant copyright and licensing information is below:
-:created_on: Oct 1, 2011
-:author: nvinot, marcink
-"""
-
-import logging
-
-from kallithea.model.db import Permission, Repository, Session, User, UserGroupRepoToPerm, UserRepoToPerm
-
-
-log = logging.getLogger(__name__)
-
-
-class RepositoryPermissionModel(object):
-
- def get_user_permission(self, repository, user):
- repository = Repository.guess_instance(repository)
- user = User.guess_instance(user)
-
- return UserRepoToPerm.query() \
- .filter(UserRepoToPerm.user == user) \
- .filter(UserRepoToPerm.repository == repository) \
- .scalar()
-
- def update_user_permission(self, repository, user, permission):
- permission = Permission.get_by_key(permission)
- current = self.get_user_permission(repository, user)
- if current:
- if current.permission is not permission:
- current.permission = permission
- else:
- p = UserRepoToPerm()
- p.user = user
- p.repository = repository
- p.permission = permission
- Session().add(p)
-
- def delete_user_permission(self, repository, user):
- current = self.get_user_permission(repository, user)
- if current:
- Session().delete(current)
-
- def get_users_group_permission(self, repository, users_group):
- return UserGroupRepoToPerm.query() \
- .filter(UserGroupRepoToPerm.users_group == users_group) \
- .filter(UserGroupRepoToPerm.repository == repository) \
- .scalar()
-
- def update_users_group_permission(self, repository, users_group,
- permission):
- permission = Permission.get_by_key(permission)
- current = self.get_users_group_permission(repository, users_group)
- if current:
- if current.permission is not permission:
- current.permission = permission
- else:
- p = UserGroupRepoToPerm()
- p.users_group = users_group
- p.repository = repository
- p.permission = permission
- Session().add(p)
-
- def delete_users_group_permission(self, repository, users_group):
- current = self.get_users_group_permission(repository, users_group)
- if current:
- Session().delete(current)
-
- def update_or_delete_user_permission(self, repository, user, permission):
- if permission:
- self.update_user_permission(repository, user, permission)
- else:
- self.delete_user_permission(repository, user)
-
- def update_or_delete_users_group_permission(self, repository, user_group,
- permission):
- if permission:
- self.update_users_group_permission(repository, user_group,
- permission)
- else:
- self.delete_users_group_permission(repository, user_group)
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
@@ -52,7 +52,7 @@ class SshKeyModel(object):
Will raise SshKeyModelException on errors
"""
try:
- keytype, pub, comment = ssh.parse_pub_key(public_key)
+ keytype, _pub, comment = ssh.parse_pub_key(public_key)
except ssh.SshKeyParseError as e:
raise SshKeyModelException(_('SSH key %r is invalid: %s') % (public_key, e.args[0]))
if not description.strip():
diff --git a/kallithea/model/validators.py b/kallithea/model/validators.py
--- a/kallithea/model/validators.py
+++ b/kallithea/model/validators.py
@@ -584,11 +584,11 @@ def ValidPerms(type_='repo'):
for k, v, t in perms_new:
try:
if t == 'user':
- self.user_db = User.query() \
+ _user_db = User.query() \
.filter(User.active == True) \
.filter(User.username == k).one()
if t == 'users_group':
- self.user_db = UserGroup.query() \
+ _user_db = UserGroup.query() \
.filter(UserGroup.users_group_active == True) \
.filter(UserGroup.users_group_name == k).one()