##// END OF EJS Templates
cleanup: drop some unnecessary use of safe_str
Mads Kiilerich -
r7908:fd099863 default
parent child Browse files
Show More
@@ -95,7 +95,7 b' def __get_lockkey(func, *fargs, **fkwarg'
95 func_name = str(func.__name__) if hasattr(func, '__name__') else str(func)
95 func_name = str(func.__name__) if hasattr(func, '__name__') else str(func)
96
96
97 lockkey = 'task_%s.lock' % \
97 lockkey = 'task_%s.lock' % \
98 md5(func_name + '-' + '-'.join(map(safe_str, params))).hexdigest()
98 md5(safe_str(func_name + '-' + '-'.join(unicode(x) for x in params))).hexdigest()
99 return lockkey
99 return lockkey
100
100
101
101
@@ -942,7 +942,7 b' def gravatar_url(email_address, size=30,'
942 .replace('{md5email}', hashlib.md5(safe_str(email_address).lower()).hexdigest()) \
942 .replace('{md5email}', hashlib.md5(safe_str(email_address).lower()).hexdigest()) \
943 .replace('{netloc}', parsed_url.netloc) \
943 .replace('{netloc}', parsed_url.netloc) \
944 .replace('{scheme}', parsed_url.scheme) \
944 .replace('{scheme}', parsed_url.scheme) \
945 .replace('{size}', safe_str(size))
945 .replace('{size}', str(size))
946 return url
946 return url
947
947
948
948
@@ -136,8 +136,10 b' class BaseDbModel(object):'
136 return None
136 return None
137 if isinstance(value, cls):
137 if isinstance(value, cls):
138 return value
138 return value
139 if isinstance(value, (int, long)) or safe_str(value).isdigit():
139 if isinstance(value, (int, long)):
140 return cls.get(value)
140 return cls.get(value)
141 if isinstance(value, basestring) and value.isdigit():
142 return cls.get(int(value))
141 if callback is not None:
143 if callback is not None:
142 return callback(value)
144 return callback(value)
143
145
@@ -139,9 +139,11 b' class ScmModel(object):'
139 cls = Repository
139 cls = Repository
140 if isinstance(instance, cls):
140 if isinstance(instance, cls):
141 return instance
141 return instance
142 elif isinstance(instance, int) or safe_str(instance).isdigit():
142 elif isinstance(instance, int):
143 return cls.get(instance)
143 return cls.get(instance)
144 elif isinstance(instance, basestring):
144 elif isinstance(instance, basestring):
145 if instance.isdigit():
146 return cls.get(int(instance))
145 return cls.get_by_repo_name(instance)
147 return cls.get_by_repo_name(instance)
146 elif instance is not None:
148 elif instance is not None:
147 raise Exception('given object must be int, basestr or Instance'
149 raise Exception('given object must be int, basestr or Instance'
@@ -29,7 +29,7 b' from tg import config'
29 from tg.i18n import ugettext as _
29 from tg.i18n import ugettext as _
30
30
31 from kallithea.lib import ssh
31 from kallithea.lib import ssh
32 from kallithea.lib.utils2 import safe_str, str2bool
32 from kallithea.lib.utils2 import str2bool
33 from kallithea.model.db import User, UserSshKeys
33 from kallithea.model.db import User, UserSshKeys
34 from kallithea.model.meta import Session
34 from kallithea.model.meta import Session
35
35
@@ -53,7 +53,7 b' class SshKeyModel(object):'
53 try:
53 try:
54 keytype, pub, comment = ssh.parse_pub_key(public_key)
54 keytype, pub, comment = ssh.parse_pub_key(public_key)
55 except ssh.SshKeyParseError as e:
55 except ssh.SshKeyParseError as e:
56 raise SshKeyModelException(_('SSH key %r is invalid: %s') % (safe_str(public_key), e.message))
56 raise SshKeyModelException(_('SSH key %r is invalid: %s') % (public_key, e.message))
57 if not description.strip():
57 if not description.strip():
58 description = comment.strip()
58 description = comment.strip()
59
59
@@ -86,7 +86,7 b' class SshKeyModel(object):'
86
86
87 ssh_key = ssh_key.scalar()
87 ssh_key = ssh_key.scalar()
88 if ssh_key is None:
88 if ssh_key is None:
89 raise SshKeyModelException(_('SSH key %r not found') % safe_str(public_key))
89 raise SshKeyModelException(_('SSH key %r not found') % public_key)
90 Session().delete(ssh_key)
90 Session().delete(ssh_key)
91
91
92 def get_ssh_keys(self, user):
92 def get_ssh_keys(self, user):
General Comments 0
You need to be logged in to leave comments. Login now