Hello community, here is the log from the commit of package python-knack for openSUSE:Factory checked in at 2020-06-19 17:23:40 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-knack (Old) and /work/SRC/openSUSE:Factory/.python-knack.new.3606 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-knack" Fri Jun 19 17:23:40 2020 rev:12 rq:815749 version:0.7.1 Changes: -------- --- /work/SRC/openSUSE:Factory/python-knack/python-knack.changes 2020-05-08 23:06:31.670006408 +0200 +++ /work/SRC/openSUSE:Factory/.python-knack.new.3606/python-knack.changes 2020-06-19 17:24:22.372065871 +0200 @@ -1,0 +2,13 @@ +Tue Jun 16 12:19:05 UTC 2020 - John Paul Adrian Glaubitz <[email protected]> + +- Update to version 0.7.1 + * Rollback `get_config_parser` in `config.py` (#205) +- from version 0.7.0 + * Add a `default_value_source` property in `HelpParameter` (#202) + * Support removing option/section from config file (#201) + * Support writing comment to config file (#201) + * Import `configparser` directly instead of from `six` (#201) + * Drop `get_config_parser` function from `config.py` (#201) +- Remove workaround for version number in spec file + +------------------------------------------------------------------- Old: ---- knack-0.7.0rc4.tar.gz New: ---- knack-0.7.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-knack.spec ++++++ --- /var/tmp/diff_new_pack.dflMGr/_old 2020-06-19 17:24:24.500071953 +0200 +++ /var/tmp/diff_new_pack.dflMGr/_new 2020-06-19 17:24:24.500071953 +0200 @@ -18,15 +18,14 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} %define skip_python2 1 -%define realver 0.7.0rc4 Name: python-knack -Version: 0.7.0~rc4 +Version: 0.7.1 Release: 0 Summary: A Command-Line Interface framework License: MIT Group: Development/Languages/Python URL: https://github.com/microsoft/knack -Source: https://files.pythonhosted.org/packages/source/k/knack/knack-%{realver}.tar.gz +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} @@ -54,7 +53,7 @@ A Command-Line Interface framework %prep -%setup -q -n knack-%{realver} +%setup -q -n knack-%{version} %build %python_build ++++++ knack-0.7.0rc4.tar.gz -> knack-0.7.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/knack-0.7.0rc4/HISTORY.rst new/knack-0.7.1/HISTORY.rst --- old/knack-0.7.0rc4/HISTORY.rst 2020-04-22 04:41:45.000000000 +0200 +++ new/knack-0.7.1/HISTORY.rst 2020-05-09 05:30:08.000000000 +0200 @@ -3,6 +3,18 @@ Release History =============== +0.7.1 +++++++++ +* Rollback `get_config_parser` in `config.py` (#205) + +0.7.0 +++++++++ +* Add a `default_value_source` property in `HelpParameter` (#202) +* Support removing option/section from config file (#201) +* Support writing comment to config file (#201) +* Import `configparser` directly instead of from `six` (#201) +* Drop `get_config_parser` function from `config.py` (#201) + 0.7.0rc4 ++++++++ * Change the timing to raise `EVENT_CLI_POST_EXECUTE` event (#199) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/knack-0.7.0rc4/PKG-INFO new/knack-0.7.1/PKG-INFO --- old/knack-0.7.0rc4/PKG-INFO 2020-04-22 04:41:54.000000000 +0200 +++ new/knack-0.7.1/PKG-INFO 2020-05-09 05:30:13.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: knack -Version: 0.7.0rc4 +Version: 0.7.1 Summary: A Command-Line Interface framework Home-page: https://github.com/microsoft/knack Author: Microsoft Corporation diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/knack-0.7.0rc4/knack/arguments.py new/knack-0.7.1/knack/arguments.py --- old/knack-0.7.0rc4/knack/arguments.py 2020-04-22 04:41:45.000000000 +0200 +++ new/knack-0.7.1/knack/arguments.py 2020-05-09 05:30:08.000000000 +0200 @@ -45,7 +45,7 @@ class CLICommandArgument(object): NAMED_ARGUMENTS = ['options_list', 'validator', 'completer', 'arg_group', 'deprecate_info', 'preview_info', - 'experimental_info'] + 'experimental_info', 'default_value_source'] def __init__(self, dest=None, argtype=None, **kwargs): """An argument that has a specific destination parameter. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/knack-0.7.0rc4/knack/commands.py new/knack-0.7.1/knack/commands.py --- old/knack-0.7.0rc4/knack/commands.py 2020-04-22 04:41:45.000000000 +0200 +++ new/knack-0.7.1/knack/commands.py 2020-05-09 05:30:08.000000000 +0200 @@ -99,6 +99,7 @@ logger.info("Configured default '%s' for arg %s", config_value, arg.name) overrides.settings['default'] = DefaultStr(config_value) overrides.settings['required'] = False + overrides.settings['default_value_source'] = 'Config' def load_arguments(self): if self.arguments_loader: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/knack-0.7.0rc4/knack/config.py new/knack-0.7.1/knack/config.py --- old/knack-0.7.0rc4/knack/config.py 2020-04-22 04:41:45.000000000 +0200 +++ new/knack-0.7.1/knack/config.py 2020-05-09 05:30:08.000000000 +0200 @@ -3,9 +3,8 @@ # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- import os -import sys import stat -from six.moves import configparser +import configparser from .util import ensure_dir @@ -13,7 +12,7 @@ def get_config_parser(): - return configparser.ConfigParser() if sys.version_info.major == 3 else configparser.SafeConfigParser() + return configparser.ConfigParser() # keep this for backward compatibility class CLIConfig(object): @@ -141,15 +140,34 @@ def set_to_use_local_config(self, use_local_config): self.use_local_config = use_local_config + def remove_option(self, section, option): + for config in self._config_file_chain if self.use_local_config else self._config_file_chain[-1:]: + if config.remove_option(section, option): + return True + return False + class _ConfigFile(object): _BOOLEAN_STATES = {'1': True, 'yes': True, 'true': True, 'on': True, '0': False, 'no': False, 'false': False, 'off': False} - def __init__(self, config_dir, config_path): + def __init__(self, config_dir, config_path, config_comment=None): + """ Manage configuration options available in the CLI + + :param config_dir: The directory to store the config file + :type config_dir: str + :param config_path: The path of the config file + :type config_path: str + :param config_comment: The comment which will be written into the head of the config file + :type config_comment: str + + When 'config_comment' is given, each line should start with # or ;. For details about INI file comment, + see https://docs.python.org/3/library/configparser.html#supported-ini-file-structure + """ self.config_dir = config_dir self.config_path = config_path - self.config_parser = get_config_parser() + self.config_comment = config_comment + self.config_parser = configparser.ConfigParser() if os.path.exists(config_path): self.config_parser.read(config_path) @@ -179,12 +197,14 @@ def set(self, config): ensure_dir(self.config_dir) with open(self.config_path, 'w') as configfile: + if self.config_comment: + configfile.write(self.config_comment + '\n') config.write(configfile) os.chmod(self.config_path, stat.S_IRUSR | stat.S_IWUSR) self.config_parser.read(self.config_path) def set_value(self, section, option, value): - config = get_config_parser() + config = configparser.ConfigParser() config.read(self.config_path) try: config.add_section(section) @@ -192,3 +212,28 @@ pass config.set(section, option, value) self.set(config) + + def remove_option(self, section, option): + existed = False + if self.config_parser: + try: + existed = self.config_parser.remove_option(section, option) + self.set(self.config_parser) + except configparser.NoSectionError: + pass + return existed + + def remove_section(self, section): + if self.config_parser and self.config_parser.remove_section(section): + self.set(self.config_parser) + return True + return False + + def clear(self): + if self.config_parser: + for section in self.config_parser.sections(): + self.config_parser.remove_section(section) + self.set(self.config_parser) + + def sections(self): + return self.config_parser.sections() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/knack-0.7.0rc4/knack/help.py new/knack-0.7.1/knack/help.py --- old/knack-0.7.0rc4/knack/help.py 2020-04-22 04:41:45.000000000 +0200 +++ new/knack-0.7.1/knack/help.py 2020-05-09 05:30:08.000000000 +0200 @@ -319,7 +319,8 @@ 'name_source': normal_options, 'deprecate_info': getattr(param, 'deprecate_info', None), 'preview_info': getattr(param, 'preview_info', None), - 'experimental_info': getattr(param, 'experimental_info', None) + 'experimental_info': getattr(param, 'experimental_info', None), + 'default_value_source': getattr(param, 'default_value_source', None) }) self.parameters.append(HelpParameter(**param_kwargs)) @@ -342,8 +343,8 @@ class HelpParameter(HelpObject): # pylint: disable=too-many-instance-attributes - def __init__(self, name_source, description, required, choices=None, - default=None, group_name=None, deprecate_info=None, preview_info=None, experimental_info=None): + def __init__(self, name_source, description, required, choices=None, default=None, group_name=None, + deprecate_info=None, preview_info=None, experimental_info=None, default_value_source=None): super(HelpParameter, self).__init__() self.name_source = name_source self.name = ' '.join(sorted(name_source)) @@ -358,6 +359,7 @@ self.deprecate_info = deprecate_info self.preview_info = preview_info self.experimental_info = experimental_info + self.default_value_source = default_value_source def update_from_data(self, data): if self.name != data.get('name'): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/knack-0.7.0rc4/knack/log.py new/knack-0.7.1/knack/log.py --- old/knack-0.7.0rc4/knack/log.py 2020-04-22 04:41:45.000000000 +0200 +++ new/knack-0.7.1/knack/log.py 2020-05-09 05:30:08.000000000 +0200 @@ -5,7 +5,6 @@ import os import logging -from logging.handlers import RotatingFileHandler from .util import CtxTypeError, ensure_dir, CLIError from .events import EVENT_PARSER_GLOBAL_CREATE @@ -159,6 +158,7 @@ def _init_logfile_handlers(self, root_logger, cli_logger): ensure_dir(self.log_dir) log_file_path = os.path.join(self.log_dir, self.logfile_name) + from logging.handlers import RotatingFileHandler logfile_handler = RotatingFileHandler(log_file_path, maxBytes=10 * 1024 * 1024, backupCount=5) lfmt = logging.Formatter('%(process)d : %(asctime)s : %(levelname)s : %(name)s : %(message)s') logfile_handler.setFormatter(lfmt) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/knack-0.7.0rc4/knack/output.py new/knack-0.7.1/knack/output.py --- old/knack-0.7.0rc4/knack/output.py 2020-04-22 04:41:45.000000000 +0200 +++ new/knack-0.7.1/knack/output.py 2020-05-09 05:30:08.000000000 +0200 @@ -11,7 +11,6 @@ import sys from collections import OrderedDict from six import StringIO, text_type, u, string_types -import yaml from .util import CLIError, CommandResultItem, CtxTypeError from .events import EVENT_INVOKER_POST_PARSE_ARGS, EVENT_PARSER_GLOBAL_CREATE @@ -48,6 +47,7 @@ def format_yaml(obj): + import yaml try: return yaml.safe_dump(obj.result, default_flow_style=False, allow_unicode=True) except yaml.representer.RepresenterError: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/knack-0.7.0rc4/knack/parser.py new/knack-0.7.1/knack/parser.py --- old/knack-0.7.0rc4/knack/parser.py 2020-04-22 04:41:45.000000000 +0200 +++ new/knack-0.7.1/knack/parser.py 2020-05-09 05:30:08.000000000 +0200 @@ -27,7 +27,8 @@ 'required', 'help', 'metavar', - 'action' + 'action', + 'default_value_source' ] @@ -174,6 +175,7 @@ param.deprecate_info = arg.deprecate_info param.preview_info = arg.preview_info param.experimental_info = arg.experimental_info + param.default_value_source = arg.default_value_source command_parser.set_defaults( func=metadata, command=command_name, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/knack-0.7.0rc4/knack.egg-info/PKG-INFO new/knack-0.7.1/knack.egg-info/PKG-INFO --- old/knack-0.7.0rc4/knack.egg-info/PKG-INFO 2020-04-22 04:41:54.000000000 +0200 +++ new/knack-0.7.1/knack.egg-info/PKG-INFO 2020-05-09 05:30:13.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: knack -Version: 0.7.0rc4 +Version: 0.7.1 Summary: A Command-Line Interface framework Home-page: https://github.com/microsoft/knack Author: Microsoft Corporation diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/knack-0.7.0rc4/setup.py new/knack-0.7.1/setup.py --- old/knack-0.7.0rc4/setup.py 2020-04-22 04:41:45.000000000 +0200 +++ new/knack-0.7.1/setup.py 2020-05-09 05:30:08.000000000 +0200 @@ -9,7 +9,7 @@ from codecs import open from setuptools import setup, find_packages -VERSION = '0.7.0rc4' +VERSION = '0.7.1' DEPENDENCIES = [ 'argcomplete', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/knack-0.7.0rc4/tests/test_config.py new/knack-0.7.1/tests/test_config.py --- old/knack-0.7.0rc4/tests/test_config.py 2020-04-22 04:41:45.000000000 +0200 +++ new/knack-0.7.1/tests/test_config.py 2020-05-09 05:30:08.000000000 +0200 @@ -11,9 +11,9 @@ import mock except ImportError: from unittest import mock -from six.moves import configparser +import configparser -from knack.config import CLIConfig, get_config_parser +from knack.config import CLIConfig from .util import TEMP_FOLDER_NAME, new_temp_folder @@ -171,7 +171,7 @@ def test_set_config_value(self): self.cli_config.set_value('test_section', 'test_option', 'a_value') - config = get_config_parser() + config = configparser.ConfigParser() config.read(self.cli_config.config_path) self.assertEqual(config.get('test_section', 'test_option'), 'a_value')
