]> arthur.barton.de Git - bup.git/blobdiff - lib/bup/helpers.py
Use absolute_import from the __future__ everywhere
[bup.git] / lib / bup / helpers.py
index e7df2321415b8321bb7c6bb9b712d2d0bc69ad3e..583c65b4bf07f040102c153638ff2d1c62b245a2 100644 (file)
@@ -1,5 +1,6 @@
 """Helper functions and classes for bup."""
 
+from __future__ import absolute_import
 from collections import namedtuple
 from contextlib import contextmanager
 from ctypes import sizeof, c_void_p
@@ -28,7 +29,6 @@ sc_arg_max = os.sysconf('SC_ARG_MAX')
 if sc_arg_max == -1:  # "no definite limit" - let's choose 2M
     sc_arg_max = 2 * 1024 * 1024
 
-
 def last(iterable):
     result = None
     for result in iterable:
@@ -293,7 +293,7 @@ def _argmax_base(command):
     base_size = 2048
     for c in command:
         base_size += len(command) + 1
-    for k, v in environ.iteritems():
+    for k, v in compat.items(environ):
         base_size += len(k) + len(v) + 2 + sizeof(c_void_p)
     return base_size
 
@@ -960,14 +960,14 @@ def columnate(l, prefix):
         return ""
     l = l[:]
     clen = max(len(s) for s in l)
-    ncols = (tty_width() - len(prefix)) / (clen + 2)
+    ncols = (tty_width() - len(prefix)) // (clen + 2)
     if ncols <= 1:
         ncols = 1
         clen = 0
     cols = []
     while len(l) % ncols:
         l.append('')
-    rows = len(l)/ncols
+    rows = len(l) // ncols
     for s in range(0, len(l), rows):
         cols.append(l[s:s+rows])
     out = ''
@@ -1060,7 +1060,7 @@ def path_components(path):
     Example:
       '/home/foo' -> [('', '/'), ('home', '/home'), ('foo', '/home/foo')]"""
     if not path.startswith('/'):
-        raise Exception, 'path must start with "/": %s' % path
+        raise Exception('path must start with "/": %s' % path)
     # Since we assume path startswith('/'), we can skip the first element.
     result = [('', '/')]
     norm_path = os.path.abspath(path)