Mercurial > kallithea
changeset 8028:fd0998635e83
cleanup: drop some unnecessary use of safe_str
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Mon, 16 Dec 2019 03:22:22 +0100 |
parents | 38749d420fbd |
children | 04aea77a49fa |
files | kallithea/lib/celerylib/__init__.py kallithea/lib/helpers.py kallithea/model/db.py kallithea/model/scm.py kallithea/model/ssh_key.py |
diffstat | 5 files changed, 11 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/lib/celerylib/__init__.py Mon Dec 16 01:51:47 2019 +0100 +++ b/kallithea/lib/celerylib/__init__.py Mon Dec 16 03:22:22 2019 +0100 @@ -95,7 +95,7 @@ func_name = str(func.__name__) if hasattr(func, '__name__') else str(func) lockkey = 'task_%s.lock' % \ - md5(func_name + '-' + '-'.join(map(safe_str, params))).hexdigest() + md5(safe_str(func_name + '-' + '-'.join(unicode(x) for x in params))).hexdigest() return lockkey
--- a/kallithea/lib/helpers.py Mon Dec 16 01:51:47 2019 +0100 +++ b/kallithea/lib/helpers.py Mon Dec 16 03:22:22 2019 +0100 @@ -942,7 +942,7 @@ .replace('{md5email}', hashlib.md5(safe_str(email_address).lower()).hexdigest()) \ .replace('{netloc}', parsed_url.netloc) \ .replace('{scheme}', parsed_url.scheme) \ - .replace('{size}', safe_str(size)) + .replace('{size}', str(size)) return url
--- a/kallithea/model/db.py Mon Dec 16 01:51:47 2019 +0100 +++ b/kallithea/model/db.py Mon Dec 16 03:22:22 2019 +0100 @@ -136,8 +136,10 @@ return None if isinstance(value, cls): return value - if isinstance(value, (int, long)) or safe_str(value).isdigit(): + if isinstance(value, (int, long)): return cls.get(value) + if isinstance(value, basestring) and value.isdigit(): + return cls.get(int(value)) if callback is not None: return callback(value)
--- a/kallithea/model/scm.py Mon Dec 16 01:51:47 2019 +0100 +++ b/kallithea/model/scm.py Mon Dec 16 03:22:22 2019 +0100 @@ -139,9 +139,11 @@ cls = Repository if isinstance(instance, cls): return instance - elif isinstance(instance, int) or safe_str(instance).isdigit(): + elif isinstance(instance, int): return cls.get(instance) elif isinstance(instance, basestring): + if instance.isdigit(): + return cls.get(int(instance)) return cls.get_by_repo_name(instance) elif instance is not None: raise Exception('given object must be int, basestr or Instance'
--- a/kallithea/model/ssh_key.py Mon Dec 16 01:51:47 2019 +0100 +++ b/kallithea/model/ssh_key.py Mon Dec 16 03:22:22 2019 +0100 @@ -29,7 +29,7 @@ from tg.i18n import ugettext as _ from kallithea.lib import ssh -from kallithea.lib.utils2 import safe_str, str2bool +from kallithea.lib.utils2 import str2bool from kallithea.model.db import User, UserSshKeys from kallithea.model.meta import Session @@ -53,7 +53,7 @@ try: keytype, pub, comment = ssh.parse_pub_key(public_key) except ssh.SshKeyParseError as e: - raise SshKeyModelException(_('SSH key %r is invalid: %s') % (safe_str(public_key), e.message)) + raise SshKeyModelException(_('SSH key %r is invalid: %s') % (public_key, e.message)) if not description.strip(): description = comment.strip() @@ -86,7 +86,7 @@ ssh_key = ssh_key.scalar() if ssh_key is None: - raise SshKeyModelException(_('SSH key %r not found') % safe_str(public_key)) + raise SshKeyModelException(_('SSH key %r not found') % public_key) Session().delete(ssh_key) def get_ssh_keys(self, user):