X-Git-Url: https://arthur.barton.de/gitweb/?a=blobdiff_plain;f=cmd%2Fmargin-cmd.py;h=b01db3d1864e151fe7e74059b024f3eb08be1ebd;hb=aeafe13a9330e7deca3dc6b9c0496937d904663a;hp=90dbdcd8f90edad112c48cc5d513b95554b709fe;hpb=aa1244949b7494af92c55c0261cfd639fe2e0048;p=bup.git diff --git a/cmd/margin-cmd.py b/cmd/margin-cmd.py index 90dbdcd..b01db3d 100755 --- a/cmd/margin-cmd.py +++ b/cmd/margin-cmd.py @@ -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 @@ -11,7 +19,7 @@ bup margin predict Guess object offsets and report the maximum deviation ignore-midx Don't use midx files; use only plain pack idx files. """ -o = options.Options('bup margin', optspec) +o = options.Options(optspec) (opt, flags, extra) = o.parse(sys.argv[1:]) if extra: @@ -30,7 +38,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 +59,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