Python 3 made items behave like iteritems and dropped iteritems.
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
"""Do nothing (already handled by Python 3 infrastructure)."""
return ex
+ def items(x):
+ return x.items()
+
else: # Python 2
str_type = basestring
tb = getattr(ex, '__traceback__', None)
print_exception(type(ex), ex, tb)
+ def items(x):
+ return x.iteritems()
+
+
def wrap_main(main):
"""Run main() and raise a SystemExit with the return value if it
returns, pass along any SystemExit it raises, convert
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
import cPickle, errno, os, tempfile
+from bup import compat
+
class Error(Exception):
pass
f.close()
f = None
# Set up the reverse hard link index.
- for node, paths in self._node_paths.iteritems():
+ for node, paths in compat.items(self._node_paths):
for path in paths:
self._path_node[path] = node
import sys
-from bup import git, vfs
+from bup import compat, git, vfs
from bup.client import ClientError
from bup.git import get_commit_items
from bup.helpers import add_error, die_if_errors, log, saved_errors
updated_refs = {} # ref_name -> (original_ref, tip_commit(bin))
- for branchname, branchitem in dead_branches.iteritems():
+ for branchname, branchitem in compat.items(dead_branches):
ref = 'refs/heads/' + branchname
assert(not ref in updated_refs)
updated_refs[ref] = (branchitem.oid, None)
if dead_saves:
writer = git.PackWriter(compression_level=compression)
try:
- for branch, saves in dead_saves.iteritems():
+ for branch, saves in compat.items(dead_saves):
assert(saves)
updated_refs['refs/heads/' + branch] = rm_saves(saves, writer)
except:
# Only update the refs here, at the very end, so that if something
# goes wrong above, the old refs will be undisturbed. Make an attempt
# to update each ref.
- for ref_name, info in updated_refs.iteritems():
+ for ref_name, info in compat.items(updated_refs):
orig_ref, new_ref = info
try:
if not new_ref:
pending_ex = chain_ex(add_ex_tb(ex), pending_ex)
try:
# Try to finish each of the streams
- for fd, pending_items in pending.iteritems():
+ for fd, pending_items in compat.items(pending):
dest = dest_out if fd == src_out else dest_err
try:
print_clean_line(dest, pending_items, width)
from buptest import exc, exo, test_tempdir
from wvtest import wvfail, wvpass, wvpasseq, wvpassne, wvstart
+from bup import compat
from bup.helpers import partition, period_as_secs, readpipe
return utcs
utcs = sorted(utcs, reverse=True)
period_start = dict(spec)
- for kind, duration in period_start.iteritems():
+ for kind, duration in compat.items(period_start):
period_start[kind] = utc_start - period_as_secs(duration)
period_start = defaultdict(lambda: float('inf'), period_start)