Server IP : 85.214.239.14 / Your IP : 18.221.97.20 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /proc/2/cwd/proc/2/root/proc/2/cwd/proc/3/task/3/cwd/usr/bin/ |
Upload File : |
#!/usr/bin/python3 # PYTHON_ARGCOMPLETE_OK # Copyright 2012-2021, Andrey Kislyuk and argcomplete contributors. # Licensed under the Apache License. See https://github.com/kislyuk/argcomplete for more info. ''' Activate the generic bash-completion script for the argcomplete module. ''' import os, sys, argparse, argcomplete, shutil, fileinput parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) dest_opt = parser.add_argument("--dest", default="/etc/bash_completion.d", help="Specify the bash completion modules directory to install into") parser.add_argument("--user", help="Install into user directory (~/.bash_completion.d/)", action='store_true') parser.add_argument("--no-defaults", dest="use_defaults", action="store_false", default=True, help="When no matches are generated, do not fallback to readline\'s default completion") parser.add_argument("--complete-arguments", nargs=argparse.REMAINDER, help="arguments to call complete with; use of this option discards default options") argcomplete.autocomplete(parser) args = parser.parse_args() if args.user: args.dest = os.path.expanduser("~/.bash_completion.d/") if not os.path.exists(args.dest): try: os.mkdir(args.dest) except Exception as e: parser.error("Path {d} does not exist and could not be created: {e}".format(d=args.dest, e=e)) elif not os.path.exists(args.dest) and args.dest != '-': if sys.platform == 'darwin' and args.dest == dest_opt.default and os.path.exists("/usr/local" + dest_opt.default): args.dest = "/usr/local" + dest_opt.default else: parser.error("Path {d} does not exist".format(d=args.dest)) activator = os.path.join(os.path.dirname(argcomplete.__file__), 'bash_completion.d', 'python-argcomplete') if args.complete_arguments is None: complete_options = '-o default -o bashdefault' if args.use_defaults else '-o bashdefault' else: complete_options = " ".join(args.complete_arguments) complete_call = "complete{} -D -F _python_argcomplete_global".format(" " + complete_options if complete_options else "") def replaceCompleteCall(line): if line.startswith("complete") and "_python_argcomplete_global" in line: return complete_call + ('\n' if line.endswith('\n') else '') else: return line if args.dest == '-': for line in open(activator): sys.stdout.write(replaceCompleteCall(line)) else: dest = os.path.join(args.dest, "python-argcomplete") sys.stdout.write("Installing bash completion script " + dest) if not args.use_defaults: sys.stdout.write(" without -o default") elif args.complete_arguments: sys.stdout.write(" with options: " + complete_options) sys.stdout.write("\n") try: shutil.copy(activator, dest) if args.complete_arguments or not args.use_defaults: for line in fileinput.input(dest, inplace=True): # fileinput with inplace=True redirects stdout to the edited file sys.stdout.write(replaceCompleteCall(line)) except Exception as e: err = str(e) if args.dest == dest_opt.default: err += ("\nPlease try --user to install into a user directory, " "or --dest to specify the bash completion modules directory") parser.error(err)