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
@@ -28,7 +28,7 @@ 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.lib.utils2 import ask_ok, safe_str
from kallithea.model.db import Repository, Ui
from kallithea.model.meta import Session
from kallithea.model.scm import ScmModel
@@ -74,7 +74,7 @@ def repo_update_metadata(repositories):
if not repositories:
repo_list = Repository.query().all()
else:
- repo_names = [safe_unicode(n.strip()) for n in repositories]
+ repo_names = [n.strip() for n in repositories]
repo_list = list(Repository.query()
.filter(Repository.repo_name.in_(repo_names)))
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
@@ -182,7 +182,10 @@ class GistsController(BaseController):
log.error(traceback.format_exc())
raise HTTPNotFound()
if format == 'raw':
- content = '\n\n'.join([safe_unicode(f.content) for f in c.files if (f_path is None or safe_unicode(f.path) == f_path)])
+ content = '\n\n'.join(
+ safe_unicode(f.content)
+ for f in c.files if (f_path is None or f.path == f_path)
+ )
response.content_type = 'text/plain'
return content
return render('admin/gists/show.html')
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
@@ -40,7 +40,7 @@ from kallithea.config.routing import url
from kallithea.lib import helpers as h
from kallithea.lib.auth import HasPermissionAny, HasRepoGroupPermissionLevel, HasRepoGroupPermissionLevelDecorator, LoginRequired
from kallithea.lib.base import BaseController, render
-from kallithea.lib.utils2 import safe_int, safe_unicode
+from kallithea.lib.utils2 import safe_int
from kallithea.model.db import RepoGroup, Repository
from kallithea.model.forms import RepoGroupForm, RepoGroupPermsForm
from kallithea.model.meta import Session
@@ -116,7 +116,7 @@ class RepoGroupsController(BaseControlle
)
for repo_gr in group_iter:
- children_groups = [safe_unicode(g.name) for g in repo_gr.parents] + [safe_unicode(repo_gr.name)]
+ children_groups = [g.name for g in repo_gr.parents] + [repo_gr.name]
repo_count = repo_gr.repositories.count()
repo_groups_data.append({
"raw_name": repo_gr.group_name,
diff --git a/kallithea/controllers/changeset.py b/kallithea/controllers/changeset.py
--- a/kallithea/controllers/changeset.py
+++ b/kallithea/controllers/changeset.py
@@ -257,7 +257,7 @@ def create_cs_pr_comment(repo_name, revi
Session().commit()
data = {
- 'target_id': h.safeid(h.safe_unicode(request.POST.get('f_path'))),
+ 'target_id': h.safeid(request.POST.get('f_path')),
}
if comment is not None:
c.comment = comment
diff --git a/kallithea/controllers/feed.py b/kallithea/controllers/feed.py
--- a/kallithea/controllers/feed.py
+++ b/kallithea/controllers/feed.py
@@ -96,7 +96,7 @@ class FeedController(BaseRepoController)
desc_msg.append('\n\n')
desc_msg.append(safe_unicode(raw_diff))
desc_msg.append('')
- return [safe_unicode(chunk) for chunk in desc_msg]
+ return desc_msg
def _feed(self, repo_name, feeder):
"""Produce a simple feed"""
diff --git a/kallithea/lib/auth.py b/kallithea/lib/auth.py
--- a/kallithea/lib/auth.py
+++ b/kallithea/lib/auth.py
@@ -42,7 +42,7 @@ from kallithea import __platform__, is_u
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 ascii_bytes, ascii_str, safe_bytes, safe_unicode
+from kallithea.lib.utils2 import ascii_bytes, ascii_str, safe_bytes
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)
@@ -817,10 +817,6 @@ class HasPermissionAnyMiddleware(object)
self.required_perms = set(perms)
def __call__(self, authuser, repo_name, purpose=None):
- # repo_name MUST be unicode, since we handle keys in ok
- # dict by unicode
- repo_name = safe_unicode(repo_name)
-
try:
ok = authuser.permissions['repositories'][repo_name] in self.required_perms
except KeyError:
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
@@ -29,7 +29,7 @@ import logging
from kallithea.lib import auth_modules
from kallithea.lib.compat import hybrid_property
-from kallithea.lib.utils2 import safe_str, safe_unicode, str2bool
+from kallithea.lib.utils2 import safe_str, str2bool
from kallithea.model.db import Setting
@@ -199,8 +199,8 @@ class KallitheaAuthPlugin(auth_modules.K
user_data = {
'username': username,
- 'firstname': safe_unicode(firstname or username),
- 'lastname': safe_unicode(lastname or ''),
+ 'firstname': firstname or username,
+ 'lastname': lastname or '',
'groups': [],
'email': email or '',
'admin': admin or False,
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,7 +31,7 @@ import logging
from kallithea.lib import auth_modules
from kallithea.lib.compat import hybrid_property
from kallithea.lib.exceptions import LdapConnectionError, LdapImportError, LdapPasswordError, LdapUsernameError
-from kallithea.lib.utils2 import safe_str, safe_unicode
+from kallithea.lib.utils2 import safe_str
log = logging.getLogger(__name__)
@@ -338,8 +338,8 @@ class KallitheaAuthPlugin(auth_modules.K
user_data = {
'username': username,
- 'firstname': safe_unicode(get_ldap_attr('attr_firstname') or firstname),
- 'lastname': safe_unicode(get_ldap_attr('attr_lastname') or lastname),
+ 'firstname': get_ldap_attr('attr_firstname') or firstname,
+ 'lastname': get_ldap_attr('attr_lastname') or lastname,
'groups': [],
'email': get_ldap_attr('attr_email') or email,
'admin': admin,
diff --git a/kallithea/lib/base.py b/kallithea/lib/base.py
--- a/kallithea/lib/base.py
+++ b/kallithea/lib/base.py
@@ -553,7 +553,7 @@ class BaseRepoController(BaseController)
return
log.debug('Found repository in database %s with state `%s`',
- safe_unicode(_dbr), safe_unicode(_dbr.repo_state))
+ _dbr, _dbr.repo_state)
route = getattr(request.environ.get('routes.route'), 'name', '')
# allow to delete repos that are somehow damages in filesystem
diff --git a/kallithea/lib/helpers.py b/kallithea/lib/helpers.py
--- a/kallithea/lib/helpers.py
+++ b/kallithea/lib/helpers.py
@@ -205,8 +205,6 @@ def FID(raw_id, path):
class _FilesBreadCrumbs(object):
def __call__(self, repo_name, rev, paths):
- if isinstance(paths, str):
- paths = safe_unicode(paths)
url_l = [link_to(repo_name, url('files_home',
repo_name=repo_name,
revision=rev, f_path=''),
@@ -954,7 +952,7 @@ def changed_tooltip(nodes):
suf = ''
if len(nodes) > 30:
suf = '
' + _(' and %s more') % (len(nodes) - 30)
- return literal(pref + '
'.join([safe_unicode(x.path)
+ return literal(pref + '
'.join([x.path
for x in nodes[:30]]) + suf)
else:
return ': ' + _('No files')
diff --git a/kallithea/lib/hooks.py b/kallithea/lib/hooks.py
--- a/kallithea/lib/hooks.py
+++ b/kallithea/lib/hooks.py
@@ -34,7 +34,7 @@ import mercurial.scmutil
from kallithea.lib import helpers as h
from kallithea.lib.exceptions import UserCreationError
from kallithea.lib.utils import action_logger, make_ui
-from kallithea.lib.utils2 import HookEnvironmentError, ascii_str, get_hook_environment, safe_bytes, safe_str, safe_unicode
+from kallithea.lib.utils2 import HookEnvironmentError, ascii_str, get_hook_environment, safe_bytes, safe_str
from kallithea.lib.vcs.backends.base import EmptyChangeset
from kallithea.model.db import Repository, User
@@ -312,7 +312,6 @@ def _hook_environment(repo_path):
#logging.config.fileConfig(ini_file_path) # Note: we are in a different process - don't use configured logging
kallithea.config.middleware.make_app(kallithea.CONFIG.global_conf, **kallithea.CONFIG.local_conf)
- repo_path = safe_unicode(repo_path)
# fix if it's not a bare repo
if repo_path.endswith(os.sep + '.git'):
repo_path = repo_path[:-5]
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
@@ -77,8 +77,7 @@ class WhooshIndexingDaemon(object):
# filter repo list
if repo_list:
- # Fix non-ascii repo names to unicode
- repo_list = set(safe_unicode(repo_name) for repo_name in repo_list)
+ repo_list = set(repo_list)
self.filtered_repo_paths = {}
for repo_name, repo in self.repo_paths.items():
if repo_name in repo_list:
@@ -110,7 +109,7 @@ class WhooshIndexingDaemon(object):
self.initial = False
def _get_index_revision(self, repo):
- db_repo = Repository.get_by_repo_name(safe_unicode(repo.name))
+ db_repo = Repository.get_by_repo_name(repo.name)
landing_rev = 'tip'
if db_repo:
_rev_type, _rev = db_repo.landing_rev
@@ -197,13 +196,12 @@ class WhooshIndexingDaemon(object):
u_content = u''
indexed += 1
- p = safe_unicode(path)
writer.add_document(
- fileid=p,
- owner=unicode(repo.contact),
- repository_rawname=safe_unicode(repo_name),
- repository=safe_unicode(repo_name),
- path=p,
+ fileid=path,
+ owner=repo.contact,
+ repository_rawname=repo_name,
+ repository=repo_name,
+ path=path,
content=u_content,
modtime=self.get_node_mtime(node),
extension=node.extension
@@ -238,18 +236,18 @@ class WhooshIndexingDaemon(object):
indexed += 1
log.debug(' >> %s %s/%s', cs, indexed, total)
writer.add_document(
- raw_id=unicode(cs.raw_id),
- owner=unicode(repo.contact),
+ raw_id=cs.raw_id,
+ owner=repo.contact,
date=cs._timestamp,
- repository_rawname=safe_unicode(repo_name),
- repository=safe_unicode(repo_name),
+ repository_rawname=repo_name,
+ repository=repo_name,
author=cs.author,
message=cs.message,
last=cs.last,
- added=u' '.join([safe_unicode(node.path) for node in cs.added]).lower(),
- removed=u' '.join([safe_unicode(node.path) for node in cs.removed]).lower(),
- changed=u' '.join([safe_unicode(node.path) for node in cs.changed]).lower(),
- parents=u' '.join([cs.raw_id for cs in cs.parents]),
+ added=u' '.join(node.path for node in cs.added).lower(),
+ removed=u' '.join(node.path for node in cs.removed).lower(),
+ changed=u' '.join(node.path for node in cs.changed).lower(),
+ parents=u' '.join(cs.raw_id for cs in cs.parents),
)
return indexed
@@ -391,9 +389,7 @@ class WhooshIndexingDaemon(object):
ri_cnt = 0 # indexed
riwc_cnt = 0 # indexed with content
for path in self.get_paths(repo):
- path = safe_unicode(path)
if path in to_index or path not in indexed_paths:
-
# This is either a file that's changed, or a new file
# that wasn't indexed before. So index it!
i, iwc = self.add_doc(writer, path, repo, repo_name)
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
@@ -33,7 +33,7 @@ import traceback
from webob import Request, Response, exc
import kallithea
-from kallithea.lib.utils2 import ascii_bytes, safe_unicode
+from kallithea.lib.utils2 import ascii_bytes
from kallithea.lib.vcs import subprocessio
@@ -87,7 +87,6 @@ class GitRepository(object):
:param path:
"""
- path = safe_unicode(path)
assert path.startswith('/' + self.repo_name + '/')
return path[len(self.repo_name) + 2:].strip('/')
diff --git a/kallithea/lib/middleware/simplegit.py b/kallithea/lib/middleware/simplegit.py
--- a/kallithea/lib/middleware/simplegit.py
+++ b/kallithea/lib/middleware/simplegit.py
@@ -35,7 +35,6 @@ from kallithea.lib.base import BaseVCSCo
from kallithea.lib.hooks import log_pull_action
from kallithea.lib.middleware.pygrack import make_wsgi_app
from kallithea.lib.utils import make_ui
-from kallithea.lib.utils2 import safe_unicode
from kallithea.model.db import Repository
@@ -64,7 +63,7 @@ class SimpleGit(BaseVCSController):
class parsed_request(object):
# See https://git-scm.com/book/en/v2/Git-Internals-Transfer-Protocols#_the_smart_protocol
- repo_name = safe_unicode(m.group(1).rstrip('/'))
+ repo_name = m.group(1).rstrip('/')
cmd = m.group(2)
query_string = environ['QUERY_STRING']
diff --git a/kallithea/lib/middleware/simplehg.py b/kallithea/lib/middleware/simplehg.py
--- a/kallithea/lib/middleware/simplehg.py
+++ b/kallithea/lib/middleware/simplehg.py
@@ -36,7 +36,7 @@ import mercurial.hgweb
from kallithea.lib.base import BaseVCSController, get_path_info
from kallithea.lib.utils import make_ui
-from kallithea.lib.utils2 import safe_bytes, safe_str, safe_unicode
+from kallithea.lib.utils2 import safe_bytes, safe_str
log = logging.getLogger(__name__)
@@ -105,7 +105,7 @@ class SimpleHg(BaseVCSController):
return None
class parsed_request(object):
- repo_name = safe_unicode(path_info[1:].rstrip('/'))
+ repo_name = path_info[1:].rstrip('/')
query_string = environ['QUERY_STRING']
diff --git a/kallithea/lib/utils.py b/kallithea/lib/utils.py
--- a/kallithea/lib/utils.py
+++ b/kallithea/lib/utils.py
@@ -40,7 +40,7 @@ from tg.i18n import ugettext as _
import kallithea.config.conf
from kallithea.lib.exceptions import HgsubversionImportError
-from kallithea.lib.utils2 import ascii_bytes, aslist, get_current_authuser, safe_bytes, safe_str, safe_unicode
+from kallithea.lib.utils2 import ascii_bytes, aslist, get_current_authuser, safe_bytes, safe_str
from kallithea.lib.vcs.backends.git.repository import GitRepository
from kallithea.lib.vcs.backends.hg.repository import MercurialRepository
from kallithea.lib.vcs.conf import settings
@@ -150,7 +150,7 @@ def action_logger(user, action, repo, ip
user_log = UserLog()
user_log.user_id = user_obj.user_id
user_log.username = user_obj.username
- user_log.action = safe_unicode(action)
+ user_log.action = action
user_log.repository = repo_obj
user_log.repository_name = repo_name
@@ -160,7 +160,7 @@ def action_logger(user, action, repo, ip
meta.Session().add(user_log)
log.info('Logging action:%s on %s by user:%s ip:%s',
- action, safe_unicode(repo), user_obj, ipaddr)
+ action, repo, user_obj, ipaddr)
if commit:
meta.Session().commit()
@@ -480,8 +480,7 @@ def repo2db_mapper(initial_repo_dict, re
for name, repo in initial_repo_dict.items():
group = map_groups(name)
- unicode_name = safe_unicode(name)
- db_repo = repo_model.get_by_repo_name(unicode_name)
+ db_repo = repo_model.get_by_repo_name(name)
# found repo that is on filesystem not in Kallithea database
if not db_repo:
log.info('repository %s not found, creating now', name)
@@ -517,9 +516,8 @@ def repo2db_mapper(initial_repo_dict, re
removed = []
# remove from database those repositories that are not in the filesystem
- unicode_initial_repo_names = set(safe_unicode(name) for name in initial_repo_dict)
for repo in sa.query(Repository).all():
- if repo.repo_name not in unicode_initial_repo_names:
+ if repo.repo_name not in initial_repo_dict:
if remove_obsolete:
log.debug("Removing non-existing repository found in db `%s`",
repo.repo_name)
diff --git a/kallithea/lib/utils2.py b/kallithea/lib/utils2.py
--- a/kallithea/lib/utils2.py
+++ b/kallithea/lib/utils2.py
@@ -322,19 +322,19 @@ def credentials_filter(uri):
def get_clone_url(clone_uri_tmpl, prefix_url, repo_name, repo_id, username=None):
parsed_url = urlobject.URLObject(prefix_url)
- prefix = safe_unicode(urllib.parse.unquote(parsed_url.path.rstrip('/')))
+ prefix = urllib.parse.unquote(parsed_url.path.rstrip('/'))
try:
system_user = pwd.getpwuid(os.getuid()).pw_name
except Exception: # TODO: support all systems - especially Windows
system_user = 'kallithea' # hardcoded default value ...
args = {
'scheme': parsed_url.scheme,
- 'user': safe_unicode(urllib.parse.quote(safe_str(username or ''))),
+ 'user': urllib.parse.quote(safe_str(username or '')),
'netloc': parsed_url.netloc + prefix, # like "hostname:port/prefix" (with optional ":port" and "/prefix")
'prefix': prefix, # undocumented, empty or starting with /
'repo': repo_name,
'repoid': str(repo_id),
- 'system_user': safe_unicode(system_user),
+ 'system_user': system_user,
'hostname': parsed_url.hostname,
}
url = re.sub('{([^{}]+)}', lambda m: args.get(m.group(1), m.group(0)), clone_uri_tmpl)
@@ -344,7 +344,7 @@ def get_clone_url(clone_uri_tmpl, prefix
if not url_obj.username:
url_obj = url_obj.with_username(None)
- return safe_unicode(url_obj)
+ return str(url_obj)
def get_changeset_safe(repo, rev):
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
@@ -15,7 +15,7 @@ import itertools
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 import author_email, author_name
from kallithea.lib.vcs.utils.helpers import get_dict_for_attrs
from kallithea.lib.vcs.utils.lazy import LazyProperty
@@ -376,9 +376,9 @@ class BaseChangeset(object):
message=self.message,
date=self.date,
author=self.author,
- added=[safe_unicode(el.path) for el in self.added],
- changed=[safe_unicode(el.path) for el in self.changed],
- removed=[safe_unicode(el.path) for el in self.removed],
+ added=[el.path for el in self.added],
+ changed=[el.path for el in self.changed],
+ removed=[el.path for el in self.removed],
)
else:
return dict(
@@ -643,9 +643,9 @@ class BaseChangeset(object):
data = get_dict_for_attrs(self, ['raw_id', 'short_id',
'revision', 'date', 'message'])
data['author'] = {'name': self.author_name, 'email': self.author_email}
- data['added'] = [safe_unicode(node.path) for node in self.added]
- data['changed'] = [safe_unicode(node.path) for node in self.changed]
- data['removed'] = [safe_unicode(node.path) for node in self.removed]
+ data['added'] = [node.path for node in self.added]
+ data['changed'] = [node.path for node in self.changed]
+ data['removed'] = [node.path for node in self.removed]
return data
@LazyProperty
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
@@ -54,7 +54,7 @@ class GitRepository(BaseRepository):
def __init__(self, repo_path, create=False, src_url=None,
update_after_clone=False, bare=False):
- self.path = safe_unicode(abspath(repo_path))
+ self.path = abspath(repo_path)
self.repo = self._get_repo(create, src_url, update_after_clone, bare)
self.bare = self.repo.bare
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
@@ -18,7 +18,7 @@ import os
from kallithea.lib.hooks import log_pull_action
from kallithea.lib.utils import make_ui
from kallithea.lib.vcs.backends.ssh import BaseSshHandler
-from kallithea.lib.vcs.utils import safe_str, safe_unicode
+from kallithea.lib.vcs.utils import safe_str
log = logging.getLogger(__name__)
@@ -56,7 +56,7 @@ class GitSshHandler(BaseSshHandler):
ssh_command_parts[0] in ['git-upload-pack', 'git-receive-pack'] and
ssh_command_parts[1].startswith('/')
):
- return cls(safe_unicode(ssh_command_parts[1][1:]), ssh_command_parts[0])
+ return cls(ssh_command_parts[1][1:], ssh_command_parts[0])
return None
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
@@ -19,7 +19,7 @@ import mercurial.wireprotoserver
from kallithea.lib.utils import make_ui
from kallithea.lib.vcs.backends.ssh import BaseSshHandler
-from kallithea.lib.vcs.utils import safe_bytes, safe_unicode
+from kallithea.lib.vcs.utils import safe_bytes
log = logging.getLogger(__name__)
@@ -47,7 +47,7 @@ class MercurialSshHandler(BaseSshHandler
>>> MercurialSshHandler.make(shlex.split('git-upload-pack "/foo"')) # not handled here
"""
if ssh_command_parts[:2] == ['hg', '-R'] and ssh_command_parts[3:] == ['serve', '--stdio']:
- return cls(safe_unicode(ssh_command_parts[2]))
+ return cls(ssh_command_parts[2])
return None
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
@@ -126,7 +126,7 @@ class Node(object):
Returns name of the node so if its path
then only last part is returned.
"""
- return safe_unicode(self.path.rstrip('/').split('/')[-1])
+ return self.path.rstrip('/').split('/')[-1]
def _get_kind(self):
return self._kind
@@ -605,5 +605,5 @@ class SubModuleNode(Node):
Returns name of the node so if its path
then only last part is returned.
"""
- org = safe_unicode(self.path.rstrip('/').split('/')[-1])
+ org = self.path.rstrip('/').rsplit('/', 1)[-1]
return u'%s @ %s' % (org, self.changeset.short_id)
diff --git a/kallithea/model/comment.py b/kallithea/model/comment.py
--- a/kallithea/model/comment.py
+++ b/kallithea/model/comment.py
@@ -31,7 +31,7 @@ from collections import defaultdict
from tg.i18n import ugettext as _
from kallithea.lib import helpers as h
-from kallithea.lib.utils2 import extract_mentioned_users, safe_unicode
+from kallithea.lib.utils2 import extract_mentioned_users
from kallithea.model.db import ChangesetComment, PullRequest, Repository, User
from kallithea.model.meta import Session
from kallithea.model.notification import NotificationModel
@@ -81,11 +81,10 @@ class ChangesetCommentsModel(object):
repo_name=repo.repo_name,
revision=revision,
anchor='comment-%s' % comment.comment_id)
- subj = safe_unicode(
- h.link_to('Re changeset: %(desc)s %(line)s' %
+ subj = h.link_to(
+ 'Re changeset: %(desc)s %(line)s' %
{'desc': desc, 'line': line},
- comment_url)
- )
+ comment_url)
# get the current participants of this changeset
recipients = _list_changeset_commenters(revision)
# add changeset author if it's known locally
@@ -127,13 +126,12 @@ class ChangesetCommentsModel(object):
h.canonical_hostname()))
comment_url = pull_request.url(canonical=True,
anchor='comment-%s' % comment.comment_id)
- subj = safe_unicode(
- h.link_to('Re pull request %(pr_nice_id)s: %(desc)s %(line)s' %
+ subj = h.link_to(
+ 'Re pull request %(pr_nice_id)s: %(desc)s %(line)s' %
{'desc': desc,
'pr_nice_id': comment.pull_request.nice_id(),
'line': line},
- comment_url)
- )
+ comment_url)
# get the current participants of this pull request
recipients = _list_pull_request_commenters(pull_request)
recipients.append(pull_request.owner)
diff --git a/kallithea/model/db.py b/kallithea/model/db.py
--- a/kallithea/model/db.py
+++ b/kallithea/model/db.py
@@ -328,9 +328,9 @@ class Setting(Base, BaseDbModel):
info = {
'modules': sorted(mods, key=lambda k: k[0].lower()),
'py_version': platform.python_version(),
- 'platform': safe_unicode(platform.platform()),
+ 'platform': platform.platform(),
'kallithea_version': kallithea.__version__,
- 'git_version': safe_unicode(check_git_version()),
+ 'git_version': str(check_git_version()),
'git_path': kallithea.CONFIG.get('git_path')
}
return info
@@ -1162,7 +1162,7 @@ class Repository(Base, BaseDbModel):
# names in the database, but that eventually needs to be converted
# into a valid system path
p += self.repo_name.split(Repository.url_sep())
- return os.path.join(*(safe_unicode(d) for d in p))
+ return os.path.join(*p)
@property
def cache_keys(self):
@@ -2282,7 +2282,7 @@ class PullRequest(Base, BaseDbModel):
@revisions.setter
def revisions(self, val):
- self._revisions = safe_unicode(':'.join(val))
+ self._revisions = ':'.join(val)
@property
def org_ref_parts(self):
diff --git a/kallithea/model/gist.py b/kallithea/model/gist.py
--- a/kallithea/model/gist.py
+++ b/kallithea/model/gist.py
@@ -33,7 +33,7 @@ import time
import traceback
from kallithea.lib import ext_json
-from kallithea.lib.utils2 import AttributeDict, ascii_bytes, safe_int, safe_unicode, time_to_datetime
+from kallithea.lib.utils2 import AttributeDict, ascii_bytes, safe_int, time_to_datetime
from kallithea.model.db import Gist, Session, User
from kallithea.model.repo import RepoModel
from kallithea.model.scm import ScmModel
@@ -120,7 +120,7 @@ class GistModel(object):
gist.gist_access_id = gist_access_id
gist.owner_id = owner.user_id
gist.gist_expires = gist_expires
- gist.gist_type = safe_unicode(gist_type)
+ gist.gist_type = gist_type
Session().add(gist)
Session().flush() # make database assign gist.gist_id
if gist_type == Gist.GIST_PUBLIC:
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
@@ -33,7 +33,7 @@ from tg import request
from tg.i18n import ugettext as _
from kallithea.lib import helpers as h
-from kallithea.lib.utils2 import ascii_bytes, extract_mentioned_users, safe_unicode
+from kallithea.lib.utils2 import ascii_bytes, extract_mentioned_users
from kallithea.model.db import ChangesetStatus, PullRequest, PullRequestReviewer, User
from kallithea.model.meta import Session
from kallithea.model.notification import NotificationModel
@@ -68,14 +68,12 @@ class PullRequestModel(object):
threading = ['%s-pr-%s@%s' % (pr.other_repo.repo_name,
pr.pull_request_id,
h.canonical_hostname())]
- subject = safe_unicode(
- h.link_to(
- _('%(user)s wants you to review pull request %(pr_nice_id)s: %(pr_title)s') %
+ subject = h.link_to(
+ _('%(user)s wants you to review pull request %(pr_nice_id)s: %(pr_title)s') %
{'user': user.username,
'pr_title': pr.title,
'pr_nice_id': pr.nice_id()},
- pr_url)
- )
+ pr_url)
body = pr.description
_org_ref_type, org_ref_name, _org_rev = pr.org_ref.split(':')
_other_ref_type, other_ref_name, _other_rev = pr.other_ref.split(':')
diff --git a/kallithea/model/repo.py b/kallithea/model/repo.py
--- a/kallithea/model/repo.py
+++ b/kallithea/model/repo.py
@@ -39,7 +39,7 @@ from kallithea.lib.caching_query import
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.utils2 import LazyProperty, get_current_authuser, obfuscate_url_pw, remove_prefix, safe_str
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)
@@ -337,8 +337,8 @@ class RepoModel(object):
fork_of = Repository.guess_instance(fork_of)
repo_group = RepoGroup.guess_instance(repo_group)
try:
- repo_name = safe_unicode(repo_name)
- description = safe_unicode(description)
+ repo_name = repo_name
+ description = description
# repo name is just a name of repository
# while repo_name_full is a full qualified name that is combined
# with name and path of group
@@ -653,7 +653,7 @@ class RepoModel(object):
raise Exception('This path %s is a valid group' % repo_path)
log.info('creating repo %s in %s from url: `%s`',
- repo_name, safe_unicode(repo_path),
+ repo_name, repo_path,
obfuscate_url_pw(clone_uri))
backend = get_backend(repo_type)
@@ -674,7 +674,7 @@ class RepoModel(object):
raise Exception('Not supported repo_type %s expected hg/git' % repo_type)
log.debug('Created repo %s with %s backend',
- safe_unicode(repo_name), safe_unicode(repo_type))
+ repo_name, repo_type)
return repo
def _rename_filesystem_repo(self, old, new):
diff --git a/kallithea/model/scm.py b/kallithea/model/scm.py
--- a/kallithea/model/scm.py
+++ b/kallithea/model/scm.py
@@ -41,7 +41,7 @@ from kallithea.lib.auth import HasPermis
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_bytes, safe_str, safe_unicode, set_hook_environment
+from kallithea.lib.utils2 import safe_bytes, safe_str, set_hook_environment
from kallithea.lib.vcs import get_backend
from kallithea.lib.vcs.backends.base import EmptyChangeset
from kallithea.lib.vcs.exceptions import RepositoryError
@@ -401,10 +401,6 @@ class ScmModel(object):
# in any other case this will throw exceptions and deny commit
content = safe_str(content)
path = safe_str(f_path)
- # message and author needs to be unicode
- # proper backend should then translate that into required type
- message = safe_unicode(message)
- author = safe_unicode(author)
imc = IMC(repo)
imc.change(FileNode(path, content, mode=cs.get_file_mode(f_path)))
try:
@@ -491,9 +487,10 @@ class ScmModel(object):
content = content.read()
processed_nodes.append((f_path, content))
- message = safe_unicode(message)
+ message = message
committer = user.full_contact
- author = safe_unicode(author) if author else committer
+ if not author:
+ author = committer
IMC = self._get_IMC_module(scm_instance.alias)
imc = IMC(scm_instance)
@@ -534,9 +531,10 @@ class ScmModel(object):
user = User.guess_instance(user)
scm_instance = repo.scm_instance_no_cache()
- message = safe_unicode(message)
+ message = message
committer = user.full_contact
- author = safe_unicode(author) if author else committer
+ if not author:
+ author = committer
imc_class = self._get_IMC_module(scm_instance.alias)
imc = imc_class(scm_instance)
@@ -614,9 +612,10 @@ class ScmModel(object):
content = nodes[f_path].get('content')
processed_nodes.append((f_path, content))
- message = safe_unicode(message)
+ message = message
committer = user.full_contact
- author = safe_unicode(author) if author else committer
+ if not author:
+ author = committer
IMC = self._get_IMC_module(scm_instance.alias)
imc = IMC(scm_instance)
diff --git a/kallithea/model/user.py b/kallithea/model/user.py
--- a/kallithea/model/user.py
+++ b/kallithea/model/user.py
@@ -38,7 +38,7 @@ from tg.i18n import ugettext as _
from kallithea.lib.caching_query import FromCache
from kallithea.lib.exceptions import DefaultUserException, UserOwnsReposException
-from kallithea.lib.utils2 import generate_api_key, get_current_authuser, safe_unicode
+from kallithea.lib.utils2 import generate_api_key, get_current_authuser
from kallithea.model.db import Permission, User, UserEmailMap, UserIpMap, UserToPerm
from kallithea.model.meta import Session
@@ -142,10 +142,8 @@ class UserModel(object):
new_user.admin = admin
new_user.email = email
new_user.active = active
- new_user.extern_name = safe_unicode(extern_name) \
- if extern_name else None
- new_user.extern_type = safe_unicode(extern_type) \
- if extern_type else None
+ new_user.extern_name = extern_name
+ new_user.extern_type = extern_type
new_user.name = firstname
new_user.lastname = lastname
diff --git a/kallithea/templates/admin/gists/edit.html b/kallithea/templates/admin/gists/edit.html
--- a/kallithea/templates/admin/gists/edit.html
+++ b/kallithea/templates/admin/gists/edit.html
@@ -67,8 +67,8 @@
% for cnt, file in enumerate(c.files):