import os, fnmatch, stat, sys
from bup import _helpers, options, git, shquote, ls, vfs
-from bup.compat import argv_bytes, fsdecode
-from bup.helpers import chunkyreader, handle_ctrl_c, log
+from bup.compat import argv_bytes
+from bup.helpers import chunkyreader, log
from bup.io import byte_stream, path_msg
from bup.repo import LocalRepo
opt = ls.opts_from_cmdline(args, onabort=OptionError, pwd=pwd_str)
except OptionError as e:
log('error: %s' % e)
- return
+ return None
return ls.within_repo(repo, opt, out, pwd_str)
outf.write(blob)
-def inputiter(f):
- if os.isatty(f.fileno()):
- while 1:
- if hasattr(_helpers, 'readline'):
- try:
- yield _helpers.readline(b'bup> ')
- except EOFError:
- print() # Clear the line for the terminal's next prompt
- break
- else:
- out.write(b'bup> ')
- out.flush()
- read_line = f.readline()
- if not read_line:
- print('')
- break
- yield read_line
- else:
- for line in f:
- yield line
-
-
def _completer_get_subs(repo, line):
(qtype, lastword) = shquote.unfinished_word(line)
dir, name = os.path.split(lastword)
global _attempt_start, _attempt_end
_attempt_start = start
_attempt_end = end
- return None
_last_line = None
_last_res = None
except Exception as e2:
log('Error printing traceback: %s\n' % e2)
log('\nError in completion: %s\n' % e)
+ return None
optspec = """
pwd = vfs.resolve(repo, b'/')
rv = 0
+ def inputiter(f):
+ if os.isatty(f.fileno()):
+ while 1:
+ prompt = b'bup %s> ' % (b'/'.join(name for name, item in pwd) or b'/', )
+ if hasattr(_helpers, 'readline'):
+ try:
+ yield _helpers.readline(prompt)
+ except EOFError:
+ print() # Clear the line for the terminal's next prompt
+ break
+ else:
+ out.write(prompt)
+ out.flush()
+ read_line = f.readline()
+ if not read_line:
+ print('')
+ break
+ yield read_line
+ else:
+ for line in f:
+ yield line
+
+
if extra:
lines = (argv_bytes(arg) for arg in extra)
else:
with open(name, 'wb') as destfile:
log('Saving %s\n' % path_msg(name))
write_to_file(srcfile, destfile)
- elif cmd == b'help' or cmd == b'?':
+ elif cmd in (b'help', b'?'):
out.write(b'Commands: ls cd pwd cat get mget help quit\n')
out.flush()
elif cmd in (b'quit', b'exit', b'bye'):