Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-knack for openSUSE:Factory checked in at 2021-12-07 23:59:55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-knack (Old) and /work/SRC/openSUSE:Factory/.python-knack.new.31177 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-knack" Tue Dec 7 23:59:55 2021 rev:17 rq:936174 version:0.9.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-knack/python-knack.changes 2021-05-11 23:04:08.796961450 +0200 +++ /work/SRC/openSUSE:Factory/.python-knack.new.31177/python-knack.changes 2021-12-08 00:00:04.599672837 +0100 @@ -1,0 +2,8 @@ +Tue Dec 7 08:24:18 UTC 2021 - John Paul Adrian Glaubitz <adrian.glaub...@suse.com> + +- Update to version 0.9.0 + * Support Python 3.10 (#250) + * Only install colorama on Windows (#249) +- Update BuildRequires and Requires from setup.py + +------------------------------------------------------------------- Old: ---- knack-0.8.2.tar.gz New: ---- knack-0.9.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-knack.spec ++++++ --- /var/tmp/diff_new_pack.SAmZVn/_old 2021-12-08 00:00:05.555669564 +0100 +++ /var/tmp/diff_new_pack.SAmZVn/_new 2021-12-08 00:00:05.559669550 +0100 @@ -19,7 +19,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} %define skip_python2 1 Name: python-knack -Version: 0.8.2 +Version: 0.9.0 Release: 0 Summary: A Command-Line Interface framework License: MIT @@ -28,7 +28,6 @@ Source: https://files.pythonhosted.org/packages/source/k/knack/knack-%{version}.tar.gz BuildRequires: %{python_module PyYAML} BuildRequires: %{python_module argcomplete} -BuildRequires: %{python_module colorama} BuildRequires: %{python_module jmespath} BuildRequires: %{python_module mock} BuildRequires: %{python_module pygments} @@ -40,7 +39,6 @@ BuildRequires: python-rpm-macros Requires: python-PyYAML Requires: python-argcomplete -Requires: python-colorama Requires: python-jmespath Requires: python-pygments Requires: python-tabulate ++++++ knack-0.8.2.tar.gz -> knack-0.9.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/knack-0.8.2/HISTORY.rst new/knack-0.9.0/HISTORY.rst --- old/knack-0.8.2/HISTORY.rst 2021-05-08 08:50:44.000000000 +0200 +++ new/knack-0.9.0/HISTORY.rst 2021-11-05 06:18:23.000000000 +0100 @@ -3,6 +3,12 @@ Release History =============== +0.9.0 ++++++ + +* Support Python 3.10 (#250) +* Only install colorama on Windows (#249) + 0.8.2 +++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/knack-0.8.2/PKG-INFO new/knack-0.9.0/PKG-INFO --- old/knack-0.8.2/PKG-INFO 2021-05-08 08:50:47.000000000 +0200 +++ new/knack-0.9.0/PKG-INFO 2021-11-05 06:18:29.853407900 +0100 @@ -1,162 +1,11 @@ -Metadata-Version: 1.1 +Metadata-Version: 2.1 Name: knack -Version: 0.8.2 +Version: 0.9.0 Summary: A Command-Line Interface framework Home-page: https://github.com/microsoft/knack Author: Microsoft Corporation Author-email: azpy...@microsoft.com License: MIT -Description: Knack - ===== - - .. image:: https://img.shields.io/pypi/v/knack.svg - :target: https://pypi.python.org/pypi/knack - - .. image:: https://img.shields.io/pypi/pyversions/knack.svg - :target: https://pypi.python.org/pypi/knack - - .. image:: https://dev.azure.com/azure-sdk/public/_apis/build/status/cli/microsoft.knack?branchName=dev - :target: https://dev.azure.com/azure-sdk/public/_build/latest?definitionId=1643&branchName=dev - - - ------------ - - - :: - - _ _ - | | ___ __ __ _ ___| | __ - | |/ / '_ \ / _` |/ __| |/ / - | <| | | | (_| | (__| < - |_|\_\_| |_|\__,_|\___|_|\_\ - - - **A Command-Line Interface framework** - - Installation is easy via pip: - - .. code-block:: bash - - pip install knack - - Knack can be installed as a non-privileged user to your home directory by adding "--user" as below: - - .. code-block:: bash - - pip install knack --user - - ------------ - - .. note:: The project is in `initial development phase <https://semver.org/#how-should-i-deal-with-revisions-in-the-0yz-initial-development-phase>`__. We recommend pinning to at least a specific minor version when marking **knack** as a dependency in your project. - - ------------ - - - Usage - ===== - - - .. code-block:: python - - import sys - from collections import OrderedDict - - from knack import CLI, ArgumentsContext, CLICommandsLoader - from knack.commands import CommandGroup - - - def abc_str(length=3): - import string - return string.ascii_lowercase[:length] - - - class MyCommandsLoader(CLICommandsLoader): - def load_command_table(self, args): - with CommandGroup(self, 'abc', '__main__#{}') as g: - g.command('str', 'abc_str') - return OrderedDict(self.command_table) - - def load_arguments(self, command): - with ArgumentsContext(self, 'abc str') as ac: - ac.argument('length', type=int) - super(MyCommandsLoader, self).load_arguments(command) - - - mycli = CLI(cli_name='mycli', commands_loader_cls=MyCommandsLoader) - exit_code = mycli.invoke(sys.argv[1:]) - sys.exit(exit_code) - - # $ python mycli.py abc str - # "abc" - - # $ python mycli.py abc str --length 5 - # "abcde" - - # $ python mycli.py abc str --length 100 - # "abcdefghijklmnopqrstuvwxyz" - - - More samples and snippets are available at `examples <https://github.com/Microsoft/knack/tree/dev/examples>`__. - - - Documentation - ============= - - Documentation is available at `docs <https://github.com/Microsoft/knack/tree/dev/docs>`__. - - Developer Setup - =============== - - In a virtual environment, install the `requirements.txt` file. - - .. code-block:: bash - - pip install -r requirements.txt - pip install -e . - - Run Automation - ============== - - This project supports running automation using `tox <https://tox.readthedocs.io/en/latest/>`__. - - .. code-block:: bash - - pip install tox - tox - - - Real-world uses - =============== - - - `Azure CLI <https://github.com/Azure/azure-cli/>`__: The Azure CLI 2.0 is Azure's new command line experience for managing Azure resources. - - `VSTS CLI <https://github.com/Microsoft/vsts-cli>`__: A command-line interface for Visual Studio Team Services (VSTS) and Team Foundation Server (TFS). With the VSTS CLI, you can manage and work with resources including pull requests, work items, builds, and more. - - `Service Fabric CLI <https://github.com/Azure/service-fabric-cli>`__: A command-line interface for interacting with Azure Service Fabric clusters and their related entities. - - Do you use knack in your CLI as well? Open a pull request to include it here. We would love to have it in our list. - - - Release History - =============== - - See `GitHub Releases <https://github.com/Microsoft/knack/releases>`__. - - - Contribute Code - =============== - - This project has adopted the `Microsoft Open Source Code of Conduct <https://opensource.microsoft.com/codeofconduct/>`__. - - For more information see the `Code of Conduct FAQ <https://opensource.microsoft.com/codeofconduct/faq/>`__ or contact `openc...@microsoft.com <mailto:openc...@microsoft.com>`__ with any additional questions or comments. - - If you would like to become an active contributor to this project, please - follow the instructions provided in `Contribution License Agreement <https://cla.microsoft.com/>`__. - - - License - ======= - - Knack is licensed under `MIT <LICENSE>`__. - Platform: UNKNOWN Classifier: Development Status :: 4 - Beta Classifier: Intended Audience :: Developers @@ -167,4 +16,159 @@ Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: 3.9 +Classifier: Programming Language :: Python :: 3.10 Classifier: License :: OSI Approved :: MIT License +License-File: LICENSE + +Knack +===== + +.. image:: https://img.shields.io/pypi/v/knack.svg + :target: https://pypi.python.org/pypi/knack + +.. image:: https://img.shields.io/pypi/pyversions/knack.svg + :target: https://pypi.python.org/pypi/knack + +.. image:: https://dev.azure.com/azure-sdk/public/_apis/build/status/cli/microsoft.knack?branchName=dev + :target: https://dev.azure.com/azure-sdk/public/_build/latest?definitionId=1643&branchName=dev + + +------------ + + +:: + + _ _ + | | ___ __ __ _ ___| | __ + | |/ / '_ \ / _` |/ __| |/ / + | <| | | | (_| | (__| < + |_|\_\_| |_|\__,_|\___|_|\_\ + + +**A Command-Line Interface framework** + +Installation is easy via pip: + +.. code-block:: bash + + pip install knack + +Knack can be installed as a non-privileged user to your home directory by adding "--user" as below: + +.. code-block:: bash + + pip install knack --user + +------------ + +.. note:: The project is in `initial development phase <https://semver.org/#how-should-i-deal-with-revisions-in-the-0yz-initial-development-phase>`__. We recommend pinning to at least a specific minor version when marking **knack** as a dependency in your project. + +------------ + + +Usage +===== + + +.. code-block:: python + + import sys + from collections import OrderedDict + + from knack import CLI, ArgumentsContext, CLICommandsLoader + from knack.commands import CommandGroup + + + def abc_str(length=3): + import string + return string.ascii_lowercase[:length] + + + class MyCommandsLoader(CLICommandsLoader): + def load_command_table(self, args): + with CommandGroup(self, 'abc', '__main__#{}') as g: + g.command('str', 'abc_str') + return OrderedDict(self.command_table) + + def load_arguments(self, command): + with ArgumentsContext(self, 'abc str') as ac: + ac.argument('length', type=int) + super(MyCommandsLoader, self).load_arguments(command) + + + mycli = CLI(cli_name='mycli', commands_loader_cls=MyCommandsLoader) + exit_code = mycli.invoke(sys.argv[1:]) + sys.exit(exit_code) + + # $ python mycli.py abc str + # "abc" + + # $ python mycli.py abc str --length 5 + # "abcde" + + # $ python mycli.py abc str --length 100 + # "abcdefghijklmnopqrstuvwxyz" + + +More samples and snippets are available at `examples <https://github.com/Microsoft/knack/tree/dev/examples>`__. + + +Documentation +============= + +Documentation is available at `docs <https://github.com/Microsoft/knack/tree/dev/docs>`__. + +Developer Setup +=============== + +In a virtual environment, install the `requirements.txt` file. + +.. code-block:: bash + + pip install -r requirements.txt + pip install -e . + +Run Automation +============== + +This project supports running automation using `tox <https://tox.readthedocs.io/en/latest/>`__. + +.. code-block:: bash + + pip install tox + tox + + +Real-world uses +=============== + +- `Azure CLI <https://github.com/Azure/azure-cli/>`__: The Azure CLI 2.0 is Azure's new command line experience for managing Azure resources. +- `VSTS CLI <https://github.com/Microsoft/vsts-cli>`__: A command-line interface for Visual Studio Team Services (VSTS) and Team Foundation Server (TFS). With the VSTS CLI, you can manage and work with resources including pull requests, work items, builds, and more. +- `Service Fabric CLI <https://github.com/Azure/service-fabric-cli>`__: A command-line interface for interacting with Azure Service Fabric clusters and their related entities. + +Do you use knack in your CLI as well? Open a pull request to include it here. We would love to have it in our list. + + +Release History +=============== + +See `GitHub Releases <https://github.com/Microsoft/knack/releases>`__. + + +Contribute Code +=============== + +This project has adopted the `Microsoft Open Source Code of Conduct <https://opensource.microsoft.com/codeofconduct/>`__. + +For more information see the `Code of Conduct FAQ <https://opensource.microsoft.com/codeofconduct/faq/>`__ or contact `openc...@microsoft.com <mailto:openc...@microsoft.com>`__ with any additional questions or comments. + +If you would like to become an active contributor to this project, please +follow the instructions provided in `Contribution License Agreement <https://cla.microsoft.com/>`__. + + +License +======= + +Knack is licensed under `MIT <LICENSE>`__. + + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/knack-0.8.2/knack/cli.py new/knack-0.9.0/knack/cli.py --- old/knack-0.8.2/knack/cli.py 2021-05-08 08:50:44.000000000 +0200 +++ new/knack-0.9.0/knack/cli.py 2021-11-05 06:18:23.000000000 +0100 @@ -98,7 +98,7 @@ self.only_show_errors = self.config.getboolean('core', 'only_show_errors', fallback=False) self.enable_color = self._should_enable_color() # Init colorama only in Windows legacy terminal - self._should_init_colorama = self.enable_color and os.name == 'nt' and not is_modern_terminal() + self._should_init_colorama = self.enable_color and sys.platform == 'win32' and not is_modern_terminal() @staticmethod def _should_show_version(args): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/knack-0.8.2/knack/commands.py new/knack-0.9.0/knack/commands.py --- old/knack-0.8.2/knack/commands.py 2021-05-08 08:50:44.000000000 +0200 +++ new/knack-0.9.0/knack/commands.py 2021-11-05 06:18:23.000000000 +0100 @@ -180,9 +180,9 @@ self.skip_applicability = False self.excluded_command_handler_args = excluded_command_handler_args # A command table is a dictionary of name -> CLICommand instances - self.command_table = dict() + self.command_table = {} # A command group table is a dictionary of names -> CommandGroup instances - self.command_group_table = dict() + self.command_group_table = {} # An argument registry stores all arguments for commands self.argument_registry = ArgumentRegistry() self.extra_argument_registry = defaultdict(lambda: {}) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/knack-0.8.2/knack/config.py new/knack-0.9.0/knack/config.py --- old/knack-0.8.2/knack/config.py 2021-05-08 08:50:44.000000000 +0200 +++ new/knack-0.9.0/knack/config.py 2021-11-05 06:18:23.000000000 +0100 @@ -10,6 +10,8 @@ _UNSET = object() +CONFIG_FILE_ENCODING = 'utf-8' + def get_config_parser(): return configparser.ConfigParser() # keep this for backward compatibility @@ -190,7 +192,7 @@ self.config_comment = config_comment self.config_parser = configparser.ConfigParser() if os.path.exists(config_path): - self.config_parser.read(config_path) + self.config_parser.read(config_path, encoding=CONFIG_FILE_ENCODING) def items(self, section): return self.config_parser.items(section) if self.config_parser else [] @@ -220,7 +222,7 @@ def set(self, config): ensure_dir(self.config_dir) - with open(self.config_path, 'w') as configfile: + with open(self.config_path, 'w', encoding=CONFIG_FILE_ENCODING) as configfile: if self.config_comment: configfile.write(self.config_comment + '\n') config.write(configfile) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/knack-0.8.2/knack/help.py new/knack-0.9.0/knack/help.py --- old/knack-0.8.2/knack/help.py 2021-05-08 08:50:44.000000000 +0200 +++ new/knack-0.9.0/knack/help.py 2021-11-05 06:18:23.000000000 +0100 @@ -362,7 +362,7 @@ def update_from_data(self, data): if self.name != data.get('name'): - raise HelpAuthoringException(u"mismatched name {} vs. {}" + raise HelpAuthoringException("mismatched name {} vs. {}" .format(self.name, data.get('name'))) @@ -394,7 +394,7 @@ _print_indent('Command' if help_file.type == 'command' else 'Group', indent) indent += 1 - LINE_FORMAT = u'{cli}{name}{separator}{summary}' + LINE_FORMAT = '{cli}{name}{separator}{summary}' line = LINE_FORMAT.format( cli=cli_name, name=' ' + help_file.command if help_file.command else '', @@ -421,7 +421,7 @@ def _print_groups(self, help_file): - LINE_FORMAT = u'{name}{padding}{tags}{separator}{summary}' + LINE_FORMAT = '{name}{padding}{tags}{separator}{summary}' indent = 1 self.max_line_len = 0 @@ -496,13 +496,13 @@ @staticmethod def _get_choices_defaults_sources_str(p): - choice_str = u' Allowed values: {}.'.format(', '.join(sorted([str(x) for x in p.choices]))) \ + choice_str = ' Allowed values: {}.'.format(', '.join(sorted([str(x) for x in p.choices]))) \ if p.choices else '' - default_str = u' Default: {}.'.format(p.default) \ + default_str = ' Default: {}.'.format(p.default) \ if p.default and p.default != argparse.SUPPRESS else '' - value_sources_str = u' Values from: {}.'.format(', '.join(p.value_sources)) \ + value_sources_str = ' Values from: {}.'.format(', '.join(p.value_sources)) \ if p.value_sources else '' - return u'{}{}{}'.format(choice_str, default_str, value_sources_str) + return '{}{}{}'.format(choice_str, default_str, value_sources_str) @staticmethod def print_description_list(help_files): @@ -510,11 +510,11 @@ max_length = max(len(f.name) for f in help_files) if help_files else 0 for help_file in sorted(help_files, key=lambda h: h.name): column_indent = max_length - len(help_file.name) - _print_indent(u'{}{}{}'.format(help_file.name, - ' ' * column_indent, - FIRST_LINE_PREFIX + help_file.short_summary - if help_file.short_summary - else ''), + _print_indent('{}{}{}'.format(help_file.name, + ' ' * column_indent, + FIRST_LINE_PREFIX + help_file.short_summary + if help_file.short_summary + else ''), indent, _get_hanging_indent(max_length, indent)) @@ -524,14 +524,14 @@ _print_indent('Examples', indent) for e in help_file.examples: indent = 1 - _print_indent(u'{0}'.format(e.name), indent) + _print_indent('{0}'.format(e.name), indent) indent = 2 - _print_indent(u'{0}'.format(e.text), indent) + _print_indent('{0}'.format(e.text), indent) print('') def _print_arguments(self, help_file): # pylint: disable=too-many-statements - LINE_FORMAT = u'{name}{padding}{tags}{separator}{short_summary}' + LINE_FORMAT = '{name}{padding}{tags}{separator}{short_summary}' indent = 1 self.max_line_len = 0 @@ -644,9 +644,9 @@ group_registry = ArgumentGroupRegistry([p.group_name for p in help_file.parameters if p.group_name]) def _get_parameter_key(parameter): - return u'{}{}{}'.format(group_registry.get_group_priority(parameter.group_name), - str(not parameter.required), - parameter.name) + return '{}{}{}'.format(group_registry.get_group_priority(parameter.group_name), + str(not parameter.required), + parameter.name) parameter_layouts = _layout_items(help_file.parameters) _print_items(parameter_layouts) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/knack-0.8.2/knack/parser.py new/knack-0.9.0/knack/parser.py --- old/knack-0.8.2/knack/parser.py 2021-05-08 08:50:44.000000000 +0200 +++ new/knack-0.9.0/knack/parser.py 2021-11-05 06:18:23.000000000 +0100 @@ -80,7 +80,8 @@ if args[arg].startswith('@'): try: logger.debug('Attempting to read file %s', args[arg][1:]) - with open(args[arg][1:], 'r') as f: + # Use the default system encoding: https://docs.python.org/3/library/functions.html#open + with open(args[arg][1:], 'r') as f: # pylint: disable=unspecified-encoding content = f.read() args[arg] = content except IOError: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/knack-0.8.2/knack/testsdk/patches.py new/knack-0.9.0/knack/testsdk/patches.py --- old/knack-0.8.2/knack/testsdk/patches.py 2021-05-08 08:50:44.000000000 +0200 +++ new/knack-0.9.0/knack/testsdk/patches.py 2021-11-05 06:18:23.000000000 +0100 @@ -4,10 +4,7 @@ # -------------------------------------------------------------------------------------------- import unittest -try: - import mock -except ImportError: - from unittest import mock +from unittest import mock from .exceptions import CliTestError diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/knack-0.8.2/knack.egg-info/PKG-INFO new/knack-0.9.0/knack.egg-info/PKG-INFO --- old/knack-0.8.2/knack.egg-info/PKG-INFO 2021-05-08 08:50:47.000000000 +0200 +++ new/knack-0.9.0/knack.egg-info/PKG-INFO 2021-11-05 06:18:29.000000000 +0100 @@ -1,162 +1,11 @@ -Metadata-Version: 1.1 +Metadata-Version: 2.1 Name: knack -Version: 0.8.2 +Version: 0.9.0 Summary: A Command-Line Interface framework Home-page: https://github.com/microsoft/knack Author: Microsoft Corporation Author-email: azpy...@microsoft.com License: MIT -Description: Knack - ===== - - .. image:: https://img.shields.io/pypi/v/knack.svg - :target: https://pypi.python.org/pypi/knack - - .. image:: https://img.shields.io/pypi/pyversions/knack.svg - :target: https://pypi.python.org/pypi/knack - - .. image:: https://dev.azure.com/azure-sdk/public/_apis/build/status/cli/microsoft.knack?branchName=dev - :target: https://dev.azure.com/azure-sdk/public/_build/latest?definitionId=1643&branchName=dev - - - ------------ - - - :: - - _ _ - | | ___ __ __ _ ___| | __ - | |/ / '_ \ / _` |/ __| |/ / - | <| | | | (_| | (__| < - |_|\_\_| |_|\__,_|\___|_|\_\ - - - **A Command-Line Interface framework** - - Installation is easy via pip: - - .. code-block:: bash - - pip install knack - - Knack can be installed as a non-privileged user to your home directory by adding "--user" as below: - - .. code-block:: bash - - pip install knack --user - - ------------ - - .. note:: The project is in `initial development phase <https://semver.org/#how-should-i-deal-with-revisions-in-the-0yz-initial-development-phase>`__. We recommend pinning to at least a specific minor version when marking **knack** as a dependency in your project. - - ------------ - - - Usage - ===== - - - .. code-block:: python - - import sys - from collections import OrderedDict - - from knack import CLI, ArgumentsContext, CLICommandsLoader - from knack.commands import CommandGroup - - - def abc_str(length=3): - import string - return string.ascii_lowercase[:length] - - - class MyCommandsLoader(CLICommandsLoader): - def load_command_table(self, args): - with CommandGroup(self, 'abc', '__main__#{}') as g: - g.command('str', 'abc_str') - return OrderedDict(self.command_table) - - def load_arguments(self, command): - with ArgumentsContext(self, 'abc str') as ac: - ac.argument('length', type=int) - super(MyCommandsLoader, self).load_arguments(command) - - - mycli = CLI(cli_name='mycli', commands_loader_cls=MyCommandsLoader) - exit_code = mycli.invoke(sys.argv[1:]) - sys.exit(exit_code) - - # $ python mycli.py abc str - # "abc" - - # $ python mycli.py abc str --length 5 - # "abcde" - - # $ python mycli.py abc str --length 100 - # "abcdefghijklmnopqrstuvwxyz" - - - More samples and snippets are available at `examples <https://github.com/Microsoft/knack/tree/dev/examples>`__. - - - Documentation - ============= - - Documentation is available at `docs <https://github.com/Microsoft/knack/tree/dev/docs>`__. - - Developer Setup - =============== - - In a virtual environment, install the `requirements.txt` file. - - .. code-block:: bash - - pip install -r requirements.txt - pip install -e . - - Run Automation - ============== - - This project supports running automation using `tox <https://tox.readthedocs.io/en/latest/>`__. - - .. code-block:: bash - - pip install tox - tox - - - Real-world uses - =============== - - - `Azure CLI <https://github.com/Azure/azure-cli/>`__: The Azure CLI 2.0 is Azure's new command line experience for managing Azure resources. - - `VSTS CLI <https://github.com/Microsoft/vsts-cli>`__: A command-line interface for Visual Studio Team Services (VSTS) and Team Foundation Server (TFS). With the VSTS CLI, you can manage and work with resources including pull requests, work items, builds, and more. - - `Service Fabric CLI <https://github.com/Azure/service-fabric-cli>`__: A command-line interface for interacting with Azure Service Fabric clusters and their related entities. - - Do you use knack in your CLI as well? Open a pull request to include it here. We would love to have it in our list. - - - Release History - =============== - - See `GitHub Releases <https://github.com/Microsoft/knack/releases>`__. - - - Contribute Code - =============== - - This project has adopted the `Microsoft Open Source Code of Conduct <https://opensource.microsoft.com/codeofconduct/>`__. - - For more information see the `Code of Conduct FAQ <https://opensource.microsoft.com/codeofconduct/faq/>`__ or contact `openc...@microsoft.com <mailto:openc...@microsoft.com>`__ with any additional questions or comments. - - If you would like to become an active contributor to this project, please - follow the instructions provided in `Contribution License Agreement <https://cla.microsoft.com/>`__. - - - License - ======= - - Knack is licensed under `MIT <LICENSE>`__. - Platform: UNKNOWN Classifier: Development Status :: 4 - Beta Classifier: Intended Audience :: Developers @@ -167,4 +16,159 @@ Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: 3.9 +Classifier: Programming Language :: Python :: 3.10 Classifier: License :: OSI Approved :: MIT License +License-File: LICENSE + +Knack +===== + +.. image:: https://img.shields.io/pypi/v/knack.svg + :target: https://pypi.python.org/pypi/knack + +.. image:: https://img.shields.io/pypi/pyversions/knack.svg + :target: https://pypi.python.org/pypi/knack + +.. image:: https://dev.azure.com/azure-sdk/public/_apis/build/status/cli/microsoft.knack?branchName=dev + :target: https://dev.azure.com/azure-sdk/public/_build/latest?definitionId=1643&branchName=dev + + +------------ + + +:: + + _ _ + | | ___ __ __ _ ___| | __ + | |/ / '_ \ / _` |/ __| |/ / + | <| | | | (_| | (__| < + |_|\_\_| |_|\__,_|\___|_|\_\ + + +**A Command-Line Interface framework** + +Installation is easy via pip: + +.. code-block:: bash + + pip install knack + +Knack can be installed as a non-privileged user to your home directory by adding "--user" as below: + +.. code-block:: bash + + pip install knack --user + +------------ + +.. note:: The project is in `initial development phase <https://semver.org/#how-should-i-deal-with-revisions-in-the-0yz-initial-development-phase>`__. We recommend pinning to at least a specific minor version when marking **knack** as a dependency in your project. + +------------ + + +Usage +===== + + +.. code-block:: python + + import sys + from collections import OrderedDict + + from knack import CLI, ArgumentsContext, CLICommandsLoader + from knack.commands import CommandGroup + + + def abc_str(length=3): + import string + return string.ascii_lowercase[:length] + + + class MyCommandsLoader(CLICommandsLoader): + def load_command_table(self, args): + with CommandGroup(self, 'abc', '__main__#{}') as g: + g.command('str', 'abc_str') + return OrderedDict(self.command_table) + + def load_arguments(self, command): + with ArgumentsContext(self, 'abc str') as ac: + ac.argument('length', type=int) + super(MyCommandsLoader, self).load_arguments(command) + + + mycli = CLI(cli_name='mycli', commands_loader_cls=MyCommandsLoader) + exit_code = mycli.invoke(sys.argv[1:]) + sys.exit(exit_code) + + # $ python mycli.py abc str + # "abc" + + # $ python mycli.py abc str --length 5 + # "abcde" + + # $ python mycli.py abc str --length 100 + # "abcdefghijklmnopqrstuvwxyz" + + +More samples and snippets are available at `examples <https://github.com/Microsoft/knack/tree/dev/examples>`__. + + +Documentation +============= + +Documentation is available at `docs <https://github.com/Microsoft/knack/tree/dev/docs>`__. + +Developer Setup +=============== + +In a virtual environment, install the `requirements.txt` file. + +.. code-block:: bash + + pip install -r requirements.txt + pip install -e . + +Run Automation +============== + +This project supports running automation using `tox <https://tox.readthedocs.io/en/latest/>`__. + +.. code-block:: bash + + pip install tox + tox + + +Real-world uses +=============== + +- `Azure CLI <https://github.com/Azure/azure-cli/>`__: The Azure CLI 2.0 is Azure's new command line experience for managing Azure resources. +- `VSTS CLI <https://github.com/Microsoft/vsts-cli>`__: A command-line interface for Visual Studio Team Services (VSTS) and Team Foundation Server (TFS). With the VSTS CLI, you can manage and work with resources including pull requests, work items, builds, and more. +- `Service Fabric CLI <https://github.com/Azure/service-fabric-cli>`__: A command-line interface for interacting with Azure Service Fabric clusters and their related entities. + +Do you use knack in your CLI as well? Open a pull request to include it here. We would love to have it in our list. + + +Release History +=============== + +See `GitHub Releases <https://github.com/Microsoft/knack/releases>`__. + + +Contribute Code +=============== + +This project has adopted the `Microsoft Open Source Code of Conduct <https://opensource.microsoft.com/codeofconduct/>`__. + +For more information see the `Code of Conduct FAQ <https://opensource.microsoft.com/codeofconduct/faq/>`__ or contact `openc...@microsoft.com <mailto:openc...@microsoft.com>`__ with any additional questions or comments. + +If you would like to become an active contributor to this project, please +follow the instructions provided in `Contribution License Agreement <https://cla.microsoft.com/>`__. + + +License +======= + +Knack is licensed under `MIT <LICENSE>`__. + + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/knack-0.8.2/knack.egg-info/requires.txt new/knack-0.9.0/knack.egg-info/requires.txt --- old/knack-0.8.2/knack.egg-info/requires.txt 2021-05-08 08:50:47.000000000 +0200 +++ new/knack-0.9.0/knack.egg-info/requires.txt 2021-11-05 06:18:29.000000000 +0100 @@ -1,5 +1,4 @@ argcomplete -colorama jmespath pygments pyyaml diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/knack-0.8.2/setup.py new/knack-0.9.0/setup.py --- old/knack-0.8.2/setup.py 2021-05-08 08:50:44.000000000 +0200 +++ new/knack-0.9.0/setup.py 2021-11-05 06:18:23.000000000 +0100 @@ -5,21 +5,24 @@ # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- -from codecs import open -from setuptools import setup, find_packages +import sys +from setuptools import setup -VERSION = '0.8.2' +VERSION = '0.9.0' DEPENDENCIES = [ 'argcomplete', - 'colorama', 'jmespath', 'pygments', 'pyyaml', 'tabulate' ] -with open('README.rst', 'r', encoding='utf-8') as f: +# On Windows, colorama is required for legacy terminals. +if sys.platform == 'win32': + DEPENDENCIES.append('colorama') + +with open('README.rst', 'r') as f: README = f.read() setup( @@ -42,6 +45,7 @@ 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', 'License :: OSI Approved :: MIT License', ], packages=['knack', 'knack.testsdk'], diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/knack-0.8.2/tests/test_cli_scenarios.py new/knack-0.9.0/tests/test_cli_scenarios.py --- old/knack-0.8.2/tests/test_cli_scenarios.py 2021-05-08 08:50:44.000000000 +0200 +++ new/knack-0.9.0/tests/test_cli_scenarios.py 2021-11-05 06:18:23.000000000 +0100 @@ -6,11 +6,7 @@ import os from collections import OrderedDict import unittest -try: - import mock -except ImportError: - from unittest import mock -import mock +from unittest import mock from io import StringIO diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/knack-0.8.2/tests/test_command_with_configured_defaults.py new/knack-0.9.0/tests/test_command_with_configured_defaults.py --- old/knack-0.8.2/tests/test_command_with_configured_defaults.py 2021-05-08 08:50:44.000000000 +0200 +++ new/knack-0.9.0/tests/test_command_with_configured_defaults.py 2021-11-05 06:18:23.000000000 +0100 @@ -6,10 +6,7 @@ import logging import sys import unittest -try: - import mock -except ImportError: - from unittest import mock +from unittest import mock from knack.arguments import ArgumentsContext from knack.commands import CLICommandsLoader, CommandGroup diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/knack-0.8.2/tests/test_completion.py new/knack-0.9.0/tests/test_completion.py --- old/knack-0.8.2/tests/test_completion.py 2021-05-08 08:50:44.000000000 +0200 +++ new/knack-0.9.0/tests/test_completion.py 2021-11-05 06:18:23.000000000 +0100 @@ -5,10 +5,7 @@ import os import unittest -try: - import mock -except ImportError: - from unittest import mock +from unittest import mock from knack.completion import CLICompletion, CaseInsensitiveChoicesCompleter, ARGCOMPLETE_ENV_NAME from tests.util import MockContext diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/knack-0.8.2/tests/test_config.py new/knack-0.9.0/tests/test_config.py --- old/knack-0.8.2/tests/test_config.py 2021-05-08 08:50:44.000000000 +0200 +++ new/knack-0.9.0/tests/test_config.py 2021-11-05 06:18:23.000000000 +0100 @@ -7,10 +7,7 @@ import stat import unittest import shutil -try: - import mock -except ImportError: - from unittest import mock +from unittest import mock import configparser from knack.config import CLIConfig diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/knack-0.8.2/tests/test_deprecation.py new/knack-0.9.0/tests/test_deprecation.py --- old/knack-0.8.2/tests/test_deprecation.py 2021-05-08 08:50:44.000000000 +0200 +++ new/knack-0.9.0/tests/test_deprecation.py 2021-11-05 06:18:23.000000000 +0100 @@ -4,10 +4,7 @@ # -------------------------------------------------------------------------------------------- import unittest -try: - import mock -except ImportError: - from unittest import mock +from unittest import mock from knack.arguments import ArgumentsContext from knack.commands import CLICommandsLoader, CommandGroup @@ -66,7 +63,7 @@ with self.assertRaises(SystemExit): self.cli_ctx.invoke('-h'.split()) actual = self.io.getvalue() - expected = u""" + expected = """ Group {} @@ -432,7 +429,7 @@ """ Ensure non-expired options can be used without warning. """ self.cli_ctx.invoke('arg-test --arg1 foo --opt1 bar --opt5 foo'.split()) actual = self.io.getvalue() - self.assertTrue(u'--alt5' not in actual and u'--opt5' not in actual) + self.assertTrue('--alt5' not in actual and '--opt5' not in actual) @redirect_io def test_deprecate_options_execute_expiring(self): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/knack-0.8.2/tests/test_experimental.py new/knack-0.9.0/tests/test_experimental.py --- old/knack-0.8.2/tests/test_experimental.py 2021-05-08 08:50:44.000000000 +0200 +++ new/knack-0.9.0/tests/test_experimental.py 2021-11-05 06:18:23.000000000 +0100 @@ -4,10 +4,7 @@ # -------------------------------------------------------------------------------------------- import unittest -try: - import mock -except ImportError: - from unittest import mock +from unittest import mock import sys import argparse @@ -72,7 +69,7 @@ with self.assertRaises(SystemExit): self.cli_ctx.invoke('-h'.split()) actual = self.io.getvalue() - expected = u""" + expected = """ Group {} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/knack-0.8.2/tests/test_help.py new/knack-0.9.0/tests/test_help.py --- old/knack-0.8.2/tests/test_help.py 2021-05-08 08:50:44.000000000 +0200 +++ new/knack-0.9.0/tests/test_help.py 2021-11-05 06:18:23.000000000 +0100 @@ -5,8 +5,8 @@ import sys import unittest +from unittest import mock -import mock from knack.arguments import ArgumentsContext from knack.commands import CLICommandsLoader, CommandGroup from knack.events import EVENT_PARSER_GLOBAL_CREATE diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/knack-0.8.2/tests/test_log.py new/knack-0.9.0/tests/test_log.py --- old/knack-0.8.2/tests/test_log.py 2021-05-08 08:50:44.000000000 +0200 +++ new/knack-0.9.0/tests/test_log.py 2021-11-05 06:18:23.000000000 +0100 @@ -4,10 +4,7 @@ # -------------------------------------------------------------------------------------------- import unittest -try: - import mock -except ImportError: - from unittest import mock +from unittest import mock import logging from knack.events import EVENT_PARSER_GLOBAL_CREATE, EVENT_INVOKER_PRE_CMD_TBL_CREATE diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/knack-0.8.2/tests/test_output.py new/knack-0.9.0/tests/test_output.py --- old/knack-0.8.2/tests/test_output.py 2021-05-08 08:50:44.000000000 +0200 +++ new/knack-0.9.0/tests/test_output.py 2021-11-05 06:18:23.000000000 +0100 @@ -7,7 +7,7 @@ # -------------------------------------------------------------------------------------------- import unittest -import mock +from unittest import mock from collections import OrderedDict from io import StringIO diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/knack-0.8.2/tests/test_preview.py new/knack-0.9.0/tests/test_preview.py --- old/knack-0.8.2/tests/test_preview.py 2021-05-08 08:50:44.000000000 +0200 +++ new/knack-0.9.0/tests/test_preview.py 2021-11-05 06:18:23.000000000 +0100 @@ -4,10 +4,7 @@ # -------------------------------------------------------------------------------------------- import unittest -try: - import mock -except ImportError: - from unittest import mock +from unittest import mock import sys import argparse @@ -64,7 +61,7 @@ with self.assertRaises(SystemExit): self.cli_ctx.invoke('-h'.split()) actual = self.io.getvalue() - expected = u""" + expected = """ Group {} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/knack-0.8.2/tests/test_prompting.py new/knack-0.9.0/tests/test_prompting.py --- old/knack-0.8.2/tests/test_prompting.py 2021-05-08 08:50:44.000000000 +0200 +++ new/knack-0.9.0/tests/test_prompting.py 2021-11-05 06:18:23.000000000 +0100 @@ -5,10 +5,7 @@ import sys import unittest -try: - import mock -except ImportError: - from unittest import mock +from unittest import mock from io import StringIO from knack.prompting import (verify_is_a_tty, NoTTYException, _INVALID_PASSWORD_MSG, prompt, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/knack-0.8.2/tests/test_query.py new/knack-0.9.0/tests/test_query.py --- old/knack-0.8.2/tests/test_query.py 2021-05-08 08:50:44.000000000 +0200 +++ new/knack-0.9.0/tests/test_query.py 2021-11-05 06:18:23.000000000 +0100 @@ -4,7 +4,7 @@ # -------------------------------------------------------------------------------------------- import unittest -import mock +from unittest import mock from knack.events import EVENT_PARSER_GLOBAL_CREATE from knack.query import CLIQuery diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/knack-0.8.2/tests/util.py new/knack-0.9.0/tests/util.py --- old/knack-0.8.2/tests/util.py 2021-05-08 08:50:44.000000000 +0200 +++ new/knack-0.9.0/tests/util.py 2021-11-05 06:18:23.000000000 +0100 @@ -3,10 +3,7 @@ # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- -try: - import mock -except ImportError: - from unittest import mock +from unittest import mock import logging import os import re