Hello community, here is the log from the commit of package python-configargparse for openSUSE:Factory checked in at 2020-06-02 14:39:46 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-configargparse (Old) and /work/SRC/openSUSE:Factory/.python-configargparse.new.3606 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-configargparse" Tue Jun 2 14:39:46 2020 rev:9 rq:810601 version:1.2.3 Changes: -------- --- /work/SRC/openSUSE:Factory/python-configargparse/python-configargparse.changes 2020-04-23 18:37:30.280898932 +0200 +++ /work/SRC/openSUSE:Factory/.python-configargparse.new.3606/python-configargparse.changes 2020-06-02 14:40:26.899864535 +0200 @@ -1,0 +2,9 @@ +Mon Jun 1 11:01:45 UTC 2020 - pgaj...@suse.com + +- version update to 1.2.3 + * Fixes #179 + * allow use of nargs with action=append (#177) + * Merged ConfigparserConfigFileParser - PR #173 - which adds support + for python's Configparser config file format + +------------------------------------------------------------------- Old: ---- ConfigArgParse-1.0.tar.gz New: ---- ConfigArgParse-1.2.3.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-configargparse.spec ++++++ --- /var/tmp/diff_new_pack.nmcfKP/_old 2020-06-02 14:40:27.559866621 +0200 +++ /var/tmp/diff_new_pack.nmcfKP/_new 2020-06-02 14:40:27.563866634 +0200 @@ -19,7 +19,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} %bcond_without python2 Name: python-configargparse -Version: 1.0 +Version: 1.2.3 Release: 0 Summary: A drop-in replacement for argparse License: MIT ++++++ ConfigArgParse-1.0.tar.gz -> ConfigArgParse-1.2.3.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ConfigArgParse-1.0/ConfigArgParse.egg-info/PKG-INFO new/ConfigArgParse-1.2.3/ConfigArgParse.egg-info/PKG-INFO --- old/ConfigArgParse-1.0/ConfigArgParse.egg-info/PKG-INFO 2019-12-30 06:16:29.000000000 +0100 +++ new/ConfigArgParse-1.2.3/ConfigArgParse.egg-info/PKG-INFO 2020-04-24 05:43:41.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: ConfigArgParse -Version: 1.0 +Version: 1.2.3 Summary: A drop-in replacement for argparse that allows options to also be set via config files and/or environment variables. Home-page: https://github.com/bw2/ConfigArgParse License: MIT @@ -168,11 +168,12 @@ ~~~~~~~~~~~~~~~~~~ Only command line args that have a long version (eg. one that starts with '--') - can be set in a config file. For example, "--color" can be set by - putting "color=green" in a config file. The config file syntax depends on the - constuctor arg: :code:`config_file_parser_class` which can be set to one of the - provided classes: :code:`DefaultConfigFileParser` or :code:`YAMLConfigFileParser`, - or to your own subclass of the :code:`ConfigFileParser` abstract class. + can be set in a config file. For example, "--color" can be set by putting + "color=green" in a config file. The config file syntax depends on the constuctor + arg: :code:`config_file_parser_class` which can be set to one of the provided + classes: :code:`DefaultConfigFileParser`, :code:`YAMLConfigFileParser`, + :code:`ConfigparserConfigFileParser` or to your own subclass of the + :code:`ConfigFileParser` abstract class. *DefaultConfigFileParser* - the full range of valid syntax is: @@ -211,6 +212,57 @@ fruit: [apple, orange, lemon] indexes: [1, 12, 35, 40] + *ConfigparserConfigFileParser* - allows a subset of python's configparser + module syntax (https://docs.python.org/3.7/library/configparser.html). In + particular the following configparser options are set: + + .. code:: py + + config = configparser.ConfigParser( + delimiters=("=",":"), + allow_no_value=False, + comment_prefixes=("#",";"), + inline_comment_prefixes=("#",";"), + strict=True, + empty_lines_in_values=False, + ) + + Once configparser parses the config file all section names are removed, thus all + keys must have unique names regardless of which INI section they are defined + under. Also, any keys which have python list syntax are converted to lists by + evaluating them as python code using ast.literal_eval + (https://docs.python.org/3/library/ast.html#ast.literal_eval). To facilitate + this all multi-line values are converted to single-line values. Thus multi-line + string values will have all new-lines converted to spaces. Note, since key-value + pairs that have python dictionary syntax are saved as single-line strings, even + if formatted across multiple lines in the config file, dictionaries can be read + in and converted to valid python dictionaries with PyYAML's safe_load. Example + given below: + + .. code:: py + + # inside your config file (e.g. config.ini) + [section1] # INI sections treated as comments + system1_settings: { # start of multi-line dictionary + 'a':True, + 'b':[2, 4, 8, 16], + 'c':{'start':0, 'stop':1000}, + 'd':'experiment 32 testing simulation with parameter a on' + } # end of multi-line dictionary value + + ....... + + # in your configargparse setup + import configargparse + import yaml + + parser = configargparse.ConfigParser( + config_file_parser_class=configargparse.ConfigparserConfigFileParser + ) + parser.add_argument('--system1_settings', type=yaml.safe_load) + + args = parser.parse_args() # now args.system1 is a valid python dict + ArgParser Singletons ~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -412,6 +464,14 @@ .. |Travis CI Status for bw2/ConfigArgParse| image:: https://travis-ci.org/bw2/ConfigArgParse.svg?branch=master + + Versioning + ~~~~~~~~~~ + + This software follows `Semantic Versioning`_ + + .. _Semantic Versioning: http://semver.org/ + Keywords: options,argparse,ConfigArgParse,config,environment variables,envvars,ENV,environment,optparse,YAML,INI Platform: UNKNOWN Classifier: Development Status :: 4 - Beta @@ -424,6 +484,7 @@ Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 +Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.* diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ConfigArgParse-1.0/PKG-INFO new/ConfigArgParse-1.2.3/PKG-INFO --- old/ConfigArgParse-1.0/PKG-INFO 2019-12-30 06:16:29.000000000 +0100 +++ new/ConfigArgParse-1.2.3/PKG-INFO 2020-04-24 05:43:41.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: ConfigArgParse -Version: 1.0 +Version: 1.2.3 Summary: A drop-in replacement for argparse that allows options to also be set via config files and/or environment variables. Home-page: https://github.com/bw2/ConfigArgParse License: MIT @@ -168,11 +168,12 @@ ~~~~~~~~~~~~~~~~~~ Only command line args that have a long version (eg. one that starts with '--') - can be set in a config file. For example, "--color" can be set by - putting "color=green" in a config file. The config file syntax depends on the - constuctor arg: :code:`config_file_parser_class` which can be set to one of the - provided classes: :code:`DefaultConfigFileParser` or :code:`YAMLConfigFileParser`, - or to your own subclass of the :code:`ConfigFileParser` abstract class. + can be set in a config file. For example, "--color" can be set by putting + "color=green" in a config file. The config file syntax depends on the constuctor + arg: :code:`config_file_parser_class` which can be set to one of the provided + classes: :code:`DefaultConfigFileParser`, :code:`YAMLConfigFileParser`, + :code:`ConfigparserConfigFileParser` or to your own subclass of the + :code:`ConfigFileParser` abstract class. *DefaultConfigFileParser* - the full range of valid syntax is: @@ -211,6 +212,57 @@ fruit: [apple, orange, lemon] indexes: [1, 12, 35, 40] + *ConfigparserConfigFileParser* - allows a subset of python's configparser + module syntax (https://docs.python.org/3.7/library/configparser.html). In + particular the following configparser options are set: + + .. code:: py + + config = configparser.ConfigParser( + delimiters=("=",":"), + allow_no_value=False, + comment_prefixes=("#",";"), + inline_comment_prefixes=("#",";"), + strict=True, + empty_lines_in_values=False, + ) + + Once configparser parses the config file all section names are removed, thus all + keys must have unique names regardless of which INI section they are defined + under. Also, any keys which have python list syntax are converted to lists by + evaluating them as python code using ast.literal_eval + (https://docs.python.org/3/library/ast.html#ast.literal_eval). To facilitate + this all multi-line values are converted to single-line values. Thus multi-line + string values will have all new-lines converted to spaces. Note, since key-value + pairs that have python dictionary syntax are saved as single-line strings, even + if formatted across multiple lines in the config file, dictionaries can be read + in and converted to valid python dictionaries with PyYAML's safe_load. Example + given below: + + .. code:: py + + # inside your config file (e.g. config.ini) + [section1] # INI sections treated as comments + system1_settings: { # start of multi-line dictionary + 'a':True, + 'b':[2, 4, 8, 16], + 'c':{'start':0, 'stop':1000}, + 'd':'experiment 32 testing simulation with parameter a on' + } # end of multi-line dictionary value + + ....... + + # in your configargparse setup + import configargparse + import yaml + + parser = configargparse.ConfigParser( + config_file_parser_class=configargparse.ConfigparserConfigFileParser + ) + parser.add_argument('--system1_settings', type=yaml.safe_load) + + args = parser.parse_args() # now args.system1 is a valid python dict + ArgParser Singletons ~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -412,6 +464,14 @@ .. |Travis CI Status for bw2/ConfigArgParse| image:: https://travis-ci.org/bw2/ConfigArgParse.svg?branch=master + + Versioning + ~~~~~~~~~~ + + This software follows `Semantic Versioning`_ + + .. _Semantic Versioning: http://semver.org/ + Keywords: options,argparse,ConfigArgParse,config,environment variables,envvars,ENV,environment,optparse,YAML,INI Platform: UNKNOWN Classifier: Development Status :: 4 - Beta @@ -424,6 +484,7 @@ Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 +Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.* diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ConfigArgParse-1.0/README.rst new/ConfigArgParse-1.2.3/README.rst --- old/ConfigArgParse-1.0/README.rst 2019-10-24 03:14:22.000000000 +0200 +++ new/ConfigArgParse-1.2.3/README.rst 2020-04-23 03:09:45.000000000 +0200 @@ -162,11 +162,12 @@ ~~~~~~~~~~~~~~~~~~ Only command line args that have a long version (eg. one that starts with '--') -can be set in a config file. For example, "--color" can be set by -putting "color=green" in a config file. The config file syntax depends on the -constuctor arg: :code:`config_file_parser_class` which can be set to one of the -provided classes: :code:`DefaultConfigFileParser` or :code:`YAMLConfigFileParser`, -or to your own subclass of the :code:`ConfigFileParser` abstract class. +can be set in a config file. For example, "--color" can be set by putting +"color=green" in a config file. The config file syntax depends on the constuctor +arg: :code:`config_file_parser_class` which can be set to one of the provided +classes: :code:`DefaultConfigFileParser`, :code:`YAMLConfigFileParser`, +:code:`ConfigparserConfigFileParser` or to your own subclass of the +:code:`ConfigFileParser` abstract class. *DefaultConfigFileParser* - the full range of valid syntax is: @@ -205,6 +206,57 @@ fruit: [apple, orange, lemon] indexes: [1, 12, 35, 40] +*ConfigparserConfigFileParser* - allows a subset of python's configparser +module syntax (https://docs.python.org/3.7/library/configparser.html). In +particular the following configparser options are set: + +.. code:: py + + config = configparser.ConfigParser( + delimiters=("=",":"), + allow_no_value=False, + comment_prefixes=("#",";"), + inline_comment_prefixes=("#",";"), + strict=True, + empty_lines_in_values=False, + ) + +Once configparser parses the config file all section names are removed, thus all +keys must have unique names regardless of which INI section they are defined +under. Also, any keys which have python list syntax are converted to lists by +evaluating them as python code using ast.literal_eval +(https://docs.python.org/3/library/ast.html#ast.literal_eval). To facilitate +this all multi-line values are converted to single-line values. Thus multi-line +string values will have all new-lines converted to spaces. Note, since key-value +pairs that have python dictionary syntax are saved as single-line strings, even +if formatted across multiple lines in the config file, dictionaries can be read +in and converted to valid python dictionaries with PyYAML's safe_load. Example +given below: + +.. code:: py + + # inside your config file (e.g. config.ini) + [section1] # INI sections treated as comments + system1_settings: { # start of multi-line dictionary + 'a':True, + 'b':[2, 4, 8, 16], + 'c':{'start':0, 'stop':1000}, + 'd':'experiment 32 testing simulation with parameter a on' + } # end of multi-line dictionary value + + ....... + + # in your configargparse setup + import configargparse + import yaml + + parser = configargparse.ConfigParser( + config_file_parser_class=configargparse.ConfigparserConfigFileParser + ) + parser.add_argument('--system1_settings', type=yaml.safe_load) + + args = parser.parse_args() # now args.system1 is a valid python dict + ArgParser Singletons ~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -405,3 +457,11 @@ .. |Travis CI Status for bw2/ConfigArgParse| image:: https://travis-ci.org/bw2/ConfigArgParse.svg?branch=master + + +Versioning +~~~~~~~~~~ + +This software follows `Semantic Versioning`_ + +.. _Semantic Versioning: http://semver.org/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ConfigArgParse-1.0/configargparse.py new/ConfigArgParse-1.2.3/configargparse.py --- old/ConfigArgParse-1.0/configargparse.py 2019-12-30 06:11:08.000000000 +0100 +++ new/ConfigArgParse-1.2.3/configargparse.py 2020-04-24 05:42:52.000000000 +0200 @@ -187,6 +187,79 @@ return r.getvalue() +class ConfigparserConfigFileParser(ConfigFileParser): + """parses INI files using pythons configparser.""" + + def get_syntax_description(self): + msg = """Uses configparser module to parse an INI file which allows multi-line + values. + + Allowed syntax is that for a ConfigParser with the following options: + + allow_no_value = False, + inline_comment_prefixes = ("#",) + strict = True + empty_lines_in_values = False + + See https://docs.python.org/3/library/configparser.html for details. + + Note: INI file sections names are still treated as comments. + """ + return msg + + def parse(self, stream): + """Parses the keys and values from an INI config file.""" + import configparser + from ast import literal_eval + # parse with configparser to allow multi-line values + config = configparser.ConfigParser( + delimiters=("=",":"), + allow_no_value=False, + comment_prefixes=("#",";"), + inline_comment_prefixes=("#",";"), + strict=True, + empty_lines_in_values=False, + ) + try: + config.read_string(stream.read()) + except Exception as e: + raise ConfigFileParserException("Couldn't parse config file: %s" % e) + # convert to dict and remove INI section names + result = OrderedDict() + for section in config.sections(): + for k,v in config[section].items(): + multiLine2SingleLine = v.replace('\n',' ').replace('\r',' ') + # handle special case for lists + if '[' in multiLine2SingleLine and ']' in multiLine2SingleLine: + # ensure not a dict with a list value + prelist_string = multiLine2SingleLine.split('[')[0] + if '{' not in prelist_string: + result[k] = literal_eval(multiLine2SingleLine) + else: + result[k] = multiLine2SingleLine + else: + result[k] = multiLine2SingleLine + return result + + def serialize(self, items): + """Does the inverse of config parsing by taking parsed values and + converting them back to a string representing config file contents. + """ + import configparser + import io + config = configparser.ConfigParser( + allow_no_value=False, + inline_comment_prefixes=("#",), + strict=True, + empty_lines_in_values=False, + ) + items = {"DEFAULT":items} + config.read_dict(items) + stream = io.StringIO() + config.write(stream) + stream.seek(0) + return stream.read() + class YAMLConfigFileParser(ConfigFileParser): """Parses YAML config files. Depends on the PyYAML module. https://pypi.python.org/pypi/PyYAML @@ -668,11 +741,21 @@ self.error("Unexpected value for %s: '%s'. Expecting 'true', " "'false', 'yes', 'no', '1' or '0'" % (key, value)) elif isinstance(value, list): + accepts_list_and_has_nargs = action is not None and action.nargs is not None and ( + isinstance(action, argparse._StoreAction) or isinstance(action, argparse._AppendAction) + ) and ( + action.nargs in ('+', '*') or (isinstance(action.nargs, int) and action.nargs > 1) + ) + if action is None or isinstance(action, argparse._AppendAction): for list_elem in value: - args.append( "%s=%s" % (command_line_key, str(list_elem)) ) - elif (isinstance(action, argparse._StoreAction) and action.nargs in ('+', '*')) or ( - isinstance(action.nargs, int) and action.nargs > 1): + if accepts_list_and_has_nargs and isinstance(list_elem, list): + args.append(command_line_key) + for sub_elem in list_elem: + args.append(str(sub_elem)) + else: + args.append( "%s=%s" % (command_line_key, str(list_elem)) ) + elif accepts_list_and_has_nargs: args.append( command_line_key ) for list_elem in value: args.append( str(list_elem) ) @@ -827,6 +910,8 @@ env_var_actions = [(a.env_var, a) for a in self._actions if getattr(a, "env_var", None)] for env_var, a in env_var_actions: + if a.help == SUPPRESS: + continue env_var_help_string = " [env var: %s]" % env_var if not a.help: a.help = "" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ConfigArgParse-1.0/setup.py new/ConfigArgParse-1.2.3/setup.py --- old/ConfigArgParse-1.0/setup.py 2019-12-30 06:06:27.000000000 +0100 +++ new/ConfigArgParse-1.2.3/setup.py 2020-04-24 05:43:20.000000000 +0200 @@ -76,7 +76,7 @@ setup( name='ConfigArgParse', - version="1.0", + version="1.2.3", description='A drop-in replacement for argparse that allows options to ' 'also be set via config files and/or environment variables.', long_description=long_description, @@ -97,6 +97,7 @@ 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: Implementation :: CPython', 'Programming Language :: Python :: Implementation :: PyPy', ], diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ConfigArgParse-1.0/tests/test_configargparse.py new/ConfigArgParse-1.2.3/tests/test_configargparse.py --- old/ConfigArgParse-1.0/tests/test_configargparse.py 2019-12-30 06:11:36.000000000 +0100 +++ new/ConfigArgParse-1.2.3/tests/test_configargparse.py 2020-03-15 12:07:55.000000000 +0100 @@ -3,6 +3,7 @@ from contextlib import contextmanager import inspect import logging +import os import sys import tempfile import types @@ -18,6 +19,9 @@ else: from StringIO import StringIO +# set COLUMNS to get expected wrapping +os.environ['COLUMNS'] = '80' + # enable logging to simplify debugging logger = logging.getLogger() logger.level = logging.DEBUG Binary files old/ConfigArgParse-1.0/tests/test_configargparse.pyc and new/ConfigArgParse-1.2.3/tests/test_configargparse.pyc differ