A simple package for a flag parsing
Project description
Flag library
Simple flag processing for Python
Supported types:
| type | implemented |
|---|---|
| int | True |
| float | True |
| str | True |
| bool | True |
| list | True |
| custom | True |
Installation
$ pip install easy-flagger
Simple usage example
# python example.py -f 10.3
from flagger import Flagger
if __name__ == "__main__":
flag = Flagger()
f_flag = flag.parse_flag("-f", float)
print(f_flag) # >> 10.3
List usage example
# python example.py -l 1,2,3
from flagger import Flagger
if __name__ == "__main__":
flag = Flagger()
l_flag = flag.parse_flag("-l", list, sep=",")
print(l_flag) # >> ['1', '2', '3']
Checks flag for existence example
# python example.py --flag
from flagger import Flagger
if __name__ == "__main__":
flag = Flagger()
l_flag = flag.parse_flag("--flag")
print(l_flag) # >> True
Using custom types flags
# python example.py -e Aerendyl
from flagger import Flagger
class Elven:
allowed = {
"aerendyl": 1,
"erendriel": 2,
"galadriel": 3
}
@staticmethod
def check(value: str):
value = value.lower()
is_allowed = value in Elven.allowed
if not is_allowed:
raise ValueError("the language is that of Mordor, which I will not utter here")
return Elven.allowed.get(value)
if __name__ == "__main__":
flag = Flagger()
flagger.types.add_parser(Elven, Elven.check)
elf = flagger.parse_flag("-e", Elven)
print(elf) # >> Aerendyl
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file easy_flagger-2.0.0.tar.gz.
File metadata
- Download URL: easy_flagger-2.0.0.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e16c86b61bdc05469568059cf3da7466776050097ef1077850e73958eb02b316
|
|
| MD5 |
40baa3a2376a90731283126a92fa80b5
|
|
| BLAKE2b-256 |
0b814f55b75d3452be4919a6de8ba11944a445a4e602bb557e056a72acd82ab1
|
Provenance
The following attestation bundles were made for easy_flagger-2.0.0.tar.gz:
Publisher:
release-action.yml on Doneeel/easy-flagger
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
easy_flagger-2.0.0.tar.gz -
Subject digest:
e16c86b61bdc05469568059cf3da7466776050097ef1077850e73958eb02b316 - Sigstore transparency entry: 162253701
- Sigstore integration time:
-
Permalink:
Doneeel/easy-flagger@a4b5f575abc0f0a829396e53ba4dd6aa8f26a4ea -
Branch / Tag:
refs/tags/v.2.0.0 - Owner: https://github.com/Doneeel
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-action.yml@a4b5f575abc0f0a829396e53ba4dd6aa8f26a4ea -
Trigger Event:
release
-
Statement type:
File details
Details for the file easy_flagger-2.0.0-py3-none-any.whl.
File metadata
- Download URL: easy_flagger-2.0.0-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3bb71239b5a3f4797d420a4914058664b84b159bfc9be14ab505d56ae4da69cf
|
|
| MD5 |
13d3570bf6d6d97231b88fd3474fe34d
|
|
| BLAKE2b-256 |
8e134678d989769b1eb59742e1dfe4e59c3b57d73b344007c9933a6f6d788bfb
|
Provenance
The following attestation bundles were made for easy_flagger-2.0.0-py3-none-any.whl:
Publisher:
release-action.yml on Doneeel/easy-flagger
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
easy_flagger-2.0.0-py3-none-any.whl -
Subject digest:
3bb71239b5a3f4797d420a4914058664b84b159bfc9be14ab505d56ae4da69cf - Sigstore transparency entry: 162253702
- Sigstore integration time:
-
Permalink:
Doneeel/easy-flagger@a4b5f575abc0f0a829396e53ba4dd6aa8f26a4ea -
Branch / Tag:
refs/tags/v.2.0.0 - Owner: https://github.com/Doneeel
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-action.yml@a4b5f575abc0f0a829396e53ba4dd6aa8f26a4ea -
Trigger Event:
release
-
Statement type: