README
Printargs - A debugging helper for argparse
Print a nicely formatted view of an argparse.Namespace object for debugging purposes:
import sys
import argparse
import printargs
def main(args):
printargs.show(args)
# do somthing with args
def get_argument_parser():
p = argparse.ArgumentParser()
p.add_argument('-f', '--foo', action='store')
p.add_argument('-b', '--bar', action='store', type=int)
p.add_argument('-o', '--output', action='store', default=sys.stdout)
return p
if __name__ == "__main__":
argument_parser = get_argument_parser()
args = argument_parser.parse_args()
main(args)
To use the output for logging or to edit it use the printargs.formatted function, which returns the string instead of printing it:
import sys
import argparse
import printargs
def main(args):
t = printargs.formatted(args)
with open('log', 'a') as logfile:
logfile.write("Test program called with parameters:")
logfile.write(t)
logfile.write("\n\n")
def get_argument_parser():
p = argparse.ArgumentParser()
p.add_argument('-f', '--foo', action='store')
p.add_argument('-b', '--bar', action='store', type=int)
p.add_argument('-o', '--output', action='store', default=sys.stdout)
return p
if __name__ == "__main__":
argument_parser = get_argument_parser()
args = argument_parser.parse_args()
main(args)
Installation
Printargs can be installed with pip:
me@machine:~$ pip install printargs
or from the sources:
me@machine:~$ git clone https://HenningTimm@bitbucket.org/HenningTimm/printargs.git me@machine:~$ cd printargs me@machine:~/printargs$ python setup.py install
Planned features
curses based output with colors
License
Printargs is Open Source and licensed under the MIT License.
Metadata
Release files for printargs 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| printargs-1.0.1.tar.gz | 3.0 kB | Without provenance | Details for printargs-1.0.1.tar.gz |
Release files / printargs-1.0.1.tar.gz
| Download URL | printargs-1.0.1.tar.gz |
|---|---|
| Size | 3.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1e9e0ce407c99d12d977e45c6e45e41695e99438dd86a57a88599d1dcebf87c1
|
|
BLAKE2b-256 checksum How to use checksums |
03782f8c603c506a7cdab80ae16bdeae8d96a4f0ef7d09bce110b48ee7f1875f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for printargs 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.