-#!/usr/bin/env python
+#!/bin/sh
+"""": # -*-python-*-
+bup_python="$(dirname "$0")/bup-python" || exit $?
+exec "$bup_python" "$0" ${1+"$@"}
+"""
+# end of bup preamble
+
import sys, os, stat, fnmatch
+
from bup import options, git, shquote, vfs, ls
-from bup.helpers import *
+from bup.helpers import chunkyreader, handle_ctrl_c, log
+
handle_ctrl_c()
def do_ls(cmd_args):
try:
ls.do_ls(cmd_args, pwd, onabort=OptionError)
- except OptionError, e:
+ except OptionError as e:
return
n = pwd.resolve(dir)
subs = list(filter(lambda x: x.name.startswith(name),
n.subs()))
- except vfs.NoSuchFile, e:
+ except vfs.NoSuchFile as e:
subs = []
return (dir, name, qtype, lastword, subs)
ret = shquote.what_to_add(qtype, lastword, fullname,
terminate=True) + ' '
return text + ret
- except Exception, e:
+ except Exception as e:
log('\n')
try:
import traceback
traceback.print_tb(sys.exc_traceback)
- except Exception, e2:
+ except Exception as e2:
log('Error printing traceback: %s\n' % e2)
log('\nError in completion: %s\n' % e)
if readline:
readline.set_completer_delims(' \t\n\r/')
readline.set_completer(completer)
- readline.parse_and_bind("tab: complete")
+ if sys.platform.startswith('darwin'):
+ # MacOS uses a slighly incompatible clone of libreadline
+ readline.parse_and_bind('bind ^I rl_complete')
+ readline.parse_and_bind('tab: complete')
init_readline_vars()
lines = inputiter()
outf = open(n.name, 'wb')
write_to_file(inf, outf)
outf.close()
- except Exception, e:
+ except Exception as e:
rv = 1
log(' error: %s\n' % e)
elif cmd == 'help' or cmd == '?':
else:
rv = 1
raise Exception('no such command %r' % cmd)
- except Exception, e:
+ except Exception as e:
rv = 1
log('error: %s\n' % e)
#raise