More pep8 fixes

This commit is contained in:
Jonas Borgström 2011-10-31 21:18:28 +01:00
parent ddc1d02e90
commit 2e4e8f1ab2
1 changed files with 10 additions and 2 deletions

View File

@ -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: