Changeset - fd0998635e83
[Not reviewed]
default
0 5 0
Mads Kiilerich - 6 years ago 2019-12-16 03:22:22
mads@kiilerich.com
Grafted from: 0f717ec3f5a8
cleanup: drop some unnecessary use of safe_str
5 files changed with 11 insertions and 7 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/celerylib/__init__.py
Show inline comments
 
@@ -95,7 +95,7 @@ def __get_lockkey(func, *fargs, **fkwarg
 
    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
 

	
 

	
kallithea/lib/helpers.py
Show inline comments
 
@@ -942,7 +942,7 @@ def gravatar_url(email_address, size=30,
 
               .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
 

	
 

	
kallithea/model/db.py
Show inline comments
 
@@ -136,8 +136,10 @@ class BaseDbModel(object):
 
            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)
 

	
kallithea/model/scm.py
Show inline comments
 
@@ -139,9 +139,11 @@ class ScmModel(object):
 
        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'
kallithea/model/ssh_key.py
Show inline comments
 
@@ -29,7 +29,7 @@ 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.lib.utils2 import str2bool
 
from kallithea.model.db import User, UserSshKeys
 
from kallithea.model.meta import Session
 

	
 
@@ -53,7 +53,7 @@ class SshKeyModel(object):
 
        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 @@ class SshKeyModel(object):
 

	
 
        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):
0 comments (0 inline, 0 general)