generic_parser
A parser for arguments and config files that also allows direct Python input and recursive parsing
Science Score: 46.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
✓Academic publication links
Links to: zenodo.org -
✓Committers with academic emails
2 of 6 committers (33.3%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (15.1%) to scientific vocabulary
Keywords
Keywords from Contributors
Repository
A parser for arguments and config files that also allows direct Python input and recursive parsing
Basic Info
- Host: GitHub
- Owner: pylhc
- License: mit
- Language: Python
- Default Branch: master
- Homepage: https://pylhc.github.io/generic_parser/
- Size: 6.73 MB
Statistics
- Stars: 2
- Watchers: 10
- Forks: 3
- Open Issues: 0
- Releases: 9
Topics
Metadata Files
README.md
Generic Parser
The package provides an all-around parser for arguments and config-files. The creation of the arguments is similar to the ones from argparse, but the input can then be either from command line, a config file or directly from python.
See the API documentation for details.
Installing
Installation is easily done via pip. The package is then used as generic_parser.
bash
python -m pip install generic-parser
One can also install in a conda environment via the conda-forge channel with:
bash
conda install -c conda-forge generic_parser
Example Usage:
Content of myscript.py
```python
from generic_parser import entrypoint, EntryPointParameters
def getarguments(): args = EntryPointParameters() args.addparameter(name="first", flags=["-f", "--first"], help="First Parameter, an int", choices=[1, 2, 3], type=int, required=True, ) args.add_parameter(name="second", flags=["-s", "--second"], help="Second Parameter, a string", type=str, default="default", required=False, ) return args
@entrypoint(get_arguments()) def main(opt, unknown): print(opt.first == 1) print(opt.second == "default")
if name == 'main': main() ```
Commandline
Calling that script with python myscript.py -f 1 -s "test" will result in:
True
False
It is assumed, that this is the standard mode of operation for your functions.
Config File
Further, one can also use a config file config.ini containing:
[Section]
first = 2
second = "Hello"
and run the script with python myscript.py --entry_cfg config.ini leading to
False
False
Config files are very useful if you want to rerun your code with the same or similar parameters.
Especially the declaration of a [DEFAULT] section can be helpful.
For further information about config files, check the python Config Parser.
Python
Or call the function directly from python code:
python
if __name__ == '__main__':
main(first=1, second="World")
True
False
This is incredibly helpful if one wants to write python-wrappers around entrypoint-functions, and does not want to resort to commandline calls from python.
Note that also in this case all variables are validated, courtesy of the dict_parser.
dict_parser provides even multi-level dictionary checking functionality,
which is not used in the Entrypoint, but can be handy in other use-cases.
License
This project is licensed under the MIT License - see the LICENSE.md file for details
Owner
- Name: PyLHC
- Login: pylhc
- Kind: organization
- Location: CERN
- Website: https://pylhc.github.io/
- Repositories: 26
- Profile: https://github.com/pylhc
Organisation for the OMC Team at CERN, in BE-ABP-LNO.
GitHub Events
Total
- Delete event: 1
- Issue comment event: 1
- Push event: 2
- Pull request review event: 5
- Pull request review comment event: 10
- Create event: 1
Last Year
- Delete event: 1
- Issue comment event: 1
- Push event: 2
- Pull request review event: 5
- Pull request review comment event: 10
- Create event: 1
Committers
Last synced: almost 3 years ago
Top Committers
| Name | Commits | |
|---|---|---|
| JoschD | j****y@g****m | 17 |
| Mäel Le Garrec | m****c@c****h | 16 |
| Felix Soubelet | 1****t@u****m | 11 |
| mihofer | m****r@c****h | 3 |
| JoschD | 2****D@u****m | 2 |
| Maël Le Garrec | m****l@l****g | 2 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 23
- Total pull requests: 36
- Average time to close issues: about 2 months
- Average time to close pull requests: about 22 hours
- Total issue authors: 4
- Total pull request authors: 4
- Average comments per issue: 0.35
- Average comments per pull request: 0.22
- Merged pull requests: 33
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 1
- Average time to close issues: N/A
- Average time to close pull requests: 1 day
- Issue authors: 0
- Pull request authors: 1
- Average comments per issue: 0
- Average comments per pull request: 1.0
- Merged pull requests: 1
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- JoschD (14)
- Mael-Le-Garrec (6)
- fsoubelet (2)
- mihofer (1)
Pull Request Authors
- Mael-Le-Garrec (16)
- fsoubelet (13)
- JoschD (5)
- mihofer (3)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 2
-
Total downloads:
- pypi 1,300 last-month
-
Total dependent packages: 5
(may contain duplicates) -
Total dependent repositories: 1
(may contain duplicates) - Total versions: 13
- Total maintainers: 1
pypi.org: generic-parser
A parser for arguments and config-files that also allows direct python input.
- Homepage: https://github.com/pylhc/generic_parser
- Documentation: https://generic-parser.readthedocs.io/
- License: MIT
-
Latest release: 1.1.1
published about 3 years ago
Rankings
Maintainers (1)
conda-forge.org: generic_parser
A parser for arguments and config files that also allows direct Python input.
- Homepage: https://github.com/pylhc/generic_parser
- License: MIT
-
Latest release: 1.1.0
published over 3 years ago
Rankings
Dependencies
- actions/checkout v3 composite
- actions/setup-python v4 composite
- actions/checkout v3 composite
- actions/setup-python v4 composite
- JamesIves/github-pages-deploy-action 3.7.1 composite
- actions/checkout v3 composite
- actions/setup-python v4 composite
- actions/checkout v3 composite
- actions/setup-python v4 composite
- actions/checkout v3 composite
- actions/setup-python v4 composite