def __init__(self): self.terminal_width = console.getTerminalWidth() self.encoding = locale.getpreferredencoding() self.methods = { M_COPY: shutil.copyfile, M_MOVE: shutil.move, M_HARDLINK: None, M_SYMLINK: None, } self.link_method_names = { M_HARDLINK: 'hard', M_SYMLINK: 'symbolic', } self.method_descriptions = { M_COPY: 'copied', M_MOVE: 'moved', M_HARDLINK: 'created hard links', M_SYMLINK: 'created symbolic links', } self.symlink_allowed = True if 'win32' in sys.platform: self.windows = True self._process_windows() else: self.windows = False try: # UNIX from os import link as hardlink, symlink self.methods[M_HARDLINK] = hardlink self.methods[M_SYMLINK] = symlink except ImportError: # unknown platform pass
def __init__(self, maxval, fout=sys.stderr, width=None, displaysize=False, enabled=True): self.curval = 0 self.terminal_width = console.getTerminalWidth() if self.width is None: # '[===...===] X%\n' # length of _getbarstr() self.width = self.terminal_width - len('[]') - len(' 100%\n') if self.displaysize: # subtract max length of size string self.width -= len(' [1023.99 GiB / 9999.99 TiB]')