diff options
| author | Anthon van der Neut <anthon@mnt.org> | 2015-08-27 17:44:39 +0200 |
|---|---|---|
| committer | Anthon van der Neut <anthon@mnt.org> | 2015-08-27 17:44:39 +0200 |
| commit | 3403025e03dd626d270f8f075fb4862daeff9878 (patch) | |
| tree | 7bdad65614b4948b1ad478a76c2ca3261e652425 /_action | |
| parent | e8188ad86449c239b6366937fea0578c315c1d5d (diff) | |
| download | ruamel.std.argparse-3403025e03dd626d270f8f075fb4862daeff9878.tar.gz | |
- added license
- move test to _test
- move _action to action
- updated setup.py (and pkg_data in __init__.py)
- flask8 in tox.ini
Diffstat (limited to '_action')
| -rw-r--r-- | _action/__init__.py | 2 | ||||
| -rw-r--r-- | _action/checksinglestore.py | 19 | ||||
| -rw-r--r-- | _action/count.py | 22 | ||||
| -rw-r--r-- | _action/splitappend.py | 29 |
4 files changed, 0 insertions, 72 deletions
diff --git a/_action/__init__.py b/_action/__init__.py deleted file mode 100644 index f49013d..0000000 --- a/_action/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -# Copyright Ruamel bvba 2007-2014 -"""extra actions for argparse""" diff --git a/_action/checksinglestore.py b/_action/checksinglestore.py deleted file mode 100644 index 3a37792..0000000 --- a/_action/checksinglestore.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding: utf-8 -# Copyright Ruamel bvba 2007-2014 - -from __future__ import print_function - -import argparse - - -class CheckSingleStoreAction(argparse.Action): - """issue a warning when the store action is called multiple times""" - def __call__(self, parser, namespace, values, option_string=None): - if getattr(namespace, self.dest, None) is not None: - print( - 'WARNING: previous optional argument "' + option_string + " " + - str(getattr(namespace, self.dest)) + '" overwritten by "' + - str(option_string) + - " " + str(values) + - '"') - setattr(namespace, self.dest, values) diff --git a/_action/count.py b/_action/count.py deleted file mode 100644 index 77bf54f..0000000 --- a/_action/count.py +++ /dev/null @@ -1,22 +0,0 @@ -# coding: utf-8 -# Copyright Ruamel bvba 2007-2014 - -from __future__ import print_function - -import argparse - - -class CountAction(argparse.Action): - """argparse action for counting 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) - """ - def __call__(self, parser, namespace, values, option_string=None): - try: - val = getattr(namespace, self.dest) + self.const - except TypeError: # probably None - val = self.const - setattr(namespace, self.dest, val) diff --git a/_action/splitappend.py b/_action/splitappend.py deleted file mode 100644 index 82b003b..0000000 --- a/_action/splitappend.py +++ /dev/null @@ -1,29 +0,0 @@ -# coding: utf-8 -# Copyright Ruamel bvba 2007-2014 - -from __future__ import print_function - -import argparse - - -class SplitAppendAction(argparse._AppendAction): - """append to list, like normal "append", but split first - (default split on ',') - - parser = argparse.ArgumentParser() - parser.add_argument('-d', action=SplitAppendAction) - - the following argument have the same list as result: - -d ab -d cd -d kl -d mn - -d ab,cd,kl,mn - -d ab,cd -d kl,mn - """ - def __init__(self, *args, **kw): - self._split_chr = ',' - argparse.Action.__init__(self, *args, **kw) - - def __call__(self, parser, namespace, values, option_string=None): - # _AppendAction does not return a value - for value in values.split(self._split_chr): - argparse._AppendAction.__call__( - self, parser, namespace, value, option_string) |
