Hello community, here is the log from the commit of package python-argcomplete for openSUSE:Factory checked in at 2020-12-21 10:24:08 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-argcomplete (Old) and /work/SRC/openSUSE:Factory/.python-argcomplete.new.5145 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-argcomplete" Mon Dec 21 10:24:08 2020 rev:17 rq:857103 version:1.12.2 Changes: -------- --- /work/SRC/openSUSE:Factory/python-argcomplete/python-argcomplete.changes 2020-06-10 00:43:29.086195153 +0200 +++ /work/SRC/openSUSE:Factory/.python-argcomplete.new.5145/python-argcomplete.changes 2020-12-21 10:26:53.360216062 +0100 @@ -1,0 +2,11 @@ +Sun Dec 20 09:17:00 UTC 2020 - Dirk Müller <[email protected]> + +- update to 1.12.2: + - Update importlib-metadata dependency pin (#332) + - Add change log project URL (#312) + - Replace Travis CI with GitHub Actions (#323) + - Update importlib-metadata dependency version range + - Bash nounset mode fixes (#313) +- remove 0001-Remove-expected-test-failure-for-new-versions-of-fish.patch (upstream) + +------------------------------------------------------------------- Old: ---- 0001-Remove-expected-test-failure-for-new-versions-of-fish.patch argcomplete-1.11.1.tar.gz New: ---- argcomplete-1.12.2.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-argcomplete.spec ++++++ --- /var/tmp/diff_new_pack.VbSizh/_old 2020-12-21 10:26:53.900216674 +0100 +++ /var/tmp/diff_new_pack.VbSizh/_new 2020-12-21 10:26:53.908216683 +0100 @@ -19,7 +19,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-argcomplete -Version: 1.11.1 +Version: 1.12.2 Release: 0 Summary: Bash tab completion for argparse License: Apache-2.0 @@ -28,7 +28,6 @@ Source: https://files.pythonhosted.org/packages/source/a/argcomplete/argcomplete-%{version}.tar.gz Patch0: skip_tcsh_tests.patch Patch1: trim-test-deps.patch -Patch2: 0001-Remove-expected-test-failure-for-new-versions-of-fish.patch BuildRequires: %{python_module importlib-metadata >= 0.23} BuildRequires: %{python_module pexpect} BuildRequires: %{python_module pip} ++++++ argcomplete-1.11.1.tar.gz -> argcomplete-1.12.2.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/argcomplete-1.11.1/Changes.rst new/argcomplete-1.12.2/Changes.rst --- old/argcomplete-1.11.1/Changes.rst 2020-01-14 18:19:23.000000000 +0100 +++ new/argcomplete-1.12.2/Changes.rst 2020-11-24 05:10:32.000000000 +0100 @@ -1,3 +1,19 @@ +Changes for v1.12.2 (2020-11-23) +================================ + +- Update importlib-metadata dependency pin (#332) + +- Add change log project URL (#312) + +- Replace Travis CI with GitHub Actions (#323) + +Changes for v1.12.1 (2020-09-26) +================================ + +- Update importlib-metadata dependency version range + +- Bash nounset mode fixes (#313) + Changes for v1.11.1 (2020-01-14) ================================ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/argcomplete-1.11.1/PKG-INFO new/argcomplete-1.12.2/PKG-INFO --- old/argcomplete-1.11.1/PKG-INFO 2020-01-14 18:19:36.000000000 +0100 +++ new/argcomplete-1.12.2/PKG-INFO 2020-11-24 05:10:45.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: argcomplete -Version: 1.11.1 +Version: 1.12.2 Summary: Bash tab completion for argparse Home-page: https://github.com/kislyuk/argcomplete Author: Andrey Kislyuk @@ -9,6 +9,7 @@ Project-URL: Documentation, https://kislyuk.github.io/argcomplete Project-URL: Source Code, https://github.com/kislyuk/argcomplete Project-URL: Issue Tracker, https://github.com/kislyuk/argcomplete/issues +Project-URL: Change Log, https://github.com/kislyuk/argcomplete/blob/master/Changes.rst Description: argcomplete - Bash tab completion for argparse ============================================== *Tab complete all the things!* @@ -287,12 +288,44 @@ ------------ To activate completions for fish use:: - register-python-argcomplete --shell fish my-awesome-script | . + register-python-argcomplete --shell fish my-awesome-script | source or create new completion file, e.g:: register-python-argcomplete --shell fish ~/.config/fish/completions/my-awesome-script.fish + Completion Description For Fish + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + By default help string is added as completion description. + + .. image:: docs/fish_help_string.png + + You can disable this feature by removing ``_ARGCOMPLETE_DFS`` variable, e.g:: + + register-python-argcomplete --shell fish my-awesome-script | grep -v _ARGCOMPLETE_DFS | . + + Git Bash Support + ---------------- + Due to limitations of file descriptor inheritance on Windows, + Git Bash not supported out of the box. You can opt in to using + temporary files instead of file descriptors for for IPC + by setting the environment variable ``ARGCOMPLETE_USE_TEMPFILES``, + e.g. by adding ``export ARGCOMPLETE_USE_TEMPFILES=1`` to ``~/.bashrc``. + + For full support, consider using Bash with the + Windows Subsystem for Linux (WSL). + + External argcomplete script + --------------------------- + To register an argcomplete script for an arbitrary name, the ``--external-argcomplete-script`` argument of the ``register-python-argcomplete`` script can be used:: + + eval "$(register-python-argcomplete --external-argcomplete-script /path/to/script arbitrary-name)" + + This allows, for example, to use the auto completion functionality of argcomplete for an application not written in Python. + The command line interface of this program must be additionally implemented in a Python script with argparse and argcomplete and whenever the application is called the registered external argcomplete script is used for auto completion. + + This option can also be used in combination with the other supported shells. + Python Support -------------- Argcomplete requires Python 2.7 or 3.5+. @@ -326,6 +359,7 @@ * `Documentation <https://kislyuk.github.io/argcomplete/>`_ * `Package distribution (PyPI) <https://pypi.python.org/pypi/argcomplete>`_ * `Change log <https://github.com/kislyuk/argcomplete/blob/master/Changes.rst>`_ + * `xontrib-argcomplete <https://github.com/anki-code/xontrib-argcomplete>`_ - support argcomplete in `xonsh <https://github.com/xonsh/xonsh>`_ shell Bugs ~~~~ @@ -335,8 +369,8 @@ ------- Licensed under the terms of the `Apache License, Version 2.0 <http://www.apache.org/licenses/LICENSE-2.0>`_. - .. image:: https://travis-ci.org/kislyuk/argcomplete.png - :target: https://travis-ci.org/kislyuk/argcomplete + .. image:: https://github.com/kislyuk/argcomplete/workflows/Python%20package/badge.svg + :target: https://github.com/kislyuk/argcomplete/actions .. image:: https://codecov.io/github/kislyuk/argcomplete/coverage.svg?branch=master :target: https://codecov.io/github/kislyuk/argcomplete?branch=master .. image:: https://img.shields.io/pypi/v/argcomplete.svg diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/argcomplete-1.11.1/README.rst new/argcomplete-1.12.2/README.rst --- old/argcomplete-1.11.1/README.rst 2019-12-22 22:07:12.000000000 +0100 +++ new/argcomplete-1.12.2/README.rst 2020-11-24 05:09:16.000000000 +0100 @@ -276,12 +276,44 @@ ------------ To activate completions for fish use:: - register-python-argcomplete --shell fish my-awesome-script | . + register-python-argcomplete --shell fish my-awesome-script | source or create new completion file, e.g:: register-python-argcomplete --shell fish ~/.config/fish/completions/my-awesome-script.fish +Completion Description For Fish +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +By default help string is added as completion description. + +.. image:: docs/fish_help_string.png + +You can disable this feature by removing ``_ARGCOMPLETE_DFS`` variable, e.g:: + + register-python-argcomplete --shell fish my-awesome-script | grep -v _ARGCOMPLETE_DFS | . + +Git Bash Support +---------------- +Due to limitations of file descriptor inheritance on Windows, +Git Bash not supported out of the box. You can opt in to using +temporary files instead of file descriptors for for IPC +by setting the environment variable ``ARGCOMPLETE_USE_TEMPFILES``, +e.g. by adding ``export ARGCOMPLETE_USE_TEMPFILES=1`` to ``~/.bashrc``. + +For full support, consider using Bash with the +Windows Subsystem for Linux (WSL). + +External argcomplete script +--------------------------- +To register an argcomplete script for an arbitrary name, the ``--external-argcomplete-script`` argument of the ``register-python-argcomplete`` script can be used:: + + eval "$(register-python-argcomplete --external-argcomplete-script /path/to/script arbitrary-name)" + +This allows, for example, to use the auto completion functionality of argcomplete for an application not written in Python. +The command line interface of this program must be additionally implemented in a Python script with argparse and argcomplete and whenever the application is called the registered external argcomplete script is used for auto completion. + +This option can also be used in combination with the other supported shells. + Python Support -------------- Argcomplete requires Python 2.7 or 3.5+. @@ -315,6 +347,7 @@ * `Documentation <https://kislyuk.github.io/argcomplete/>`_ * `Package distribution (PyPI) <https://pypi.python.org/pypi/argcomplete>`_ * `Change log <https://github.com/kislyuk/argcomplete/blob/master/Changes.rst>`_ +* `xontrib-argcomplete <https://github.com/anki-code/xontrib-argcomplete>`_ - support argcomplete in `xonsh <https://github.com/xonsh/xonsh>`_ shell Bugs ~~~~ @@ -324,8 +357,8 @@ ------- Licensed under the terms of the `Apache License, Version 2.0 <http://www.apache.org/licenses/LICENSE-2.0>`_. -.. image:: https://travis-ci.org/kislyuk/argcomplete.png - :target: https://travis-ci.org/kislyuk/argcomplete +.. image:: https://github.com/kislyuk/argcomplete/workflows/Python%20package/badge.svg + :target: https://github.com/kislyuk/argcomplete/actions .. image:: https://codecov.io/github/kislyuk/argcomplete/coverage.svg?branch=master :target: https://codecov.io/github/kislyuk/argcomplete?branch=master .. image:: https://img.shields.io/pypi/v/argcomplete.svg diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/argcomplete-1.11.1/argcomplete/__init__.py new/argcomplete-1.12.2/argcomplete/__init__.py --- old/argcomplete-1.11.1/argcomplete/__init__.py 2019-12-28 17:07:40.000000000 +0100 +++ new/argcomplete-1.12.2/argcomplete/__init__.py 2020-07-12 20:14:04.000000000 +0200 @@ -182,6 +182,13 @@ debug_stream = os.fdopen(9, "w") except: debug_stream = sys.stderr + debug() + + if output_stream is None: + filename = os.environ.get("_ARGCOMPLETE_STDOUT_FILENAME") + if filename is not None: + debug("Using output file {}".format(filename)) + output_stream = open(filename, "wb") if output_stream is None: try: @@ -199,6 +206,11 @@ debug("Invalid value for IFS, quitting [{v}]".format(v=ifs)) exit_method(1) + dfs = os.environ.get("_ARGCOMPLETE_DFS") + if dfs and len(dfs) != 1: + debug("Invalid value for DFS, quitting [{v}]".format(v=dfs)) + exit_method(1) + comp_line = os.environ["COMP_LINE"] comp_point = int(os.environ["COMP_POINT"]) @@ -226,6 +238,12 @@ completions = self._get_completions(comp_words, cword_prefix, cword_prequote, last_wordbreak_pos) + if dfs: + display_completions = {key_part: value.replace(ifs, " ") if value else "" + for key, value in self._display_completions.items() + for key_part in key} + completions = [dfs.join((key, display_completions.get(key) or "")) for key in completions] + debug("\nReturning completions:", completions) output_stream.write(ifs.join(completions).encode(sys_encoding)) output_stream.flush() @@ -321,16 +339,16 @@ return self.active_parsers def _get_subparser_completions(self, parser, cword_prefix): - def filter_aliases(metavar, dest, prefix): - if not metavar: - return dest if dest and dest.startswith(prefix) else "" - - # metavar combines dest and aliases with ",". - a = metavar.replace(",", "").split() - return " ".join(x for x in a if x.startswith(prefix)) + def filter_aliases(aliases, prefix): + return tuple(x for x in aliases if x.startswith(prefix)) + + aliases_by_parser = {} + for key in parser.choices.keys(): + p = parser.choices[key] + aliases_by_parser.setdefault(p, []).append(key) for action in parser._get_subactions(): - subcmd_with_aliases = filter_aliases(action.metavar, action.dest, cword_prefix) + subcmd_with_aliases = filter_aliases(aliases_by_parser[parser.choices[action.dest]], cword_prefix) if subcmd_with_aliases: self._display_completions[subcmd_with_aliases] = action.help @@ -350,8 +368,8 @@ def _get_option_completions(self, parser, cword_prefix): self._display_completions.update( - [[" ".join(ensure_str(x) for x in action.option_strings - if ensure_str(x).startswith(cword_prefix)), action.help] + [[tuple(ensure_str(x) for x in action.option_strings + if ensure_str(x).startswith(cword_prefix)), action.help] for action in parser._actions if action.option_strings]) @@ -428,6 +446,9 @@ completer = self.default_completer if completer: + if isinstance(completer, SuppressCompleter) and completer.suppress(): + continue + if callable(completer): completions_from_callable = [c for c in completer( prefix=cword_prefix, action=active_action, parser=parser, parsed_args=parsed_args) @@ -437,10 +458,10 @@ completions += completions_from_callable if isinstance(completer, completers.ChoicesCompleter): self._display_completions.update( - [[x, active_action.help] for x in completions_from_callable]) + [[(x,), active_action.help] for x in completions_from_callable]) else: self._display_completions.update( - [[x, ""] for x in completions_from_callable]) + [[(x,), ""] for x in completions_from_callable]) else: debug("Completer is not callable, trying the readline completer protocol instead") for i in range(9999): @@ -448,7 +469,7 @@ if next_completion is None: break if self.validator(next_completion, cword_prefix): - self._display_completions.update({next_completion: ""}) + self._display_completions.update({(next_completion,): ""}) completions.append(next_completion) if optional_prefix: completions = [optional_prefix + "=" + completion for completion in completions] @@ -635,7 +656,7 @@ readline.set_completion_display_matches_hook(display_completions) """ - return self._display_completions + return {" ".join(k): v for k, v in self._display_completions.items()} class ExclusiveCompletionFinder(CompletionFinder): @staticmethod diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/argcomplete-1.11.1/argcomplete/bash_completion.d/python-argcomplete new/argcomplete-1.12.2/argcomplete/bash_completion.d/python-argcomplete --- old/argcomplete-1.11.1/argcomplete/bash_completion.d/python-argcomplete 2019-12-22 21:59:57.000000000 +0100 +++ new/argcomplete-1.12.2/argcomplete/bash_completion.d/python-argcomplete 2020-09-27 06:24:26.000000000 +0200 @@ -14,8 +14,22 @@ # Run something, muting output or redirecting it to the debug stream # depending on the value of _ARC_DEBUG. +# If ARGCOMPLETE_USE_TEMPFILES is set, use tempfiles for IPC. __python_argcomplete_run() { - if [[ -z "$_ARC_DEBUG" ]]; then + if [[ -z "${ARGCOMPLETE_USE_TEMPFILES-}" ]]; then + __python_argcomplete_run_inner "$@" + return + fi + local tmpfile="$(mktemp)" + _ARGCOMPLETE_STDOUT_FILENAME="$tmpfile" __python_argcomplete_run_inner "$@" + local code=$? + cat "$tmpfile" + rm "$tmpfile" + return $code +} + +__python_argcomplete_run_inner() { + if [[ -z "${_ARC_DEBUG-}" ]]; then "$@" 8>&1 9>&2 1>/dev/null 2>&1 else "$@" 8>&1 9>&2 1>&9 2>&1 @@ -82,7 +96,7 @@ __python_argcomplete_run "$executable" "${COMP_WORDS[@]:1:ARGCOMPLETE-1}") ) if [[ $? != 0 ]]; then unset COMPREPLY - elif [[ "$COMPREPLY" =~ [=/:]$ ]]; then + elif [[ "${COMPREPLY-}" =~ [=/:]$ ]]; then compopt -o nospace fi else diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/argcomplete-1.11.1/argcomplete/shell_integration.py new/argcomplete-1.12.2/argcomplete/shell_integration.py --- old/argcomplete-1.11.1/argcomplete/shell_integration.py 2020-01-14 17:20:59.000000000 +0100 +++ new/argcomplete-1.12.2/argcomplete/shell_integration.py 2020-09-27 06:24:26.000000000 +0200 @@ -8,15 +8,29 @@ bashcode = r''' # Run something, muting output or redirecting it to the debug stream # depending on the value of _ARC_DEBUG. +# If ARGCOMPLETE_USE_TEMPFILES is set, use tempfiles for IPC. __python_argcomplete_run() { - if [[ -z "$_ARC_DEBUG" ]]; then + if [[ -z "${ARGCOMPLETE_USE_TEMPFILES-}" ]]; then + __python_argcomplete_run_inner "$@" + return + fi + local tmpfile="$(mktemp)" + _ARGCOMPLETE_STDOUT_FILENAME="$tmpfile" __python_argcomplete_run_inner "$@" + local code=$? + cat "$tmpfile" + rm "$tmpfile" + return $code +} + +__python_argcomplete_run_inner() { + if [[ -z "${_ARC_DEBUG-}" ]]; then "$@" 8>&1 9>&2 1>/dev/null 2>&1 else "$@" 8>&1 9>&2 1>&9 2>&1 fi } -_python_argcomplete() { +_python_argcomplete%(function_suffix)s() { local IFS=$'\013' local SUPPRESS_SPACE=0 if compopt +o nospace 2> /dev/null; then @@ -29,23 +43,24 @@ _ARGCOMPLETE_COMP_WORDBREAKS="$COMP_WORDBREAKS" \ _ARGCOMPLETE=1 \ _ARGCOMPLETE_SUPPRESS_SPACE=$SUPPRESS_SPACE \ - __python_argcomplete_run "$1") ) + __python_argcomplete_run "%(argcomplete_script)s") ) if [[ $? != 0 ]]; then unset COMPREPLY - elif [[ $SUPPRESS_SPACE == 1 ]] && [[ "$COMPREPLY" =~ [=/:]$ ]]; then + elif [[ $SUPPRESS_SPACE == 1 ]] && [[ "${COMPREPLY-}" =~ [=/:]$ ]]; then compopt -o nospace fi } -complete %(complete_opts)s -F _python_argcomplete %(executables)s +complete %(complete_opts)s -F _python_argcomplete%(function_suffix)s %(executables)s ''' tcshcode = '''\ -complete "%(executable)s" 'p@*@`python-argcomplete-tcsh "%(executable)s"`@' ; +complete "%(executable)s" 'p@*@`python-argcomplete-tcsh "%(argcomplete_script)s"`@' ; ''' fishcode = r''' function __fish_%(executable)s_complete set -x _ARGCOMPLETE 1 + set -x _ARGCOMPLETE_DFS \t set -x _ARGCOMPLETE_IFS \n set -x _ARGCOMPLETE_SUPPRESS_SPACE 1 set -x _ARGCOMPLETE_SHELL fish @@ -53,24 +68,29 @@ set -x COMP_POINT (string length (commandline -cp)) set -x COMP_TYPE if set -q _ARC_DEBUG - %(executable)s 8>&1 9>&2 1>/dev/null 2>&1 + %(argcomplete_script)s 8>&1 9>&2 1>/dev/null 2>&1 else - %(executable)s 8>&1 9>&2 1>&9 2>&1 + %(argcomplete_script)s 8>&1 9>&2 1>&9 2>&1 end end complete -c %(executable)s -f -a '(__fish_%(executable)s_complete)' ''' +shell_codes = {'bash': bashcode, 'tcsh': tcshcode, 'fish': fishcode} -def shellcode(executables, use_defaults=True, shell='bash', complete_arguments=None): + +def shellcode(executables, use_defaults=True, shell='bash', complete_arguments=None, argcomplete_script=None): ''' Provide the shell code required to register a python executable for use with the argcomplete module. - :param str executables: Executables to be completed (when invoked exactly with this name + :param list(str) executables: Executables to be completed (when invoked exactly with this name) :param bool use_defaults: Whether to fallback to readline's default completion when no matches are generated. :param str shell: Name of the shell to output code for (bash or tcsh) :param complete_arguments: Arguments to call complete with :type complete_arguments: list(str) or None + :param argcomplete_script: Script to call complete with, if not the executable to complete. + If supplied, will be used to complete *all* passed executables. + :type argcomplete_script: str or None ''' if complete_arguments is None: @@ -81,14 +101,21 @@ if shell == 'bash': quoted_executables = [quote(i) for i in executables] executables_list = " ".join(quoted_executables) - code = bashcode % dict(complete_opts=complete_options, executables=executables_list) - elif shell == 'fish': - code = "" - for executable in executables: - code += fishcode % dict(executable=executable) + script = argcomplete_script + if script: + function_suffix = '_' + script + else: + script = '$1' + function_suffix = '' + code = bashcode % dict(complete_opts=complete_options, executables=executables_list, + argcomplete_script=script, function_suffix=function_suffix) else: code = "" for executable in executables: - code += tcshcode % dict(executable=executable) + script = argcomplete_script + # If no script was specified, default to the executable being completed. + if not script: + script = executable + code += shell_codes.get(shell, '') % dict(executable=executable, argcomplete_script=script) return code diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/argcomplete-1.11.1/argcomplete.egg-info/PKG-INFO new/argcomplete-1.12.2/argcomplete.egg-info/PKG-INFO --- old/argcomplete-1.11.1/argcomplete.egg-info/PKG-INFO 2020-01-14 18:19:36.000000000 +0100 +++ new/argcomplete-1.12.2/argcomplete.egg-info/PKG-INFO 2020-11-24 05:10:45.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: argcomplete -Version: 1.11.1 +Version: 1.12.2 Summary: Bash tab completion for argparse Home-page: https://github.com/kislyuk/argcomplete Author: Andrey Kislyuk @@ -9,6 +9,7 @@ Project-URL: Documentation, https://kislyuk.github.io/argcomplete Project-URL: Source Code, https://github.com/kislyuk/argcomplete Project-URL: Issue Tracker, https://github.com/kislyuk/argcomplete/issues +Project-URL: Change Log, https://github.com/kislyuk/argcomplete/blob/master/Changes.rst Description: argcomplete - Bash tab completion for argparse ============================================== *Tab complete all the things!* @@ -287,12 +288,44 @@ ------------ To activate completions for fish use:: - register-python-argcomplete --shell fish my-awesome-script | . + register-python-argcomplete --shell fish my-awesome-script | source or create new completion file, e.g:: register-python-argcomplete --shell fish ~/.config/fish/completions/my-awesome-script.fish + Completion Description For Fish + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + By default help string is added as completion description. + + .. image:: docs/fish_help_string.png + + You can disable this feature by removing ``_ARGCOMPLETE_DFS`` variable, e.g:: + + register-python-argcomplete --shell fish my-awesome-script | grep -v _ARGCOMPLETE_DFS | . + + Git Bash Support + ---------------- + Due to limitations of file descriptor inheritance on Windows, + Git Bash not supported out of the box. You can opt in to using + temporary files instead of file descriptors for for IPC + by setting the environment variable ``ARGCOMPLETE_USE_TEMPFILES``, + e.g. by adding ``export ARGCOMPLETE_USE_TEMPFILES=1`` to ``~/.bashrc``. + + For full support, consider using Bash with the + Windows Subsystem for Linux (WSL). + + External argcomplete script + --------------------------- + To register an argcomplete script for an arbitrary name, the ``--external-argcomplete-script`` argument of the ``register-python-argcomplete`` script can be used:: + + eval "$(register-python-argcomplete --external-argcomplete-script /path/to/script arbitrary-name)" + + This allows, for example, to use the auto completion functionality of argcomplete for an application not written in Python. + The command line interface of this program must be additionally implemented in a Python script with argparse and argcomplete and whenever the application is called the registered external argcomplete script is used for auto completion. + + This option can also be used in combination with the other supported shells. + Python Support -------------- Argcomplete requires Python 2.7 or 3.5+. @@ -326,6 +359,7 @@ * `Documentation <https://kislyuk.github.io/argcomplete/>`_ * `Package distribution (PyPI) <https://pypi.python.org/pypi/argcomplete>`_ * `Change log <https://github.com/kislyuk/argcomplete/blob/master/Changes.rst>`_ + * `xontrib-argcomplete <https://github.com/anki-code/xontrib-argcomplete>`_ - support argcomplete in `xonsh <https://github.com/xonsh/xonsh>`_ shell Bugs ~~~~ @@ -335,8 +369,8 @@ ------- Licensed under the terms of the `Apache License, Version 2.0 <http://www.apache.org/licenses/LICENSE-2.0>`_. - .. image:: https://travis-ci.org/kislyuk/argcomplete.png - :target: https://travis-ci.org/kislyuk/argcomplete + .. image:: https://github.com/kislyuk/argcomplete/workflows/Python%20package/badge.svg + :target: https://github.com/kislyuk/argcomplete/actions .. image:: https://codecov.io/github/kislyuk/argcomplete/coverage.svg?branch=master :target: https://codecov.io/github/kislyuk/argcomplete?branch=master .. image:: https://img.shields.io/pypi/v/argcomplete.svg diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/argcomplete-1.11.1/argcomplete.egg-info/requires.txt new/argcomplete-1.12.2/argcomplete.egg-info/requires.txt --- old/argcomplete-1.11.1/argcomplete.egg-info/requires.txt 2020-01-14 18:19:36.000000000 +0100 +++ new/argcomplete-1.12.2/argcomplete.egg-info/requires.txt 2020-11-24 05:10:45.000000000 +0100 @@ -1,15 +1,15 @@ [:python_version == "2.7"] -importlib-metadata<2,>=0.23 +importlib-metadata<4,>=0.23 [:python_version == "3.5"] -importlib-metadata<2,>=0.23 +importlib-metadata<4,>=0.23 [:python_version == "3.6"] -importlib-metadata<2,>=0.23 +importlib-metadata<4,>=0.23 [:python_version == "3.7"] -importlib-metadata<2,>=0.23 +importlib-metadata<4,>=0.23 [test] coverage diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/argcomplete-1.11.1/scripts/register-python-argcomplete new/argcomplete-1.12.2/scripts/register-python-argcomplete --- old/argcomplete-1.11.1/scripts/register-python-argcomplete 2019-12-22 21:59:20.000000000 +0100 +++ new/argcomplete-1.12.2/scripts/register-python-argcomplete 2020-05-22 02:59:06.000000000 +0200 @@ -43,6 +43,9 @@ '-s', '--shell', choices=('bash', 'tcsh', 'fish'), default='bash', help='output code for the specified shell') +parser.add_argument( + '-e', '--external-argcomplete-script', + help='external argcomplete script for auto completion of the executable') parser.add_argument( 'executable', @@ -59,4 +62,4 @@ sys.stdout.write(argcomplete.shellcode( - args.executable, args.use_defaults, args.shell, args.complete_arguments)) + args.executable, args.use_defaults, args.shell, args.complete_arguments, args.external_argcomplete_script)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/argcomplete-1.11.1/setup.py new/argcomplete-1.12.2/setup.py --- old/argcomplete-1.11.1/setup.py 2020-01-14 18:19:08.000000000 +0100 +++ new/argcomplete-1.12.2/setup.py 2020-11-24 05:09:45.000000000 +0100 @@ -5,16 +5,17 @@ install_requires = [] tests_require = ["coverage", "flake8", "pexpect", "wheel"] -importlib_backport_requires = ["importlib-metadata >= 0.23, < 2"] +importlib_backport_requires = ["importlib-metadata >= 0.23, < 4"] setup( name='argcomplete', - version='1.11.1', + version='1.12.2', url='https://github.com/kislyuk/argcomplete', project_urls={ "Documentation": "https://kislyuk.github.io/argcomplete", "Source Code": "https://github.com/kislyuk/argcomplete", - "Issue Tracker": "https://github.com/kislyuk/argcomplete/issues" + "Issue Tracker": "https://github.com/kislyuk/argcomplete/issues", + "Change Log": "https://github.com/kislyuk/argcomplete/blob/master/Changes.rst", }, license='Apache Software License', author='Andrey Kislyuk', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/argcomplete-1.11.1/test/prog new/argcomplete-1.12.2/test/prog --- old/argcomplete-1.11.1/test/prog 2019-10-24 01:48:19.000000000 +0200 +++ new/argcomplete-1.12.2/test/prog 2020-07-12 20:14:04.000000000 +0200 @@ -31,12 +31,12 @@ parser = argparse.ArgumentParser() subparsers = parser.add_subparsers() -subparsers.add_parser('basic').add_argument('arg', choices=['foo', 'bar', 'baz']) +subparsers.add_parser('basic', help='basic help\nnext line of help').add_argument('arg', choices=['foo', 'bar', 'baz']) subparsers.add_parser('space').add_argument('arg', choices=['foo bar', 'baz']) subparsers.add_parser('cont').add_argument('arg').completer = complete_cont subparsers.add_parser('spec').add_argument('arg', choices=['d$e$f', 'd$e$g', 'x!x', r'y\y']) subparsers.add_parser('quote').add_argument('arg', choices=["1'1", '2"2']) -subparsers.add_parser('break').add_argument('arg', choices=['a:b:c', 'a:b:d']) +subparsers.add_parser('break', help="break help").add_argument('arg', choices=['a:b:c', 'a:b:d']) subparsers.add_parser('env').add_argument('arg').completer = check_environ subparsers.add_parser('debug').add_argument('arg').completer = print_output subparsers.add_parser('point', add_help=False).add_argument('arg', nargs='*').completer = get_comp_point diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/argcomplete-1.11.1/test/test.py new/argcomplete-1.12.2/test/test.py --- old/argcomplete-1.11.1/test/test.py 2019-11-22 21:05:27.000000000 +0100 +++ new/argcomplete-1.12.2/test/test.py 2020-09-27 08:00:07.000000000 +0200 @@ -28,6 +28,8 @@ BASH_VERSION = subprocess.check_output(['bash', '-c', 'echo $BASH_VERSION']).decode() BASH_MAJOR_VERSION = int(BASH_VERSION.split('.')[0]) +FISH_VERSION_STR = subprocess.check_output(['fish', '-c', 'echo -n $FISH_VERSION']).decode() +FISH_VERSION_TUPLE = tuple(int(x) for x in FISH_VERSION_STR.split('.')) class TempDir(object): @@ -74,8 +76,10 @@ with TemporaryFile() as t: os.environ["COMP_LINE"] = ensure_bytes(command) if USING_PYTHON2 else command os.environ["COMP_POINT"] = point - self.assertRaises(SystemExit, completer, parser, output_stream=t, - exit_method=sys.exit, **kwargs) + with self.assertRaises(SystemExit) as cm: + completer(parser, output_stream=t, exit_method=sys.exit, **kwargs) + if cm.exception.code != 0: + raise Exception("Unexpected exit code %d" % cm.exception.code) t.seek(0) return t.read().decode(sys_encoding).split(IFS) @@ -371,7 +375,7 @@ [r"on\ a\ train", r"with\ a\ goat", r"on\ a\ boat", r"in\ the\ rain", "--help", "-h"]), ("prog eggs ", [r"on\ a\ train", r"with\ a\ goat", r"on\ a\ boat", r"in\ the\ rain", "--help", "-h"]), ("prog eggs \"on a", ['on a train', 'on a boat']), - ("prog eggs on\\ a", [r"on\ a\ train", "on\ a\ boat"]), + ("prog eggs on\\ a", [r"on\ a\ train", r"on\ a\ boat"]), ("prog spam ", ["iberico", "ham", "--help", "-h"]), ) @@ -398,7 +402,7 @@ ("prog ", ["--книга", "-h", "--help"]), ("prog --книга ", [r"Трудно\ быть\ богом", r"Парень\ из\ преисподней", r"Понедельник\ начинается\ в\ субботу"]), - ("prog --книга П", [r"Парень\ из\ преисподней", "Понедельник\ начинается\ в\ субботу"]), + ("prog --книга П", [r"Парень\ из\ преисподней", r"Понедельник\ начинается\ в\ субботу"]), ("prog --книга Пу", [""]), ) @@ -504,6 +508,41 @@ self.assertEqual("ttt", disp.get("--oh", "")) self.assertEqual("ccc", disp.get("--ch", "")) + @unittest.skipIf(USING_PYTHON2, "Subparser aliases aren't supported on Python 2") + def test_display_completions_with_aliases(self): + parser = ArgumentParser() + parser.add_subparsers().add_parser("a", aliases=["b", "c"], help="abc help") + + # empty + completer = CompletionFinder(parser) + completer.rl_complete("", 0) + disp = completer.get_display_completions() + self.assertEqual({"a b c": "abc help", "-h --help": "show this help message and exit"}, disp) + + # a + completer = CompletionFinder(parser) + completer.rl_complete("a", 0) + disp = completer.get_display_completions() + self.assertEqual({"a": "abc help", "": "show this help message and exit"}, disp) + + # b + completer = CompletionFinder(parser) + completer.rl_complete("b", 0) + disp = completer.get_display_completions() + self.assertEqual({"b": "abc help", "": "show this help message and exit"}, disp) + + # c + completer = CompletionFinder(parser) + completer.rl_complete("c", 0) + disp = completer.get_display_completions() + self.assertEqual({"c": "abc help", "": "show this help message and exit"}, disp) + + # ( + completer = CompletionFinder(parser) + completer.rl_complete("(", 0) + disp = completer.get_display_completions() + self.assertEqual({"": "show this help message and exit"}, disp) + def test_nargs_one_or_more(self): def make_parser(): parser = ArgumentParser() @@ -753,9 +792,41 @@ fh.write(sc.encode()) fh.flush() subprocess.check_call(['bash', '-n', fh.name]) + with NamedTemporaryFile() as fh: + sc = shellcode(["prog"], use_defaults=True, shell="bash", complete_arguments=None, + argcomplete_script="~/.bash_completion.d/prog.py") + fh.write(sc.encode()) + fh.flush() + subprocess.check_call(['bash', '-n', fh.name]) sc = shellcode(["prog"], use_defaults=False, shell="tcsh", complete_arguments=["-o", "nospace"]) sc = shellcode(["prog"], use_defaults=False, shell="woosh", complete_arguments=["-o", "nospace"]) sc = shellcode(["prog"], shell="fish") + sc = shellcode(["prog"], shell="fish", argcomplete_script="~/.bash_completion.d/prog.py") + + def test_option_help(self): + os.environ["_ARGCOMPLETE_DFS"] = "\t" + os.environ["_ARGCOMPLETE_SUPPRESS_SPACE"] = "1" + os.environ["_ARGCOMPLETE_SHELL"] = "fish" + + p = ArgumentParser() + p.add_argument("--foo", help="foo" + IFS + "help") + p.add_argument("--bar", "--bar2", help="bar help") + + subparsers = p.add_subparsers() + subparsers.add_parser("subcommand", help="subcommand help") + subparsers.add_parser("subcommand 2", help="subcommand 2 help") + + completions = self.run_completer(p, "prog --f") + self.assertEqual(set(completions), {"--foo\tfoo help"}) + + completions = self.run_completer(p, "prog --b") + self.assertEqual(set(completions), {"--bar\tbar help", "--bar2\tbar help"}) + + completions = self.run_completer(p, "prog sub") + self.assertEqual(set(completions), {"subcommand\tsubcommand help", "subcommand 2\tsubcommand 2 help"}) + + os.environ["_ARGCOMPLETE_DFS"] = "invalid" + self.assertRaises(Exception, self.run_completer, p, "prog --b") class TestArgcompleteREPL(unittest.TestCase): def setUp(self): @@ -890,8 +961,8 @@ self.assertEqual(self.prefix('a b c'), 'c') def test_escaped_special(self): - self.assertEqual(self.prefix('a\$b'), 'a$b') - self.assertEqual(self.prefix('a\`b'), 'a`b') + self.assertEqual(self.prefix(r'a\$b'), 'a$b') + self.assertEqual(self.prefix(r'a\`b'), 'a`b') def test_unescaped_special(self): self.assertEqual(self.prefix('a$b'), 'a$b') @@ -899,8 +970,8 @@ @unittest.expectedFailure def test_escaped_special_in_double_quotes(self): - self.assertEqual(self.prefix('"a\$b'), 'a$b') - self.assertEqual(self.prefix('"a\`b'), 'a`b') + self.assertEqual(self.prefix(r'"a\$b'), 'a$b') + self.assertEqual(self.prefix(r'"a\`b'), 'a`b') def test_punctuation(self): self.assertEqual(self.prefix('a,'), 'a,') @@ -1120,7 +1191,9 @@ # This requires compopt which is not available in 3.x. expected_failures.append('test_quoted_exact') - install_cmd = 'eval "$(register-python-argcomplete prog)"' + # 'dummy' argument unused; checks multi-command registration works + # by passing 'prog' as the second argument. + install_cmd = 'eval "$(register-python-argcomplete dummy prog)"' def setUp(self): sh = pexpect.replwrap.bash() @@ -1131,6 +1204,10 @@ sh.run_command('complete -r python python2 python3') output = sh.run_command(self.install_cmd) self.assertEqual(output, '') + # Register a dummy completion with an external argcomplete script + # to ensure this doesn't overwrite our previous registration. + output = sh.run_command('eval "$(register-python-argcomplete dummy --external-argcomplete-script dummy)"') + self.assertEqual(output, '') self.sh = sh def test_one_space_after_exact(self): @@ -1147,6 +1224,18 @@ self.assertIn('PYTHON_ARGCOMPLETE_STDERR\r\n', output) self.assertTrue(output.endswith('foo\r\n')) + def test_temp_file(self): + self.sh.run_command('export ARGCOMPLETE_USE_TEMPFILES=1') + self.assertEqual(self.sh.run_command('prog basic f\t'), 'foo\r\n') + # Confirm we used a temp file by searching for the debug message. + self.sh.run_command('export _ARC_DEBUG=1') + output = self.sh.run_command('prog basic f\t') + self.assertIn('Using output file ', output) + + def test_nounset(self): + self.sh.run_command('set -o nounset') + self.test_simple_completion() + @unittest.skipIf(BASH_MAJOR_VERSION < 4, 'complete -D not supported') class TestBashGlobal(TestBash): @@ -1210,10 +1299,12 @@ """Test completing a console_script for a package.""" self._test_console_script(package=True) + @unittest.skipIf(os.uname()[0] == "Darwin", "Skip test that fails on MacOS") def test_console_script_module_wheel(self): """Test completing a console_script for a module from a wheel.""" self._test_console_script(wheel=True) + @unittest.skipIf(os.uname()[0] == "Darwin", "Skip test that fails on MacOS") def test_console_script_package_wheel(self): """Test completing a console_script for a package from a wheel.""" self._test_console_script(package=True, wheel=True) @@ -1235,7 +1326,13 @@ path = ' '.join([os.path.join(BASE_DIR, 'scripts'), TEST_DIR, '$path']) sh.run_command('set path = ({0})'.format(path)) sh.run_command('setenv PYTHONPATH {0}'.format(BASE_DIR)) - output = sh.run_command('eval `register-python-argcomplete --shell tcsh prog`') + # 'dummy' argument unused; checks multi-command registration works + # by passing 'prog' as the second argument. + output = sh.run_command('eval `register-python-argcomplete --shell tcsh dummy prog`') + self.assertEqual(output, '') + # Register a dummy completion with an external argcomplete script + # to ensure this doesn't overwrite our previous registration. + output = sh.run_command('eval `register-python-argcomplete --shell tcsh dummy --external-argcomplete-script dummy`') self.assertEqual(output, '') self.sh = sh @@ -1251,8 +1348,11 @@ expected_failures = [ 'test_parse_special_characters', 'test_comp_point', - 'test_special_characters_double_quoted' ] + if FISH_VERSION_TUPLE < (3, 1): + expected_failures.extend([ + 'test_special_characters_double_quoted' + ]) skipped = [ 'test_single_quotes_in_single_quotes', @@ -1265,7 +1365,13 @@ path = ' '.join([os.path.join(BASE_DIR, 'scripts'), TEST_DIR, '$PATH']) sh.run_command('set -x PATH {0}'.format(path)) sh.run_command('set -x PYTHONPATH {0}'.format(BASE_DIR)) - output = sh.run_command('register-python-argcomplete --shell fish prog | .') + # 'dummy' argument unused; checks multi-command registration works + # by passing 'prog' as the second argument. + output = sh.run_command('register-python-argcomplete --shell fish dummy prog | .') + self.assertEqual(output, '') + # Register a dummy completion with an external argcomplete script + # to ensure this doesn't overwrite our previous registration. + output = sh.run_command('register-python-argcomplete --shell fish dummy --external-argcomplete-script dummy | .') self.assertEqual(output, '') self.sh = sh ++++++ skip_tcsh_tests.patch ++++++ --- /var/tmp/diff_new_pack.VbSizh/_old 2020-12-21 10:26:54.016216805 +0100 +++ /var/tmp/diff_new_pack.VbSizh/_new 2020-12-21 10:26:54.016216805 +0100 @@ -1,8 +1,8 @@ -Index: argcomplete-1.11.0/test/test.py +Index: argcomplete-1.12.2/test/test.py =================================================================== ---- argcomplete-1.11.0.orig/test/test.py -+++ argcomplete-1.11.0/test/test.py -@@ -1219,34 +1219,6 @@ class TestBashGlobal(TestBash): +--- argcomplete-1.12.2.orig/test/test.py ++++ argcomplete-1.12.2/test/test.py +@@ -1310,40 +1310,6 @@ class TestBashGlobal(TestBash): self._test_console_script(package=True, wheel=True) @@ -22,7 +22,13 @@ - path = ' '.join([os.path.join(BASE_DIR, 'scripts'), TEST_DIR, '$path']) - sh.run_command('set path = ({0})'.format(path)) - sh.run_command('setenv PYTHONPATH {0}'.format(BASE_DIR)) -- output = sh.run_command('eval `register-python-argcomplete --shell tcsh prog`') +- # 'dummy' argument unused; checks multi-command registration works +- # by passing 'prog' as the second argument. +- output = sh.run_command('eval `register-python-argcomplete --shell tcsh dummy prog`') +- self.assertEqual(output, '') +- # Register a dummy completion with an external argcomplete script +- # to ensure this doesn't overwrite our previous registration. +- output = sh.run_command('eval `register-python-argcomplete --shell tcsh dummy --external-argcomplete-script dummy`') - self.assertEqual(output, '') - self.sh = sh - ++++++ trim-test-deps.patch ++++++ --- /var/tmp/diff_new_pack.VbSizh/_old 2020-12-21 10:26:54.028216819 +0100 +++ /var/tmp/diff_new_pack.VbSizh/_new 2020-12-21 10:26:54.028216819 +0100 @@ -1,13 +1,13 @@ -Index: argcomplete-1.11.0/setup.py +Index: argcomplete-1.12.2/setup.py =================================================================== ---- argcomplete-1.11.0.orig/setup.py -+++ argcomplete-1.11.0/setup.py +--- argcomplete-1.12.2.orig/setup.py ++++ argcomplete-1.12.2/setup.py @@ -4,7 +4,7 @@ import glob from setuptools import setup, find_packages install_requires = [] -tests_require = ["coverage", "flake8", "pexpect", "wheel"] +tests_require = ["pexpect"] - importlib_backport_requires = ["importlib-metadata >= 0.23, < 2"] + importlib_backport_requires = ["importlib-metadata >= 0.23, < 4"] setup( _______________________________________________ openSUSE Commits mailing list -- [email protected] To unsubscribe, email [email protected] List Netiquette: https://en.opensuse.org/openSUSE:Mailing_list_netiquette List Archives: https://lists.opensuse.org/archives/list/[email protected]
