From: Michael Tremer Date: Thu, 3 Jun 2021 18:23:05 +0000 (+0000) Subject: util: Drop loads of unused code X-Git-Tag: 0.9.28~1285^2~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f34be2f3f623a71e83a032c2bdbc874434545ec5;p=pakfire.git util: Drop loads of unused code Signed-off-by: Michael Tremer --- diff --git a/src/pakfire/util.py b/src/pakfire/util.py index 0b49f5066..4db3ad6d7 100644 --- a/src/pakfire/util.py +++ b/src/pakfire/util.py @@ -20,65 +20,7 @@ ############################################################################### import os -import random import shutil -import string -import sys -import time - -import logging -log = logging.getLogger("pakfire") - -from .constants import * -from .i18n import _ - -def cli_is_interactive(): - """ - Say weather a shell is interactive or not. - """ - if sys.stdin.isatty() and sys.stdout.isatty() and sys.stderr.isatty(): - return True - - return False - -def random_string(length=20): - s = "" - - for i in range(length): - s += random.choice(string.ascii_letters) - - return s - -def make_progress(message, maxval, eta=True, speed=False): - # XXX delay importing the progressbar module - # (because of a circular dependency) - from .ui import progressbar - - # Return nothing if stdout is not a terminal. - if not sys.stdout.isatty(): - return - - if not maxval: - maxval = 1 - - pb = progressbar.ProgressBar(maxval) - pb.add("%-50s" % message) - - bar = progressbar.WidgetBar() - pb.add(bar) - - if speed: - percentage = progressbar.WidgetPercentage() - pb.add(percentage) - - filetransfer = progressbar.WidgetFileTransferSpeed() - pb.add(filetransfer) - - if eta: - eta = progressbar.WidgetETA() - pb.add(eta) - - return pb.start() def rm(path, *args, **kargs): """ @@ -102,43 +44,3 @@ def rm(path, *args, **kargs): os.system("chattr -R -i %s" % path) else: raise - -def text_wrap(s, length=65): - if not s: - return "" - - lines = [] - - words = [] - for line in s.splitlines(): - if not line: - words.append("") - else: - words += line.split() - - line = [] - while words: - word = words.pop(0) - - # An empty words means a line break. - if not word: - if line: - lines.append(" ".join(line)) - lines.append("") - line = [] - - else: - if len(" ".join(line)) + len(word) >= length: - lines.append(" ".join(line)) - line = [] - words.insert(0, word) - else: - line.append(word) - - if line: - lines.append(" ".join(line)) - - assert not words - - #return "\n".join(lines) - return lines