{"id":15628986,"url":"https://github.com/pwwang/pyparam","last_synced_at":"2025-04-29T09:57:08.178Z","repository":{"id":62582347,"uuid":"190302318","full_name":"pwwang/pyparam","owner":"pwwang","description":"Powerful parameter processing for python","archived":false,"fork":false,"pushed_at":"2024-01-15T03:38:52.000Z","size":2644,"stargazers_count":8,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-03-15T10:22:42.167Z","etag":null,"topics":["argument-parser","argument-parsers","argument-parsing","parameters"],"latest_commit_sha":null,"homepage":"https://pwwang.github.io/pyparam","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pwwang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-05T01:04:52.000Z","updated_at":"2024-01-30T05:05:37.000Z","dependencies_parsed_at":"2024-01-15T05:04:26.353Z","dependency_job_id":null,"html_url":"https://github.com/pwwang/pyparam","commit_stats":{"total_commits":192,"total_committers":3,"mean_commits":64.0,"dds":0.06770833333333337,"last_synced_commit":"8529a384f5615b959f617d182e1c0af4b0de7f1c"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwwang%2Fpyparam","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwwang%2Fpyparam/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwwang%2Fpyparam/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwwang%2Fpyparam/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pwwang","download_url":"https://codeload.github.com/pwwang/pyparam/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251122759,"owners_count":21539742,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["argument-parser","argument-parsers","argument-parsing","parameters"],"created_at":"2024-10-03T10:25:12.788Z","updated_at":"2025-04-29T09:57:08.162Z","avatar_url":"https://github.com/pwwang.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pyparam\n\n[![pypi][1]][2] [![pypi][10]][11] [![codacy quality][4]][6] [![codacy quality][7]][6] [![docs][12]][5] ![github action][3] ![pyver][8]\n\nPowerful parameter processing\n\n\u003e [!Warning]\n\u003e This package is deprecated. Please use [argx](https://github.com/pwwang/argx) instead.\n\n## Features\n\n- Command line argument parser (with subcommand support)\n- Rich type support, including `py`, `json`, `namespace`, etc.\n- Type overwriting for parameters from command line\n- Arbitrary parsing arguments from command line\n- Automatic help page assembling\n- Help page customization\n- Callbacks for option values\n- Parameter loading from configuration files\n\n## Installation\n\n```shell\npip install -U pyparam\n```\n\n## Documentation\n\n[https://pwwang.github.io/pyparam/][5]\n\n## Basic usage\n\n`example.py`\n\n```python\nfrom rich import print\nfrom pyparam import Params\n# program name, otherwise sys.argv[0]\nparams = Params(prog='pyparam', desc=\"An example for %(prog)s\")\n# adding parameters\nparams.add_param('i, int', type=int,\n                 desc=\"An integer argument.\")\nparams.add_param('float', default=0.1, # type float implied\n                 desc=\"A float argument.\")\nparams.add_param('str', type=str,\n                 desc=\"A str argument.\")\nparams.add_param('flag', type=bool,\n                 desc=\"A flag argument.\")\nparams.add_param('c,count', type='count',\n                 desc=\"A count argument.\")\nparams.add_param('a', type='auto', type_frozen=False,\n                 desc=\"Value will be automatically casted.\")\nparams.add_param('py', type='py',\n                 desc=\"Value will be evaluated by `ast.literal_eval`.\")\nparams.add_param('json', type='json',\n                 desc=\"Value will be converted using `json.loads`.\")\nparams.add_param('list', type='list',\n                 desc=\"Values will be accumulated.\")\nparams.add_param('path', type='path', required=True,\n                 desc=\"Value will be casted into `pathlib.Path`.\",\n                 callback=( # check if path exists\n                     lambda path: ValueError('File does not exist.')\n                     if not path.exists() else path\n                 ))\nparams.add_param('choice', type='choice', default='medium',\n                 choices=['small', 'medium', 'large'],\n                 desc=\"One of {choices}.\")\nparams.add_param('config.ncores', default=1, # namespace config implied\n                 argname_shorten=False,\n                 desc='Number of cores to use.')\n\nprint(vars(params.parse()))\n```\n\nTry it out:\n\n```sh\npython example.py\n```\n\n![help](./pyparam-help.png)\n\n```sh\n$ python example.py \\\n    -i2 \\\n    --float 0.5 \\\n    --str abc \\\n    -ccc \\\n    -a:int 1 \\\n    --py \"{1,2,3}\" \\\n    --json \"{\\\"a\\\": 1}\" \\\n    --list 1 2 3 \\\n    --choice large \\\n    --path . \\\n    --config.ncores 4\n```\n\n```python\n{\n    'i': 2,\n    'int': 2,\n    'float': 0.5,\n    'str': 'abc',\n    'flag': False,\n    'c': 3,\n    'count': 3,\n    'a': 1,\n    'py': {1, 2, 3},\n    'json': {'a': 1},\n    'list': [1, 2, 3],\n    'path': PosixPath('.'),\n    'choice': 'large',\n    'config': Namespace(ncores=4)\n}\n```\n\nTry more features with:\n\n```sh\npython -m pyparam\n```\n\n## Shell completions\n\nHere is how the command completion in `fish` works:\n\n![pyparam-completions](./pyparam-completions.gif)\n\nCheck the [documentation][13], as well as the `__main__.py` to see how the completion works.\n\n[1]: https://img.shields.io/pypi/v/pyparam.svg?style=flat-square\n[2]: https://pypi.org/project/pyparam/\n[3]: https://img.shields.io/github/actions/workflow/status/pwwang/pyparam/build.yml?style=flat-square\n[4]: https://img.shields.io/codacy/grade/370aa0074595445188b01dc8dba47fe5.svg?style=flat-square\n[5]: https://pwwang.github.io/pyparam/\n[6]: https://app.codacy.com/gh/pwwang/pyparam/dashboard\n[7]: https://img.shields.io/codacy/coverage/370aa0074595445188b01dc8dba47fe5.svg?style=flat-square\n[8]: https://img.shields.io/pypi/pyversions/pyparam.svg?style=flat-square\n[9]: https://raw.githubusercontent.com/pwwang/pyparam/master/docs/static/help.png\n[10]: https://img.shields.io/github/tag/pwwang/pyparam.svg?style=flat-square\n[11]: https://github.com/pwwang/pyparam\n[12]: https://img.shields.io/github/actions/workflow/status/pwwang/pyparam/docs.yml?label=docs\u0026style=flat-square\n[13]: https://pwwang.github.io/pyparam/shellCompletion/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpwwang%2Fpyparam","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpwwang%2Fpyparam","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpwwang%2Fpyparam/lists"}