Installing
pip3 install throttle
Battleship
import flagopt
usage = '-x [spot] -y [spot]'
flags = flagopt.trace(usage)
content = '-x C -y 7'
args = flagopt.snip(flags, content)
print('hit at', args['-x'], args['-y'])
Actions
import flagopt
flags = {
'-move': {
'-x': 'distance',
'-y': 'distance'
},
'-craft': 'recipe',
'-scavenge': {
'-target': 'resource',
'-finish': {
'-time': 'hours',
'-time': 'amount'
}
},
'-rest': 'hours',
'-target': 'human | animal'
}
# show how to use this
usage = flagopt.draw(flags)
content = (
# move right linearly
'-move -x 10 '
# then move diagonally right and down;
# no need to explicitly pass the first flag (-x)
'-move 5 -y -5 '
# backslash is used as an escape character;
# -target will be ignored during the first parse scan
# and the backslash will be removed so that -target can
# be considered during the next scan for -scavenge;
# multiple backslashed can be used to achieve other
# amounts of iterations for this effect
'-scavenge \-target wood '
# arguments can be passed multiple times (-time);
# scavenge for 3 hours and 60 more wood after that
'-finish -time 3 -limit 60 '
# or until 5 hours have passed
'-finish -time 5'
# rest for 4 hours, craft a tent, rest for another 3;
# there is no space between 5 and -rest (line above);
# spaces do not matter for flags and are stripped away
# unless there is an escape character before / after
'-rest 4 '
# you can pass empty flags,
# their presence is indicated with an empty string
'--debug '
# im bad at coming up with examples
'-craft spear '
# especially when they involve games
'-target rabbit '
# time to sleep now
'-rest 3'
)
args = flagopt.snip(flags, content)
moves = args.getall('-move')
print(moves)
Release files for flagopt 0.1.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 | |
|---|---|---|---|
| flagopt-0.1.1.tar.gz | 4.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| flagopt-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.3 kB
Release files / flagopt-0.1.1.tar.gz
| Download URL | flagopt-0.1.1.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8ec81dfb5fb45bb671e605bbce45f8a43a18938da1b882336869653661a84b0b
|
|
BLAKE2b-256 checksum How to use checksums |
995048bcfeb10463e0798265c50e8edbb5f146f68cf3fe51cc719400830b0a1f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.8.0rc1
|
Release files / flagopt-0.1.1-py3-none-any.whl
| Download URL | flagopt-0.1.1-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a9d849c543a3c41a90cfa44309c7edfcf2e89c3880245426dad936b8a1f6eb68
|
|
BLAKE2b-256 checksum How to use checksums |
733edcfe02e15216dbd0bff5abb0da53d646d718ce9e346ee88c328e07d0d299
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.8.0rc1
|