From 71eaa46927de82d676c15ecf8d25db73bf44f3455e09b654710439a9a7766075 Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Fri, 12 Jun 2020 10:26:13 +0000 Subject: [PATCH] - Resolve the mess with different patches. different_pytest_name.patch has been replaced by prog-in-description.patch from gh#alex-rudakov/sphinx-argparse#121 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-sphinx-argparse?expand=0&rev=3 --- different_pytest_name.patch | 51 --------------------- prog-in-description.patch | 83 ++++++++++++++++++++++++++++++++++ python-sphinx-argparse.changes | 8 ++++ python-sphinx-argparse.spec | 8 ++-- 4 files changed, 95 insertions(+), 55 deletions(-) delete mode 100644 different_pytest_name.patch create mode 100644 prog-in-description.patch diff --git a/different_pytest_name.patch b/different_pytest_name.patch deleted file mode 100644 index 45a2d66..0000000 --- a/different_pytest_name.patch +++ /dev/null @@ -1,51 +0,0 @@ ---- a/test/test_parser.py -+++ b/test/test_parser.py -@@ -1,4 +1,8 @@ - import argparse -+import os -+import sys -+print("sys.path = {}".format(sys.path)) -+ - from sphinxarg.parser import parse_parser, parser_navigate - - -@@ -129,6 +133,8 @@ def test_parse_description(): - - - def test_parse_nested(): -+ pytest_name = os.environ['PYTEST_NAME'] if 'PYTEST_NAME' in os.environ \ -+ else 'py.test' - parser = argparse.ArgumentParser() - parser.add_argument('foo', default=False, help='foo help') - parser.add_argument('bar', default=False) -@@ -157,8 +163,8 @@ def test_parse_nested(): - { - 'name': 'install', - 'help': 'install help', -- 'usage': 'usage: py.test install [-h] [--upgrade] ref', -- 'bare_usage': 'py.test install [-h] [--upgrade] ref', -+ 'usage': 'usage: {} install [-h] [--upgrade] ref'.format(pytest_name), -+ 'bare_usage': '{} install [-h] [--upgrade] ref'.format(pytest_name), - 'action_groups': [ - { - 'title': 'Positional Arguments', -@@ -188,6 +194,8 @@ def test_parse_nested(): - - - def test_parse_nested_traversal(): -+ pytest_name = os.environ['PYTEST_NAME'] if 'PYTEST_NAME' in os.environ \ -+ else 'py.test' - parser = argparse.ArgumentParser() - - subparsers1 = parser.add_subparsers() -@@ -223,8 +231,8 @@ def test_parse_nested_traversal(): - { - 'name': 'level3', - 'help': '', -- 'usage': 'usage: py.test level1 level2 level3 [-h] foo bar', -- 'bare_usage': 'py.test level1 level2 level3 [-h] foo bar', -+ 'usage': 'usage: {} level1 level2 level3 [-h] foo bar'.format(pytest_name), -+ 'bare_usage': '{} level1 level2 level3 [-h] foo bar'.format(pytest_name), - 'action_groups': [ - { - 'title': 'Positional Arguments', diff --git a/prog-in-description.patch b/prog-in-description.patch new file mode 100644 index 0000000..62a5df1 --- /dev/null +++ b/prog-in-description.patch @@ -0,0 +1,83 @@ +--- a/sphinxarg/parser.py ++++ b/sphinxarg/parser.py +@@ -10,7 +10,7 @@ def parser_navigate(parser_result, path, + if isinstance(path, str): + if path == '': + return parser_result +- path = re.split('\s+', path) ++ path = re.split(r'\s+', path) + current_path = current_path or [] + if len(path) == 0: + return parser_result +@@ -35,7 +35,7 @@ def _try_add_parser_attribute(data, pars + if not isinstance(attribval, str): + return + if len(attribval) > 0: +- data[attribname] = attribval ++ data[attribname] = attribval % {'prog': data['prog']} + + + def _format_usage_without_prefix(parser): +--- a/test/test_parser.py ++++ b/test/test_parser.py +@@ -129,7 +129,7 @@ def test_parse_description(): + + + def test_parse_nested(): +- parser = argparse.ArgumentParser() ++ parser = argparse.ArgumentParser(prog='test_parse_nested') + parser.add_argument('foo', default=False, help='foo help') + parser.add_argument('bar', default=False) + +@@ -157,8 +157,8 @@ def test_parse_nested(): + { + 'name': 'install', + 'help': 'install help', +- 'usage': 'usage: py.test install [-h] [--upgrade] ref', +- 'bare_usage': 'py.test install [-h] [--upgrade] ref', ++ 'usage': 'usage: test_parse_nested install [-h] [--upgrade] ref', ++ 'bare_usage': 'test_parse_nested install [-h] [--upgrade] ref', + 'action_groups': [ + { + 'title': 'Positional Arguments', +@@ -188,7 +188,7 @@ def test_parse_nested(): + + + def test_parse_nested_traversal(): +- parser = argparse.ArgumentParser() ++ parser = argparse.ArgumentParser(prog='test_parse_nested_traversal') + + subparsers1 = parser.add_subparsers() + subparser1 = subparsers1.add_parser('level1') +@@ -223,8 +223,8 @@ def test_parse_nested_traversal(): + { + 'name': 'level3', + 'help': '', +- 'usage': 'usage: py.test level1 level2 level3 [-h] foo bar', +- 'bare_usage': 'py.test level1 level2 level3 [-h] foo bar', ++ 'usage': 'usage: test_parse_nested_traversal level1 level2 level3 [-h] foo bar', ++ 'bare_usage': 'test_parse_nested_traversal level1 level2 level3 [-h] foo bar', + 'action_groups': [ + { + 'title': 'Positional Arguments', +@@ -265,6 +265,20 @@ def test_fill_in_default_prog(): + ] + + ++def test_fill_in_description_epilog(): ++ """ ++ Ensure that %(prog)s gets filled in inside description and epilog. ++ """ ++ parser = argparse.ArgumentParser( ++ prog='test_fill_in_description', ++ description='Welcome to %(prog)s', ++ epilog='%(prog)s salutes you') ++ data = parse_parser(parser) ++ ++ assert data['description'] == 'Welcome to test_fill_in_description' ++ assert data['epilog'] == 'test_fill_in_description salutes you' ++ ++ + def test_string_quoting(): + """ + If an optional argument has a string type and a default, then the default should be in quotes. diff --git a/python-sphinx-argparse.changes b/python-sphinx-argparse.changes index b14a329..a547e44 100644 --- a/python-sphinx-argparse.changes +++ b/python-sphinx-argparse.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Fri Jun 12 10:25:03 UTC 2020 - Matej Cepl + +- Resolve the mess with different + patches. different_pytest_name.patch has been + replaced by prog-in-description.patch from + gh#alex-rudakov/sphinx-argparse#121 + ------------------------------------------------------------------- Fri Dec 13 12:19:37 CET 2019 - Matej Cepl diff --git a/python-sphinx-argparse.spec b/python-sphinx-argparse.spec index 045e29b..e7050d4 100644 --- a/python-sphinx-argparse.spec +++ b/python-sphinx-argparse.spec @@ -1,7 +1,7 @@ # # spec file for package python-sphinx-argparse # -# Copyright (c) 2019 SUSE LLC +# Copyright (c) 2020 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -27,9 +27,9 @@ Group: Development/Languages/Python URL: https://github.com/ribozz/sphinx-argparse Source0: https://files.pythonhosted.org/packages/source/s/sphinx-argparse/sphinx-argparse-%{version}.tar.gz Source1: https://raw.githubusercontent.com/alex-rudakov/sphinx-argparse/%{version}/LICENSE#/LICENSE-sphinx-argparse -# PATCH-FIX-UPSTREAM different_pytest_name.patch gh#alex-rudakov/sphinx-argparse#121 mcepl@suse.com -# Use environmental variable PYTEST_NAME for different names of the pytest executable -Patch0: different_pytest_name.patch +# PATCH-FIX-UPSTREAM prog-in-description.patch gh#alex-rudakov/sphinx-argparse#113 mcepl@suse.com +# Substitute %(prog)s in description and epilog +Patch0: prog-in-description.patch BuildRequires: %{python_module CommonMark} BuildRequires: %{python_module Sphinx >= 1.2.0} BuildRequires: %{python_module pytest}