argparse-from-file 1.2__tar.gz → 1.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {argparse_from_file-1.2 → argparse_from_file-1.4}/Makefile +3 -2
- {argparse_from_file-1.2/argparse_from_file.egg-info → argparse_from_file-1.4}/PKG-INFO +7 -6
- {argparse_from_file-1.2 → argparse_from_file-1.4}/README.md +6 -5
- argparse_from_file-1.4/argparse_from_file/__init__.py +2 -0
- argparse_from_file-1.2/argparse_from_file.py → argparse_from_file-1.4/argparse_from_file/argparse.py +7 -12
- argparse_from_file-1.4/argparse_from_file/py.typed +0 -0
- {argparse_from_file-1.2 → argparse_from_file-1.4/argparse_from_file.egg-info}/PKG-INFO +7 -6
- {argparse_from_file-1.2 → argparse_from_file-1.4}/argparse_from_file.egg-info/SOURCES.txt +4 -1
- argparse_from_file-1.4/test.py +10 -0
- {argparse_from_file-1.2 → argparse_from_file-1.4}/.gitignore +0 -0
- {argparse_from_file-1.2 → argparse_from_file-1.4}/argparse_from_file.egg-info/dependency_links.txt +0 -0
- {argparse_from_file-1.2 → argparse_from_file-1.4}/argparse_from_file.egg-info/requires.txt +0 -0
- {argparse_from_file-1.2 → argparse_from_file-1.4}/argparse_from_file.egg-info/top_level.txt +0 -0
- {argparse_from_file-1.2 → argparse_from_file-1.4}/pyproject.toml +0 -0
- {argparse_from_file-1.2 → argparse_from_file-1.4}/setup.cfg +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
NAME = $(shell basename $(CURDIR))
|
|
2
|
-
|
|
2
|
+
PYNAME = $(subst -,_,$(NAME))
|
|
3
|
+
PYFILES = $(wildcard $(PYNAME)/[^_]*.py)
|
|
3
4
|
|
|
4
5
|
check:
|
|
5
6
|
ruff check $(PYFILES)
|
|
@@ -19,4 +20,4 @@ format::
|
|
|
19
20
|
ruff check --select I --fix $(PYFILES) && ruff format $(PYFILES)
|
|
20
21
|
|
|
21
22
|
clean::
|
|
22
|
-
@rm -vrf *.egg-info build/ dist/ __pycache__/
|
|
23
|
+
@rm -vrf *.egg-info build/ dist/ __pycache__/ */__pycache__
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: argparse-from-file
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4
|
|
4
4
|
Summary: Wrapper for Python's argparse to also read arguments from a file
|
|
5
5
|
Author-email: Mark Blakeney <mark.blakeney@bullet-systems.net>
|
|
6
6
|
License-Expression: GPL-3.0-or-later
|
|
@@ -57,11 +57,11 @@ which is the only addition to the standard
|
|
|
57
57
|
[`ArgumentParser()`][argparser] API:
|
|
58
58
|
|
|
59
59
|
```python
|
|
60
|
-
# Use a specific file path
|
|
61
|
-
parser = argparse.ArgumentParser(from_file='/path/to/
|
|
60
|
+
# Use a specific () file path
|
|
61
|
+
parser = argparse.ArgumentParser(from_file='/path/to/myprog.conf', ..)
|
|
62
62
|
|
|
63
63
|
# Use a file relative to the user's config directory
|
|
64
|
-
parser = argparse.ArgumentParser(from_file='
|
|
64
|
+
parser = argparse.ArgumentParser(from_file='myprog.conf', ..)
|
|
65
65
|
```
|
|
66
66
|
|
|
67
67
|
The `from_file` argument accepts a string or a [`pathlib.Path`][pathlib].
|
|
@@ -76,10 +76,11 @@ clarity.
|
|
|
76
76
|
|
|
77
77
|
Example `~/.config/myprog-flags.conf`:
|
|
78
78
|
```
|
|
79
|
-
--verbose
|
|
80
|
-
|
|
81
79
|
# Always run with foo set to 123
|
|
82
80
|
--foo 123
|
|
81
|
+
|
|
82
|
+
# Default to verbose output
|
|
83
|
+
--verbose
|
|
83
84
|
```
|
|
84
85
|
|
|
85
86
|
## Customizing the Help Message
|
|
@@ -44,11 +44,11 @@ which is the only addition to the standard
|
|
|
44
44
|
[`ArgumentParser()`][argparser] API:
|
|
45
45
|
|
|
46
46
|
```python
|
|
47
|
-
# Use a specific file path
|
|
48
|
-
parser = argparse.ArgumentParser(from_file='/path/to/
|
|
47
|
+
# Use a specific () file path
|
|
48
|
+
parser = argparse.ArgumentParser(from_file='/path/to/myprog.conf', ..)
|
|
49
49
|
|
|
50
50
|
# Use a file relative to the user's config directory
|
|
51
|
-
parser = argparse.ArgumentParser(from_file='
|
|
51
|
+
parser = argparse.ArgumentParser(from_file='myprog.conf', ..)
|
|
52
52
|
```
|
|
53
53
|
|
|
54
54
|
The `from_file` argument accepts a string or a [`pathlib.Path`][pathlib].
|
|
@@ -63,10 +63,11 @@ clarity.
|
|
|
63
63
|
|
|
64
64
|
Example `~/.config/myprog-flags.conf`:
|
|
65
65
|
```
|
|
66
|
-
--verbose
|
|
67
|
-
|
|
68
66
|
# Always run with foo set to 123
|
|
69
67
|
--foo 123
|
|
68
|
+
|
|
69
|
+
# Default to verbose output
|
|
70
|
+
--verbose
|
|
70
71
|
```
|
|
71
72
|
|
|
72
73
|
## Customizing the Help Message
|
argparse_from_file-1.2/argparse_from_file.py → argparse_from_file-1.4/argparse_from_file/argparse.py
RENAMED
|
@@ -15,7 +15,7 @@ PLACEHOLDER = '#FROM_FILE_PATH#'
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
# Get program name. This function is copied (but very modified) from argparse 3.14.0
|
|
18
|
-
def _prog_name():
|
|
18
|
+
def _prog_name() -> str:
|
|
19
19
|
try:
|
|
20
20
|
modspec = sys.modules['__main__'].__spec__
|
|
21
21
|
except (KeyError, AttributeError):
|
|
@@ -23,10 +23,10 @@ def _prog_name():
|
|
|
23
23
|
# no good answer here, so fall back to the default
|
|
24
24
|
modspec = None
|
|
25
25
|
|
|
26
|
-
if not modspec or modspec.name == '__main__':
|
|
26
|
+
if not modspec or (name := modspec.name) == '__main__':
|
|
27
27
|
return os.path.basename(sys.argv[0])
|
|
28
28
|
|
|
29
|
-
return
|
|
29
|
+
return name[:-9] if name.endswith('.__main__') else name
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
class ArgumentParser(argparse.ArgumentParser):
|
|
@@ -35,9 +35,9 @@ class ArgumentParser(argparse.ArgumentParser):
|
|
|
35
35
|
def __init__(self, *args, **kwargs):
|
|
36
36
|
self._argv = []
|
|
37
37
|
|
|
38
|
-
# Only set up "from file" stuff once, for the top-level
|
|
39
|
-
if
|
|
40
|
-
|
|
38
|
+
# Only set up "from file" stuff once, for the top-level/main ArgumentParser()
|
|
39
|
+
if __class__._top:
|
|
40
|
+
__class__._top = False
|
|
41
41
|
|
|
42
42
|
# from_file = 'path-to/file': Use this as "from file" name/path. If
|
|
43
43
|
# relative then wrt platform specific user config dir.
|
|
@@ -79,7 +79,7 @@ class ArgumentParser(argparse.ArgumentParser):
|
|
|
79
79
|
|
|
80
80
|
self.from_file_path = from_file_path
|
|
81
81
|
|
|
82
|
-
|
|
82
|
+
super().__init__(*args, **kwargs)
|
|
83
83
|
|
|
84
84
|
def parse_args(self, args=None, namespace=None): # type: ignore[override]
|
|
85
85
|
if args is None and self._argv:
|
|
@@ -89,8 +89,3 @@ class ArgumentParser(argparse.ArgumentParser):
|
|
|
89
89
|
self._argv.clear()
|
|
90
90
|
|
|
91
91
|
return super().parse_args(args, namespace)
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
def __getattr__(name: str):
|
|
95
|
-
"Proxy all other attributes from argparse module."
|
|
96
|
-
return getattr(argparse, name)
|
|
File without changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: argparse-from-file
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4
|
|
4
4
|
Summary: Wrapper for Python's argparse to also read arguments from a file
|
|
5
5
|
Author-email: Mark Blakeney <mark.blakeney@bullet-systems.net>
|
|
6
6
|
License-Expression: GPL-3.0-or-later
|
|
@@ -57,11 +57,11 @@ which is the only addition to the standard
|
|
|
57
57
|
[`ArgumentParser()`][argparser] API:
|
|
58
58
|
|
|
59
59
|
```python
|
|
60
|
-
# Use a specific file path
|
|
61
|
-
parser = argparse.ArgumentParser(from_file='/path/to/
|
|
60
|
+
# Use a specific () file path
|
|
61
|
+
parser = argparse.ArgumentParser(from_file='/path/to/myprog.conf', ..)
|
|
62
62
|
|
|
63
63
|
# Use a file relative to the user's config directory
|
|
64
|
-
parser = argparse.ArgumentParser(from_file='
|
|
64
|
+
parser = argparse.ArgumentParser(from_file='myprog.conf', ..)
|
|
65
65
|
```
|
|
66
66
|
|
|
67
67
|
The `from_file` argument accepts a string or a [`pathlib.Path`][pathlib].
|
|
@@ -76,10 +76,11 @@ clarity.
|
|
|
76
76
|
|
|
77
77
|
Example `~/.config/myprog-flags.conf`:
|
|
78
78
|
```
|
|
79
|
-
--verbose
|
|
80
|
-
|
|
81
79
|
# Always run with foo set to 123
|
|
82
80
|
--foo 123
|
|
81
|
+
|
|
82
|
+
# Default to verbose output
|
|
83
|
+
--verbose
|
|
83
84
|
```
|
|
84
85
|
|
|
85
86
|
## Customizing the Help Message
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
.gitignore
|
|
2
2
|
Makefile
|
|
3
3
|
README.md
|
|
4
|
-
argparse_from_file.py
|
|
5
4
|
pyproject.toml
|
|
5
|
+
test.py
|
|
6
|
+
argparse_from_file/__init__.py
|
|
7
|
+
argparse_from_file/argparse.py
|
|
8
|
+
argparse_from_file/py.typed
|
|
6
9
|
argparse_from_file.egg-info/PKG-INFO
|
|
7
10
|
argparse_from_file.egg-info/SOURCES.txt
|
|
8
11
|
argparse_from_file.egg-info/dependency_links.txt
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/python
|
|
2
|
+
import argparse_from_file as argparse
|
|
3
|
+
|
|
4
|
+
opt = argparse.ArgumentParser()
|
|
5
|
+
opt.add_argument('-b', '--bool', action='store_true', help='sample bool option')
|
|
6
|
+
opt.add_argument('-s', '--str', help='sample str option')
|
|
7
|
+
print(opt.parse_args())
|
|
8
|
+
|
|
9
|
+
# Ensure external argparse constants are accessible
|
|
10
|
+
print(argparse.SUPPRESS)
|
|
File without changes
|
{argparse_from_file-1.2 → argparse_from_file-1.4}/argparse_from_file.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|