Show More
@@ -48,20 +48,23 b' def generate_api_key(username, salt=None' | |||
|
48 | 48 | |
|
49 | 49 | return hashlib.sha1(username + salt).hexdigest() |
|
50 | 50 | |
|
51 | def safe_unicode(str): | |
|
51 | def safe_unicode(_str): | |
|
52 | 52 | """ |
|
53 | 53 | safe unicode function. In case of UnicodeDecode error we try to return |
|
54 | 54 | unicode with errors replace, if this fails we return unicode with |
|
55 | 55 | string_escape decoding |
|
56 | 56 | """ |
|
57 | 57 | |
|
58 | if isinstance(_str, unicode): | |
|
59 | return _str | |
|
60 | ||
|
58 | 61 | try: |
|
59 | u_str = unicode(str) | |
|
62 | u_str = unicode(_str) | |
|
60 | 63 | except UnicodeDecodeError: |
|
61 | 64 | try: |
|
62 |
u_str = |
|
|
65 | u_str = _str.decode('utf-8', 'replace') | |
|
63 | 66 | except UnicodeDecodeError: |
|
64 | 67 | #incase we have a decode error just represent as byte string |
|
65 |
u_str = unicode( |
|
|
68 | u_str = unicode(_str.encode('string_escape')) | |
|
66 | 69 | |
|
67 | 70 | return u_str |
@@ -24,6 +24,8 b'' | |||
|
24 | 24 | # along with this program; if not, write to the Free Software |
|
25 | 25 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
26 | 26 | # MA 02110-1301, USA. |
|
27 | ||
|
28 | import os | |
|
27 | 29 | import logging |
|
28 | 30 | import datetime |
|
29 | 31 | from datetime import date |
@@ -212,7 +214,7 b' class Repository(Base):' | |||
|
212 | 214 | |
|
213 | 215 | @property |
|
214 | 216 | def just_name(self): |
|
215 |
return self.repo_name.split( |
|
|
217 | return self.repo_name.split(os.sep)[-1] | |
|
216 | 218 | |
|
217 | 219 | @property |
|
218 | 220 | def groups_with_parents(self): |
General Comments 0
You need to be logged in to leave comments.
Login now