]> arthur.barton.de Git - bup.git/blobdiff - lib/bup/cmd/ftp.py
pylint: enable inconsistent-return-statements
[bup.git] / lib / bup / cmd / ftp.py
index 0dba70ef39e8ed414686c180edfb6ece36417032..99121f0dc76d539fac313d085362b508a2dc22f1 100755 (executable)
@@ -8,8 +8,8 @@ from __future__ import absolute_import, print_function
 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
 
@@ -26,7 +26,7 @@ def do_ls(repo, pwd, args, out):
         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)
 
 
@@ -35,28 +35,6 @@ def write_to_file(inf, outf):
         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)
@@ -77,7 +55,6 @@ def attempt_completion(text, start, end):
     global _attempt_start, _attempt_end
     _attempt_start = start
     _attempt_end = end
-    return None
 
 _last_line = None
 _last_res = None
@@ -113,6 +90,7 @@ def enter_completion(text, iteration):
         except Exception as e2:
             log('Error printing traceback: %s\n' % e2)
         log('\nError in completion: %s\n' % e)
+    return None
 
 
 optspec = """
@@ -134,6 +112,29 @@ def main(argv):
     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:
@@ -226,7 +227,7 @@ def main(argv):
                                 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'):