]> arthur.barton.de Git - bup.git/blobdiff - cmd/margin-cmd.py
tvfs: accommodate python 3 and test there
[bup.git] / cmd / margin-cmd.py
index 9b7fd60a18efd24ab1801f32bcf02623be0cd3c1..7eba44844c6769a5b9279c2cddbbc06501dd7aa6 100755 (executable)
@@ -1,7 +1,15 @@
-#!/usr/bin/env python
+#!/bin/sh
+"""": # -*-python-*-
+bup_python="$(dirname "$0")/bup-python" || exit $?
+exec "$bup_python" "$0" ${1+"$@"}
+"""
+# end of bup preamble
+
+from __future__ import absolute_import, print_function
 import sys, struct, math
+
 from bup import options, git, _helpers
-from bup.helpers import *
+from bup.helpers import log
 
 POPULATION_OF_EARTH=6.7e9  # as of September, 2010
 
@@ -18,9 +26,8 @@ if extra:
     o.fatal("no arguments expected")
 
 git.check_repo_or_die()
-git.ignore_midx = opt.ignore_midx
 
-mi = git.PackIdxList(git.repo('objects/pack'))
+mi = git.PackIdxList(git.repo('objects/pack'), ignore_midx=opt.ignore_midx)
 
 def do_predict(ix):
     total = len(ix)
@@ -30,7 +37,7 @@ def do_predict(ix):
         expected = prefix * total / (1<<64)
         diff = count - expected
         maxdiff = max(maxdiff, abs(diff))
-    print '%d of %d (%.3f%%) ' % (maxdiff, len(ix), maxdiff*100.0/len(ix))
+    print('%d of %d (%.3f%%) ' % (maxdiff, len(ix), maxdiff*100.0/len(ix)))
     sys.stdout.flush()
     assert(count+1 == len(ix))
 
@@ -51,7 +58,7 @@ else:
         pm = _helpers.bitmatch(last, i)
         longmatch = max(longmatch, pm)
         last = i
-    print longmatch
+    print(longmatch)
     log('%d matching prefix bits\n' % longmatch)
     doublings = math.log(len(mi), 2)
     bpd = longmatch / doublings