From 2e4e8f1ab20f4a1f7873a638661f5f9135ecc26f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Borgstr=C3=B6m?= Date: Mon, 31 Oct 2011 21:18:28 +0100 Subject: [PATCH] More pep8 fixes --- darc/helpers.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/darc/helpers.py b/darc/helpers.py index 574959128..251f096fb 100644 --- a/darc/helpers.py +++ b/darc/helpers.py @@ -76,7 +76,7 @@ class Statistics(object): def print_(self): print 'Number of files: %d' % self.nfiles print 'Original size: %d (%s)' % (self.osize, format_file_size(self.osize)) - print 'Compressed size: %s (%s)'% (self.csize, format_file_size(self.csize)) + print 'Compressed size: %s (%s)' % (self.csize, format_file_size(self.csize)) print 'Unique data: %d (%s)' % (self.usize, format_file_size(self.usize)) @@ -228,7 +228,7 @@ def format_timedelta(td): '2 hours 1.10 seconds' """ # Since td.total_seconds() requires python 2.7 - ts = (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / float(10**6) + ts = (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10 ** 6) / float(10 ** 6) s = ts % 60 m = int(ts / 60) % 60 h = int(ts / 3600) % 24 @@ -250,6 +250,7 @@ def format_file_mode(mod): for m, s in ((4, 'r'), (2, 'w'), (1, 'x'))) return '%s%s%s' % (x(mod / 64), x(mod / 8), x(mod)) + def format_file_size(v): """Format file size into a human friendly format """ @@ -262,12 +263,15 @@ def format_file_size(v): else: return '%d B' % v + class IntegrityError(Exception): """ """ + def memoize(function): cache = {} + def decorated_function(*args): try: return cache[args] @@ -277,6 +281,7 @@ def memoize(function): return val return decorated_function + @memoize def uid2user(uid): try: @@ -284,6 +289,7 @@ def uid2user(uid): except KeyError: return None + @memoize def user2uid(user): try: @@ -291,6 +297,7 @@ def user2uid(user): except KeyError: return None + @memoize def gid2group(gid): try: @@ -298,6 +305,7 @@ def gid2group(gid): except KeyError: return None + @memoize def group2gid(group): try: