"""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
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:
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
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 = ''
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)