tags: +patch

Attached is a set of patches for the stretch version.

I have also converted to git-buildpackage.

Alternatively pull the branch
https://salsa.debian.org/hansto-guest/sphinx-argparse/tree/debian/stretch

Best regards,
    Hanno
From 32688c2a1bb176672f47c55a27fdf9d23c977635 Mon Sep 17 00:00:00 2001
From: Dmitry Shachnev <mity...@debian.org>
Date: Thu, 28 Jun 2018 00:25:01 +0300
Subject: [PATCH 1/3] Convert from git-dpm to gbp and patches unapplied format.

---
 debian/gbp.conf     |  2 ++
 test/test_parser.py | 10 +++++-----
 2 files changed, 7 insertions(+), 5 deletions(-)
 create mode 100644 debian/gbp.conf

diff --git a/debian/gbp.conf b/debian/gbp.conf
new file mode 100644
index 0000000..3879982
--- /dev/null
+++ b/debian/gbp.conf
@@ -0,0 +1,2 @@
+[DEFAULT]
+debian-branch=debian/master
diff --git a/test/test_parser.py b/test/test_parser.py
index 43852a2..859e3de 100755
--- a/test/test_parser.py
+++ b/test/test_parser.py
@@ -160,8 +160,8 @@ def test_parse_nested():
         {
             'name': 'install',
             'help': 'install help',
-            'usage': 'usage: pytest.py install [-h] [--upgrade] ref',
-            'bare_usage': 'pytest.py install [-h] [--upgrade] ref',
+            'usage': 'usage: py.test install [-h] [--upgrade] ref',
+            'bare_usage': 'py.test install [-h] [--upgrade] ref',
             'args': [
                 {
                     'name': 'ref',
@@ -216,8 +216,8 @@ def test_parse_nested_traversal():
                 {
                     'name': 'level3',
                     'help': '',
-                    'usage': 'usage: pytest.py level1 level2 level3 [-h] foo bar',
-                    'bare_usage': 'pytest.py level1 level2 level3 [-h] foo bar',
+                    'usage': 'usage: py.test level1 level2 level3 [-h] foo bar',
+                    'bare_usage': 'py.test level1 level2 level3 [-h] foo bar',
                     'args': [
                         {
                             'name': 'foo',
@@ -233,4 +233,4 @@ def test_parse_nested_traversal():
                 }
             ]
 
-    assert data == parser_navigate(data, '')
+    assert data == parser_navigate(data, '')
\ No newline at end of file
-- 
2.11.0


From 28285460bf2bf6787cd1d93e9d5bd100ea8b3403 Mon Sep 17 00:00:00 2001
From: Hanno Stock <opensou...@hanno-stock.de>
Date: Mon, 25 Feb 2019 13:09:13 +0100
Subject: [PATCH 2/3] Fix aliased subcommands for Python3 (closes: #922880)

---
 debian/patches/0001-fix-tests.patch                |   1 -
 .../0002-Fix-aliased-subcommands-Python3.patch     | 126 +++++++++++++++++++++
 debian/patches/series                              |   1 +
 3 files changed, 127 insertions(+), 1 deletion(-)
 create mode 100644 debian/patches/0002-Fix-aliased-subcommands-Python3.patch

diff --git a/debian/patches/0001-fix-tests.patch b/debian/patches/0001-fix-tests.patch
index 95391da..d791e5b 100644
--- a/debian/patches/0001-fix-tests.patch
+++ b/debian/patches/0001-fix-tests.patch
@@ -1,4 +1,3 @@
-From 8a6a275c5a0a23fb466d6fa53da968e9096a8676 Mon Sep 17 00:00:00 2001
 From: Daniel Stender <deb...@danielstender.com>
 Date: Wed, 20 Jan 2016 21:24:54 +0100
 Subject: fix-tests
diff --git a/debian/patches/0002-Fix-aliased-subcommands-Python3.patch b/debian/patches/0002-Fix-aliased-subcommands-Python3.patch
new file mode 100644
index 0000000..6061f94
--- /dev/null
+++ b/debian/patches/0002-Fix-aliased-subcommands-Python3.patch
@@ -0,0 +1,126 @@
+From: Hanno Stock <hanno.st...@indurad.com>
+Date: Mon, 25 Feb 2019 12:06:20 +0100
+Subject: Fix aliased subcommands (Python3)
+
+When subcommands have aliases defined, the :path: parameter
+fails.
+
+Bug: https://github.com/ribozz/sphinx-argparse/pull/109
+Bug-Debian: https://bugs.debian.org/922880
+Applied-Upstream: 0.2.6
+---
+ sphinxarg/parser.py |  6 ++++-
+ test/test_parser.py | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++
+ 2 files changed, 74 insertions(+), 1 deletion(-)
+
+diff --git a/sphinxarg/parser.py b/sphinxarg/parser.py
+index 7bdbfa6..c339e29 100644
+--- a/sphinxarg/parser.py
++++ b/sphinxarg/parser.py
+@@ -20,7 +20,9 @@ def parser_navigate(parser_result, path, current_path=None):
+             ' '.join(current_path))
+     next_hop = path.pop(0)
+     for child in parser_result['children']:
+-        if child['name'] == next_hop:
++        # identifer is only used for aliased subcommands
++        identifier = child['identifier'] if 'identifier' in child else child['name']
++        if identifier == next_hop:
+             current_path.append(next_hop)
+             return parser_navigate(child, path, current_path)
+     raise NavigationException(
+@@ -90,6 +92,8 @@ def parse_parser(parser, data=None, **kwargs):
+                     'usage': subaction.format_usage().strip(),
+                     'bare_usage': _format_usage_without_prefix(subaction),
+                 }
++                if subalias:
++                    subdata['identifier'] = name
+                 parse_parser(subaction, subdata, **kwargs)
+                 data.setdefault('children', []).append(subdata)
+             continue
+diff --git a/test/test_parser.py b/test/test_parser.py
+index 43852a2..ab104aa 100755
+--- a/test/test_parser.py
++++ b/test/test_parser.py
+@@ -2,6 +2,7 @@ import argparse
+ import json
+ from pprint import pprint
+ from sphinxarg.parser import parse_parser, parser_navigate
++import six
+ 
+ 
+ def test_parse_options():
+@@ -180,6 +181,74 @@ def test_parse_nested():
+     ]
+ 
+ 
++if six.PY3:
++    def test_parse_nested_with_alias():
++        parser = argparse.ArgumentParser()
++        parser.add_argument('foo', default=False, help='foo help')
++        parser.add_argument('bar', default=False)
++
++        subparsers = parser.add_subparsers()
++
++        subparser = subparsers.add_parser('install', aliases=['i'], help='install help')
++        subparser.add_argument('ref', type=str, help='foo1 help')
++        subparser.add_argument('--upgrade', action='store_true', default=False, help='foo2 help')
++
++        data = parse_parser(parser)
++
++        assert data['args'] == [
++            {
++                'name': 'foo',
++                'help': 'foo help',
++                'metavar': None
++            }, {
++                'name': 'bar',
++                'help': '',
++                'metavar': None
++            },
++        ]
++
++        assert data['children'] == [
++            {
++                'name': 'install (i)',
++                'identifier': 'install',
++                'help': 'install help',
++                'usage': 'usage: pytest.py install [-h] [--upgrade] ref',
++                'bare_usage': 'pytest.py install [-h] [--upgrade] ref',
++                'args': [
++                    {
++                        'name': 'ref',
++                        'help': 'foo1 help',
++                        'metavar': None
++                    },
++                ],
++                'options': [
++                    {
++                        'name': ['--upgrade'],
++                        'default': False,
++                        'help': 'foo2 help'
++                    },
++                ]
++            },
++        ]
++
++    def test_aliased_traversal():
++        parser = argparse.ArgumentParser()
++
++        subparsers1 = parser.add_subparsers()
++        subparsers1.add_parser('level1', aliases=['l1'])
++
++        data = parse_parser(parser)
++
++        data2 = parser_navigate(data, 'level1')
++
++        assert(data2 == {
++            'bare_usage': 'pytest.py level1 [-h]',
++            'help': '',
++            'usage': 'usage: pytest.py level1 [-h]',
++            'name': 'level1 (l1)',
++            'identifier': 'level1'})
++
++
+ def test_parse_nested_traversal():
+     parser = argparse.ArgumentParser()
+ 
diff --git a/debian/patches/series b/debian/patches/series
index b16e02d..c199689 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,2 @@
 0001-fix-tests.patch
+0002-Fix-aliased-subcommands-Python3.patch
-- 
2.11.0


From 4cc0f61883b999a9ddaed442812f0b0d22605d44 Mon Sep 17 00:00:00 2001
From: Hanno Stock <opensou...@hanno-stock.de>
Date: Mon, 25 Feb 2019 15:07:25 +0100
Subject: [PATCH 3/3] Prepare release 0.1.15-3.1

---
 debian/changelog | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 4125185..579f95a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+sphinx-argparse (0.1.15-3.1) unstable; urgency=medium
+
+  * Non-maintainer upload.
+  * Convert from git-dpm to gbp and patches unapplied format.
+  * Fix aliased subcommands for Python3 (closes: #922880)
+
+ -- Hanno Stock <opensou...@hanno-stock.de>  Mon, 25 Feb 2019 15:05:30 +0100
+
 sphinx-argparse (0.1.15-3) unstable; urgency=medium
 
   * Orphan package:
-- 
2.11.0

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to