generic_parser

A parser for arguments and config files that also allows direct Python input and recursive parsing

https://github.com/pylhc/generic_parser

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

commandline-calls generic-parser ini-parser parser python

Keywords from Contributors

accelerator-physics cern frequency-analysis mad-x omc optics optics-measurements particle-accelerators plots
Last synced: 6 months ago · JSON representation

Repository

A parser for arguments and config files that also allows direct Python input and recursive parsing

Basic Info
Statistics
  • Stars: 2
  • Watchers: 10
  • Forks: 3
  • Open Issues: 0
  • Releases: 9
Topics
commandline-calls generic-parser ini-parser parser python
Created over 6 years ago · Last pushed 7 months ago
Metadata Files
Readme Changelog License Zenodo

README.md

Generic Parser

Cron Testing Code Climate coverage Code Climate maintainability (percentage) <!-- GitHub last commit --> PyPI Version GitHub release Conda-forge Version DOI

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

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

All Time
  • Total Commits: 51
  • Total Committers: 6
  • Avg Commits per committer: 8.5
  • Development Distribution Score (DDS): 0.667
Past Year
  • Commits: 3
  • Committers: 3
  • Avg Commits per committer: 1.0
  • Development Distribution Score (DDS): 0.667
Top Committers
Name Email 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
enhancement (8) bug (6) documentation (3) good first issue (2) CI / CD (1)
Pull Request Labels
enhancement (6) bug (4) CI / CD (3) documentation (2) question (1) Type: Feature (1)

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.

  • Versions: 11
  • Dependent Packages: 4
  • Dependent Repositories: 1
  • Downloads: 1,300 Last month
Rankings
Dependent packages count: 1.8%
Downloads: 7.4%
Average: 15.6%
Forks count: 19.1%
Dependent repos count: 21.7%
Stargazers count: 27.8%
Maintainers (1)
Last synced: 6 months ago
conda-forge.org: generic_parser

A parser for arguments and config files that also allows direct Python input.

  • Versions: 2
  • Dependent Packages: 1
  • Dependent Repositories: 0
Rankings
Dependent packages count: 28.8%
Dependent repos count: 34.0%
Average: 44.9%
Forks count: 54.2%
Stargazers count: 62.4%
Last synced: 6 months ago

Dependencies

.github/workflows/coverage.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
.github/workflows/cron.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
.github/workflows/documentation.yml actions
  • JamesIves/github-pages-deploy-action 3.7.1 composite
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
.github/workflows/publish.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
.github/workflows/tests.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
setup.py pypi