]> git.ipfire.org Git - pakfire.git/commitdiff
util: Drop loads of unused code
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 3 Jun 2021 18:23:05 +0000 (18:23 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 3 Jun 2021 18:23:05 +0000 (18:23 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/util.py

index 0b49f5066424bc1a5f78518b4fb4a52a61c83967..4db3ad6d7fca6ba78921900f5dce1c4908513f4a 100644 (file)
 ###############################################################################
 
 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