summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2014-10-16 08:28:51 +0200
committerAnthon van der Neut <anthon@mnt.org>2014-10-16 08:28:51 +0200
commitcf4b0c51bf05870990f6295060b9c7622083df81 (patch)
treed9d02b0028e9b48b57b594304a6c19a3ba836135
parentd150cfed69a796bcbcb4a55a57193b8da8027750 (diff)
downloadruamel.std.argparse-cf4b0c51bf05870990f6295060b9c7622083df81.tar.gz
copyright and pep8 updates
-rw-r--r--.hgignore1
-rw-r--r--Makefile2
-rw-r--r--README.rst16
-rw-r--r--__init__.py1
-rw-r--r--_action/__init__.py1
-rw-r--r--_action/checksinglestore.py1
-rw-r--r--_action/count.py1
-rw-r--r--_action/splitappend.py1
-rw-r--r--example/checksingleaction.py3
-rw-r--r--example/countaction.py2
-rw-r--r--example/smartformatter.py2
-rw-r--r--example/testcmd.py5
-rw-r--r--setup.py5
-rw-r--r--test/test_argparse.py16
-rw-r--r--test/test_program.py36
15 files changed, 57 insertions, 36 deletions
diff --git a/.hgignore b/.hgignore
index d496f4b..6007b8b 100644
--- a/.hgignore
+++ b/.hgignore
@@ -6,6 +6,7 @@ syntax: glob
*.bak
*.o
*.orig
+README.pdf
dist
build
*.egg-info
diff --git a/Makefile b/Makefile
index 81e8fb1..594e80a 100644
--- a/Makefile
+++ b/Makefile
@@ -7,7 +7,7 @@ REGEN:=/usr/local/bin/ruamel_util_new util --std Argparse --skip-util --skip-hg
include ~/.config/ruamel_util_new/Makefile.inc
clean:
- rm -rf build .tox $(PKGNAME).egg-info/ README.pdf
+ rm -rf build .tox $(PKGNAME).egg-info/ README.pdf __pycache__
find . -name "*.pyc" -exec rm {} +
updatereadme:
diff --git a/README.rst b/README.rst
index ee25009..ff136d3 100644
--- a/README.rst
+++ b/README.rst
@@ -56,7 +56,7 @@ Count up and down::
parser = argparse.ArgumentParser()
parser.add_argument('--verbose', '-v', action=CountAction, const=1, nargs=0)
parser.add_argument('--quiet', '-q', action=CountAction, dest='verbose',
- const=-1, nargs=0)
+ const=-1, nargs=0)
print(parser.parse_args("--verbose -v -q".split()))
@@ -109,7 +109,8 @@ Complain if the same option is called multiple times::
import argparse
parser = argparse.ArgumentParser()
- parser.add_argument('--check', '-c', action=CheckSingleStoreAction, const=1, nargs=0)
+ parser.add_argument('--check', '-c', action=CheckSingleStoreAction, const=1,
+ nargs=0)
print(parser.parse_args("--check -c".split()))
@@ -150,6 +151,7 @@ line breaks in the version string.
from ruamel.std.argparse import SmartFormatter
import argparse
+
def exit(self, *args, **kw):
pass
@@ -172,7 +174,6 @@ line breaks in the version string.
if index > 0:
print('--------------------------------------\n')
parser.parse_args(["--help"])
-
.. example code smartformatter.py
@@ -224,7 +225,8 @@ A typical use case is::
import os
from ruamel.std.argparse import ProgramBase, option, sub_parser, version, \
- SmartFormatter
+ SmartFormatter
+
class TestCmd(ProgramBase):
def __init__(self):
@@ -243,7 +245,7 @@ A typical use case is::
def run(self):
if self._args.func:
- return self._args.func()
+ return self._args.func()
def parse_args(self, *args):
self._parse_args(*args)
@@ -301,6 +303,6 @@ them on the special handled method ``_pb_init`` if subclassing might
happen.
Care should be taken that all attributes on ``TestCmd`` are accessed
-during scanning for sub parsers. In particular any ``@property``
-decorated method will be accessed.
+during scanning for sub parsers. In particular any property method
+will be accessedi and its code executed.
diff --git a/__init__.py b/__init__.py
index 7434f51..0ff9c30 100644
--- a/__init__.py
+++ b/__init__.py
@@ -1,4 +1,5 @@
# coding: utf-8
+# Copyright Ruamel bvba 2007-2014
from __future__ import print_function
diff --git a/_action/__init__.py b/_action/__init__.py
index 9cd9b75..f49013d 100644
--- a/_action/__init__.py
+++ b/_action/__init__.py
@@ -1 +1,2 @@
+# Copyright Ruamel bvba 2007-2014
"""extra actions for argparse"""
diff --git a/_action/checksinglestore.py b/_action/checksinglestore.py
index 11fd80c..3a37792 100644
--- a/_action/checksinglestore.py
+++ b/_action/checksinglestore.py
@@ -1,4 +1,5 @@
# coding: utf-8
+# Copyright Ruamel bvba 2007-2014
from __future__ import print_function
diff --git a/_action/count.py b/_action/count.py
index 1362907..77bf54f 100644
--- a/_action/count.py
+++ b/_action/count.py
@@ -1,4 +1,5 @@
# coding: utf-8
+# Copyright Ruamel bvba 2007-2014
from __future__ import print_function
diff --git a/_action/splitappend.py b/_action/splitappend.py
index fade386..82b003b 100644
--- a/_action/splitappend.py
+++ b/_action/splitappend.py
@@ -1,4 +1,5 @@
# coding: utf-8
+# Copyright Ruamel bvba 2007-2014
from __future__ import print_function
diff --git a/example/checksingleaction.py b/example/checksingleaction.py
index cad05ea..054891c 100644
--- a/example/checksingleaction.py
+++ b/example/checksingleaction.py
@@ -4,6 +4,7 @@ from ruamel.std.argparse import CheckSingleStoreAction
import argparse
parser = argparse.ArgumentParser()
-parser.add_argument('--check', '-c', action=CheckSingleStoreAction, const=1, nargs=0)
+parser.add_argument('--check', '-c', action=CheckSingleStoreAction, const=1,
+ nargs=0)
print(parser.parse_args("--check -c".split())) \ No newline at end of file
diff --git a/example/countaction.py b/example/countaction.py
index b9ee104..9d1235c 100644
--- a/example/countaction.py
+++ b/example/countaction.py
@@ -6,6 +6,6 @@ import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--verbose', '-v', action=CountAction, const=1, nargs=0)
parser.add_argument('--quiet', '-q', action=CountAction, dest='verbose',
- const=-1, nargs=0)
+ const=-1, nargs=0)
print(parser.parse_args("--verbose -v -q".split()))
diff --git a/example/smartformatter.py b/example/smartformatter.py
index cb19f09..a64174f 100644
--- a/example/smartformatter.py
+++ b/example/smartformatter.py
@@ -3,6 +3,7 @@ from __future__ import print_function
from ruamel.std.argparse import SmartFormatter
import argparse
+
def exit(self, *args, **kw):
pass
@@ -25,4 +26,3 @@ for index, log_s in enumerate(['log to file', 'D|log to file']):
if index > 0:
print('--------------------------------------\n')
parser.parse_args(["--help"])
-
diff --git a/example/testcmd.py b/example/testcmd.py
index a319306..1618820 100644
--- a/example/testcmd.py
+++ b/example/testcmd.py
@@ -4,7 +4,8 @@ import sys
import os
from ruamel.std.argparse import ProgramBase, option, sub_parser, version, \
- SmartFormatter
+ SmartFormatter
+
class TestCmd(ProgramBase):
def __init__(self):
@@ -23,7 +24,7 @@ class TestCmd(ProgramBase):
def run(self):
if self._args.func:
- return self._args.func()
+ return self._args.func()
def parse_args(self, *args):
self._parse_args(*args)
diff --git a/setup.py b/setup.py
index d41f485..3f0b892 100644
--- a/setup.py
+++ b/setup.py
@@ -1,5 +1,6 @@
#! /usr/bin/env python
# coding: utf-8
+# Copyright Ruamel bvba 2007-2014
from __future__ import print_function
@@ -67,6 +68,8 @@ def _check_convert_version(tup):
# < from ruamel.util.new.setupinc import version_info, version_str
version_info = get_version()
version_str = _check_convert_version(version_info)
+
+
# < from ruamel.util.new.setupinc import MyInstallLib
class MyInstallLib(install_lib.install_lib):
"create __init__.py on the fly"
@@ -128,7 +131,7 @@ def main():
url='https://bitbucket.org/ruamel/' + package_name,
author='Anthon van der Neut',
author_email='a.van.der.neut@ruamel.eu',
- license="Copyright Ruamel bvba 2007-2014",
+ license="MIT license",
package_dir={full_package_name: '.'},
namespace_packages=[name_space],
packages=packages,
diff --git a/test/test_argparse.py b/test/test_argparse.py
index d50b46b..6c3d765 100644
--- a/test/test_argparse.py
+++ b/test/test_argparse.py
@@ -1,13 +1,16 @@
# coding: utf-8
+# Copyright Ruamel bvba 2007-2014
import pytest
from ruamel.std.argparse import argparse, CountAction, SmartFormatter
from textwrap import dedent
+
def exit(self=None, status=None, message=None):
pass
+
def test_argparse(capsys):
desc = dedent("""\
Please do not mess up this text!
@@ -48,11 +51,12 @@ def test_argparse(capsys):
--list LIST {2}
--oneline one line help
""").format(
- desc, help_verbose,
- help_list.lstrip().replace('\n ', '\n ').rstrip(),
- )
+ desc, help_verbose,
+ help_list.lstrip().replace('\n ', '\n ').rstrip(),
+ )
assert full_help == out
+
def test_argparse_default(capsys):
desc = dedent("""\
Please do not mess up this text!
@@ -95,7 +99,7 @@ def test_argparse_default(capsys):
(default: None)
--oneline one line help (default: False)
""").format(
- desc, help_verbose,
- help_list.lstrip().replace('\n ', '\n ').rstrip(),
- )
+ desc, help_verbose,
+ help_list.lstrip().replace('\n ', '\n ').rstrip(),
+ )
assert full_help == out
diff --git a/test/test_program.py b/test/test_program.py
index 6d7bc5b..4ac1706 100644
--- a/test/test_program.py
+++ b/test/test_program.py
@@ -1,4 +1,6 @@
# coding: utf-8
+# Copyright Ruamel bvba 2007-2014
+
from __future__ import print_function
@@ -7,11 +9,12 @@ import pytest
from ruamel.std.argparse import ProgramBase, option, sub_parser, version
+
class Program(ProgramBase):
def __init__(self):
- #super(Program, self).__init__(
- # formatter_class=SmartFormatter
- #)
+ # super(Program, self).__init__(
+ # formatter_class=SmartFormatter
+ # )
ProgramBase.__init__(self)
def run(self):
@@ -25,7 +28,7 @@ class Program(ProgramBase):
# defensive is to use a differently named option or the special _pb_init
@option('--verbose', global_option=True, action='store_true')
@option('--quiet', action='store_true')
- #@option('--version', action='version', version='version: 42')
+ # @option('--version', action='version', version='version: 42')
@version('version: 42')
def _pb_init(self):
pass
@@ -57,12 +60,12 @@ class Program(ProgramBase):
@sub_parser(help="call git")
def git(self):
- print( 'doing git')
+ print('doing git')
@git.sub_parser('abc')
@option('--extra')
def just_some_name(self):
- print( 'doing just_some_name/abc')
+ print('doing just_some_name/abc')
@git.sub_parser('hihi', help='helphelp')
def hki(self):
@@ -70,7 +73,7 @@ class Program(ProgramBase):
@hki.sub_parser('oops')
def oops(self):
- print( 'doing oops')
+ print('doing oops')
@sub_parser(help="call a")
def a(self):
@@ -91,15 +94,16 @@ class Program(ProgramBase):
# on purpose not in "right" order
@sub_parser(help="call f")
def f(self):
- print( 'doing f')
+ print('doing f')
@sub_parser(help="call e")
def e(self):
pass
- #@sub_parser('svn')
- #def subversion(self):
- # pass
+ # @sub_parser('svn')
+ # def subversion(self):
+ # pass
+
class ParseHelpOutput:
def __init__(self, capsys, error=False):
@@ -111,7 +115,7 @@ class ParseHelpOutput:
def __call__(self, out):
print(out)
print('+++++')
- self._chunks = {}
+ self._chunks = {}
chunk = None
for line in out.splitlines():
lsplit = line.split()
@@ -157,7 +161,7 @@ class TestProgram:
program._parse_args('-h'.split())
pho = ParseHelpOutput(capsys)
assert pho.start('positional arguments', 'hg')
- if sys.version_info[:2] == (2,6):
+ if sys.version_info[:2] == (2, 6):
# 2.6 argparse scrambles order
assert pho.somewhere('usage', 'git,e,d,f')
else:
@@ -176,8 +180,8 @@ class TestProgram:
with pytest.raises(SystemExit):
program._parse_args('hg check -h'.split())
pho = ParseHelpOutput(capsys)
- #assert not pho.start('positional arguments', 'file-name')
- #assert not pho.start('positional arguments', 'hg')
+ # assert not pho.start('positional arguments', 'file-name')
+ # assert not pho.start('positional arguments', 'hg')
assert pho.start('optional arguments', '--extra')
assert pho.start('optional arguments', '--verbose')
@@ -205,7 +209,7 @@ class TestProgram:
def test_version(self, capsys, program):
with pytest.raises(SystemExit):
program._parse_args('--version'.split())
- pho = ParseHelpOutput(capsys, error=sys.version_info < (3,4))
+ pho = ParseHelpOutput(capsys, error=sys.version_info < (3, 4))
assert pho.start('version', '42')
if __name__ == '__main__':