mirror of
https://github.com/borgbackup/borg.git
synced 2025-01-03 05:35:58 +00:00
Move pretty_size to helpers.py
This commit is contained in:
parent
cbb62fd2a6
commit
03b0e85d0b
2 changed files with 15 additions and 14 deletions
|
@ -8,7 +8,7 @@
|
|||
from chunkifier import chunkify
|
||||
from cache import Cache, NS_ARCHIVES, NS_CHUNKS
|
||||
from bandstore import BandStore
|
||||
from helpers import location_validator
|
||||
from helpers import location_validator, pretty_size
|
||||
|
||||
CHUNK_SIZE = 55001
|
||||
|
||||
|
@ -167,16 +167,6 @@ def process_file(self, path, cache):
|
|||
|
||||
class Archiver(object):
|
||||
|
||||
def pretty_size(self, v):
|
||||
if v > 1024 * 1024 * 1024:
|
||||
return '%.2f GB' % (v / 1024. / 1024. / 1024.)
|
||||
elif v > 1024 * 1024:
|
||||
return '%.2f MB' % (v / 1024. / 1024.)
|
||||
elif v > 1024:
|
||||
return '%.2f kB' % (v / 1024.)
|
||||
else:
|
||||
return str(v)
|
||||
|
||||
def open_store(self, location):
|
||||
store = BandStore(location.path)
|
||||
cache = Cache(store)
|
||||
|
@ -215,9 +205,9 @@ def do_info(self, args):
|
|||
store, cache = self.open_store(args.archive)
|
||||
archive = Archive(store, cache, args.archive.archive)
|
||||
stats = archive.stats(cache)
|
||||
print 'Original size:', self.pretty_size(stats['osize'])
|
||||
print 'Compressed size:', self.pretty_size(stats['csize'])
|
||||
print 'Unique data:', self.pretty_size(stats['usize'])
|
||||
print 'Original size:', pretty_size(stats['osize'])
|
||||
print 'Compressed size:', pretty_size(stats['csize'])
|
||||
print 'Unique data:', pretty_size(stats['usize'])
|
||||
|
||||
def run(self):
|
||||
parser = argparse.ArgumentParser(description='Dedupestore')
|
||||
|
|
|
@ -49,3 +49,14 @@ def validator(text):
|
|||
return validator
|
||||
|
||||
|
||||
def pretty_size(v):
|
||||
if v > 1024 * 1024 * 1024:
|
||||
return '%.2f GB' % (v / 1024. / 1024. / 1024.)
|
||||
elif v > 1024 * 1024:
|
||||
return '%.2f MB' % (v / 1024. / 1024.)
|
||||
elif v > 1024:
|
||||
return '%.2f kB' % (v / 1024.)
|
||||
else:
|
||||
return str(v)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue