Argumental
annotation descripters to put closuer on classes and objects to allow argparse to be easy to use
Argue.py
A tool to decorate a python class to create an argparse ready command line application
Here is an example application
#!/usr/bin/env python
import os,re,sys,json
from Argumental.Argue import Argue
args = Argue()
#====================================================================================================
@args.function(short='v', flag=True)
def verbose(): return False
#====================================================================================================
@args.command(single=True)
class ForTheSake(object):
#________________________________________________________________________________________________
@args.function(flag=True)
def myFlag(self):
'''
this is a flag true if exists false if not
'''
return False
#________________________________________________________________________________________________
@args.function(choices=['a','b'])
def myChoice(self):
'''
select for a list of choices,
test if in or out of list
'''
return None
#________________________________________________________________________________________________
@args.function(short='n', type=int)
def myNumber(self):
'''
this should expect an number of type int
'''
return 0
#________________________________________________________________________________________________
@args.operation
def myMethod(self, p1, p2, p3='d3', p4='d4'):
'''
this should be called myMethod
and is a good example
:param p1: p1 should be expected
:type p1: str
:param p2: p2 should be expected
:type p2: int
:param p3: p3 is optional use --p3 and defaults to d3
:param p4: p3 is optional use --p4 and defaults to d4
:return: json view of all variables
:rtype: dict
:Example:
$ ./forTheSake.py [--] <command> <operation> <parameters> [--parameter=optional]
'''
return {
'verbose' : verbose(),
'flag' : self.myFlag(),
'choice' : self.myChoice(),
'number' : self.myNumber(),
'p1' : p1,
'p2' : p2,
'p3' : p3,
'p4' : p4
}
#====================================================================================================
if __name__ == '__main__':
print json.dumps(args.execute(), indent=4)
A sample usage would look like;
$ ./ofTheEngagement.py -h
usage: ofTheEngagement.py [-h] [--args] [-n MYNUMBER] [--myChoice {a,b}] [--myFlag] [-v]
{OfTheEngagment} ...
positional arguments:
{OfTheEngagment}
OfTheEngagment
optional arguments:
-h, --help show this help message and exit
--args show this argument tree
-n MYNUMBER, --myNumber MYNUMBER
<type 'int'> this should expect an number of type int
--myChoice {a,b} select for a list of choices, test if in or out of list
--myFlag this is a flag true if exists false if not
-v, --verbose
$ ./ofTheEngagement.py OfTheEngagment -h
usage: ofTheEngagement.py OfTheEngagment [-h] {myMethod} ...
positional arguments:
{myMethod}
myMethod this should be called myMethod and is a good example
optional arguments:
-h, --help show this help message and exit
$ ./ofTheEngagement.py OfTheEngagment myMethod -h
usage: ofTheEngagement.py OfTheEngagment myMethod [-h] [--p3 P3] [--p4 P4] p1 p2
positional arguments:
p1 <type 'str'> p1 should be expected
p2 <type 'int'> p2 should be expected
optional arguments:
-h, --help show this help message and exit
--p3 P3 <type 'str'> p3 is optional use --p3 and defaults to d3
--p4 P4 <type 'str'> p3 is optional use --p4 and defaults to d4
$ ./ofTheEngagement.py -v --myFlag OfTheEngagment myMethod 1 2 --p3=3
{
"p2": 2,
"p3": "3",
"flag": true,
"p1": "1",
"verbose": true,
"p4": "d4",
"number": 0,
"choice": null
}
Metadata
Release files for Argumental 1.8
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 |
|---|---|---|---|---|
| Argumental-1.8.tar.gz | 10.4 kB | Without provenance | Details for Argumental-1.8.tar.gz |
Release files / Argumental-1.8.tar.gz
| Download URL | Argumental-1.8.tar.gz |
|---|---|
| Size | 10.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0d1216c5a02e87a9d810493301b7b58c1b7a8ea5cd14fa0c53e6b258cc905fcb
|
|
BLAKE2b-256 checksum How to use checksums |
e076e56bc0786955bbe27c714b3ff92c84f1762c2214e3df0cbc47db61015e4d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2
|
Security for Argumental 1.8
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.