From c2b99d5235cadcd541ed00909f7df5e0ace7ac42 Mon Sep 17 00:00:00 2001 From: hut Date: Tue, 1 Dec 2009 00:57:26 +0100 Subject: renamed api to helper since it had nothing to do with an api --- ranger/api.py | 31 ------------------------------- ranger/directory.py | 2 +- ranger/fsobject.py | 2 +- ranger/gui/ui.py | 2 +- ranger/helper.py | 31 +++++++++++++++++++++++++++++++ 5 files changed, 34 insertions(+), 34 deletions(-) delete mode 100644 ranger/api.py create mode 100644 ranger/helper.py diff --git a/ranger/api.py b/ranger/api.py deleted file mode 100644 index 5ca40175..00000000 --- a/ranger/api.py +++ /dev/null @@ -1,31 +0,0 @@ - -LOGFILE = '/tmp/errorlog' - -def log(txt): - f = open(LOGFILE, 'a') - f.write("r1: ") - f.write(str(txt)) - f.write("\n") - f.close() - -ONE_KB = 1024 -UNITS = tuple('BKMGTP') -NINE_THOUSAND = len(UNITS) - 1 - -def human_readable(byte): - import math - - if not byte: - return '0 B' - - its = int(math.log(byte, 2) / 10) - flt = float(byte) / (1 << (10 * its)) - - if its > NINE_THOUSAND: - return '>9000' # off scale - - if int(flt) == flt: - return '%.0f %s' % (flt, UNITS[its]) - - else: - return '%.2f %s' % (flt, UNITS[its]) diff --git a/ranger/directory.py b/ranger/directory.py index f9175778..cb5b9ddc 100644 --- a/ranger/directory.py +++ b/ranger/directory.py @@ -1,6 +1,6 @@ import ranger.fsobject from ranger.file import File -#from ranger.api import log +#from ranger.helper import log from ranger.fsobject import FileSystemObject as SuperClass diff --git a/ranger/fsobject.py b/ranger/fsobject.py index 48a6eee2..c4a1e882 100644 --- a/ranger/fsobject.py +++ b/ranger/fsobject.py @@ -42,7 +42,7 @@ class FileSystemObject(object): self.loaded = True import os - from ranger.api import human_readable + from ranger.helper import human_readable if os.access(self.path, os.F_OK): self.stat = os.stat(self.path) self.islink = os.path.islink(self.path) diff --git a/ranger/gui/ui.py b/ranger/gui/ui.py index 34f7c54c..78adde28 100644 --- a/ranger/gui/ui.py +++ b/ranger/gui/ui.py @@ -61,7 +61,7 @@ class UI(): def press(self, key, fm): self.env.key_append(key) -# from ranger.api import log +# from ranger.helper import log # log(self.env.keybuffer) try: diff --git a/ranger/helper.py b/ranger/helper.py new file mode 100644 index 00000000..5ca40175 --- /dev/null +++ b/ranger/helper.py @@ -0,0 +1,31 @@ + +LOGFILE = '/tmp/errorlog' + +def log(txt): + f = open(LOGFILE, 'a') + f.write("r1: ") + f.write(str(txt)) + f.write("\n") + f.close() + +ONE_KB = 1024 +UNITS = tuple('BKMGTP') +NINE_THOUSAND = len(UNITS) - 1 + +def human_readable(byte): + import math + + if not byte: + return '0 B' + + its = int(math.log(byte, 2) / 10) + flt = float(byte) / (1 << (10 * its)) + + if its > NINE_THOUSAND: + return '>9000' # off scale + + if int(flt) == flt: + return '%.0f %s' % (flt, UNITS[its]) + + else: + return '%.2f %s' % (flt, UNITS[its]) -- cgit 1.4.1-2-gfad0