1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-26 01:37:20 +00:00

move defaults up in alternate implementation, use nameduple

This commit is contained in:
Antoine Beaupré 2015-10-18 21:07:28 -04:00
parent 158e6b529a
commit f48bbc3725

View file

@ -11,8 +11,9 @@
try: try:
from shutil import get_terminal_size from shutil import get_terminal_size
except ImportError: except ImportError:
def get_terminal_size(fallback): def get_terminal_size(fallback=(80, 24)):
return (os.environ.get('COLUMNS', fallback[0]), os.environ.get('LINES', fallback[1])) TerminalSize = namedtuple(TerminalSize, ['columns', 'lines'])
return TerminalSize(os.environ.get('COLUMNS', int(fallback[0])), os.environ.get('LINES', int(fallback[1])))
import sys import sys
import time import time
import unicodedata import unicodedata
@ -186,7 +187,7 @@ def csize_fmt(self):
return format_file_size(self.csize) return format_file_size(self.csize)
def show_progress(self, item=None, final=False, stream=None): def show_progress(self, item=None, final=False, stream=None):
(columns, lines) = get_terminal_size((80, 24)) columns, lines = get_terminal_size()
if not final: if not final:
msg = '{0.osize_fmt} O {0.csize_fmt} C {0.usize_fmt} D {0.nfiles} N '.format(self) msg = '{0.osize_fmt} O {0.csize_fmt} C {0.usize_fmt} D {0.nfiles} N '.format(self)
path = remove_surrogates(item[b'path']) if item else '' path = remove_surrogates(item[b'path']) if item else ''