|
@@ -76,7 +76,7 @@ class Statistics(object):
|
|
def print_(self):
|
|
def print_(self):
|
|
print 'Number of files: %d' % self.nfiles
|
|
print 'Number of files: %d' % self.nfiles
|
|
print 'Original size: %d (%s)' % (self.osize, format_file_size(self.osize))
|
|
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))
|
|
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'
|
|
'2 hours 1.10 seconds'
|
|
"""
|
|
"""
|
|
# Since td.total_seconds() requires python 2.7
|
|
# 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
|
|
s = ts % 60
|
|
m = int(ts / 60) % 60
|
|
m = int(ts / 60) % 60
|
|
h = int(ts / 3600) % 24
|
|
h = int(ts / 3600) % 24
|
|
@@ -250,6 +250,7 @@ def format_file_mode(mod):
|
|
for m, s in ((4, 'r'), (2, 'w'), (1, 'x')))
|
|
for m, s in ((4, 'r'), (2, 'w'), (1, 'x')))
|
|
return '%s%s%s' % (x(mod / 64), x(mod / 8), x(mod))
|
|
return '%s%s%s' % (x(mod / 64), x(mod / 8), x(mod))
|
|
|
|
|
|
|
|
+
|
|
def format_file_size(v):
|
|
def format_file_size(v):
|
|
"""Format file size into a human friendly format
|
|
"""Format file size into a human friendly format
|
|
"""
|
|
"""
|
|
@@ -262,12 +263,15 @@ def format_file_size(v):
|
|
else:
|
|
else:
|
|
return '%d B' % v
|
|
return '%d B' % v
|
|
|
|
|
|
|
|
+
|
|
class IntegrityError(Exception):
|
|
class IntegrityError(Exception):
|
|
"""
|
|
"""
|
|
"""
|
|
"""
|
|
|
|
|
|
|
|
+
|
|
def memoize(function):
|
|
def memoize(function):
|
|
cache = {}
|
|
cache = {}
|
|
|
|
+
|
|
def decorated_function(*args):
|
|
def decorated_function(*args):
|
|
try:
|
|
try:
|
|
return cache[args]
|
|
return cache[args]
|
|
@@ -277,6 +281,7 @@ def memoize(function):
|
|
return val
|
|
return val
|
|
return decorated_function
|
|
return decorated_function
|
|
|
|
|
|
|
|
+
|
|
@memoize
|
|
@memoize
|
|
def uid2user(uid):
|
|
def uid2user(uid):
|
|
try:
|
|
try:
|
|
@@ -284,6 +289,7 @@ def uid2user(uid):
|
|
except KeyError:
|
|
except KeyError:
|
|
return None
|
|
return None
|
|
|
|
|
|
|
|
+
|
|
@memoize
|
|
@memoize
|
|
def user2uid(user):
|
|
def user2uid(user):
|
|
try:
|
|
try:
|
|
@@ -291,6 +297,7 @@ def user2uid(user):
|
|
except KeyError:
|
|
except KeyError:
|
|
return None
|
|
return None
|
|
|
|
|
|
|
|
+
|
|
@memoize
|
|
@memoize
|
|
def gid2group(gid):
|
|
def gid2group(gid):
|
|
try:
|
|
try:
|
|
@@ -298,6 +305,7 @@ def gid2group(gid):
|
|
except KeyError:
|
|
except KeyError:
|
|
return None
|
|
return None
|
|
|
|
|
|
|
|
+
|
|
@memoize
|
|
@memoize
|
|
def group2gid(group):
|
|
def group2gid(group):
|
|
try:
|
|
try:
|