{ "info": { "author": "Gabriel Chamon", "author_email": "gchamon@live.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# argson\nArguments from JSON\n\nDeploy arguments into a python program from a JSON config file\n\n## Installation\n`pip install argson`\n\n`python3 setup.py install`\n\nCurrently not supporting Python 2. Should work on all Python 3 versions. Tested with Python 3.7.1\n\n## Basic usage\n**config/arguments.json**\n```\n[\n {\n \"flags\": [\"--string-to-print\"]\n }\n]\n```\n**config/defaults.json**\n```\n{\n \"string_to_print\": \"foo\"\n}\n```\n**main.py**\n```\nimport argson\n\narguments = argson.parse_file_and_arguments()\nprint(arguments.string_to_print)\n```\n\n`$ python main.py # -> foo`\n\n`$ python main.py --string bar # -> bar`\n\n## Documentation\n**argson.parse_file_and_arguments**\n\nUsed to automatically parse the arguments file, self file and defaults file, generating an object with the flags from the arguments file\n\n*Arguments*:\n\n| Argument | Type | Default | Description |\n| - | - | - | - |\n| config_file | str | config/arguments.json | where arguments are read |\n| self_file | str | config/self.json | configurations for [argparse.ArgumentParser](https://docs.python.org/3/library/argparse.html#argumentparser-objects) |\n| defaults_file | str | config/defaults.json | default values for arguments |\n| working_dir | str | os.getcwd() | where the program will look for files to load |\n| no_builtins | bool | False | disables built-in flags |\n| verbose | bool | False | disables error messages |\n\n*Returns*: object with attributes from `config_file` flags\n\n**argson.parse_config_file**\n\nUsed when there is need to manipulate the instance of `ArgumentParser` and the array of remaining arguments to parse\n\n*Arguments*: same as `argson.parse_file_and_arguments`\n\n*Returns*: Tuple[ArgumentParser, List[string]]. The instance of ArgumentParser and a list of the remaining arguments to be parsed. If the return value is assigned like `argument_parser, remaining_args = argson.parse_config_file()` the remaining args can be then parsed as in `arguments = argument_parser.parse_args(remaining_args)`, which is basically what `parse_file_and_arguments` does.\n\n**config_file**\n\nA json file containing an array of objects with at least one key called `flags`. Those are the flags with which the program will be called in \"hyphen-case\" starting with `--`, like in the example. Extra keys can be passed to express the flag behaviour or help string that will be displayed when the program is called with `--help`. Those are the same attributes that can be passed to [ArgumentParser.add_argument](https://docs.python.org/3/library/argparse.html#the-add-argument-method)\n\n**self_file**\n\nA json file containing information about the main ArgumentParser instance. Those are the same attributes supported by [argparse.ArgumentParser](https://docs.python.org/3/library/argparse.html#argumentparser-objects)\n\n**defaults_file**\n\nA json file with the default values of the flags in `snake_case`. That is, if an argument has a flag `string-to-parse`, the default value must be read as `string_to_parse`. Refer to the example above.\n\n### why decouple configs_file and defaults_file?\nIt is best to decouple those files so we can programatically select the defaults source, maintaining the same configurations for the flags. That is sometimes necessary when deploying scripts that have different defaults when running in development and in production environments.\n\n### Contributing\n\n* fork and clone this repo\n* install pipenv\n* `pipenv install`\n* code like there is no tomorrow\n* submit PR\n* ??\n* we profit together\n\nOpen for suggestions!", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/gchamon/argson", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "argson", "package_url": "https://pypi.org/project/argson/", "platform": "any", "project_url": "https://pypi.org/project/argson/", "project_urls": { "Homepage": "https://github.com/gchamon/argson" }, "release_url": "https://pypi.org/project/argson/0.2.1/", "requires_dist": null, "requires_python": ">3.6", "summary": "Manage arguments from a JSON file", "version": "0.2.1" }, "last_serial": 5367453, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "efeb2314dd36bb77ecf1414db71ac0c7", "sha256": "6722bebc46fb77eed96a9ad76cdbd9abcd5244f9270b40d6d71dcf572d7fb708" }, "downloads": -1, "filename": "argson-0.1.0.tar.gz", "has_sig": false, "md5_digest": "efeb2314dd36bb77ecf1414db71ac0c7", "packagetype": "sdist", "python_version": "source", "requires_python": ">3.6", "size": 3597, "upload_time": "2018-12-16T23:50:31", "url": "https://files.pythonhosted.org/packages/05/2d/d73575c64230295faf58c0c38fe1be2ffb1fc3f26c58153e5f7d5e4e3c01/argson-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "df6df9d91d3d5b22e77c1165964fb8f7", "sha256": "6bc248db15cfd50d0451600a10d405b83701b8eb9d827797a69e66b4c3558bb9" }, "downloads": -1, "filename": "argson-0.1.1.tar.gz", "has_sig": false, "md5_digest": "df6df9d91d3d5b22e77c1165964fb8f7", "packagetype": "sdist", "python_version": "source", "requires_python": ">3.6", "size": 3681, "upload_time": "2018-12-17T00:08:06", "url": "https://files.pythonhosted.org/packages/50/5d/4981c45fa5bee8b8a311cbe21e120a25ba7ba73965458e21d0ed9ea116da/argson-0.1.1.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "eb85bd43455ae3d8a7a32a98dc3928ef", "sha256": "015f12bbe85ab08726c3b59ab35b117e37d553e3d00864e9c8ffa72fd6131c87" }, "downloads": -1, "filename": "argson-0.2.0.tar.gz", "has_sig": false, "md5_digest": "eb85bd43455ae3d8a7a32a98dc3928ef", "packagetype": "sdist", "python_version": "source", "requires_python": ">3.6", "size": 3797, "upload_time": "2019-06-06T14:16:09", "url": "https://files.pythonhosted.org/packages/e4/64/ea897fa6fa04dc71621c79b137503ed38aa583b3bf215f54cc6f3366fa74/argson-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "cab1e4188590f9d1030ab8ec67c37dcc", "sha256": "cd1a836022d6e1b8c4e79a6025c6af0640db0c14c102ab5c146b25766422ae73" }, "downloads": -1, "filename": "argson-0.2.1.tar.gz", "has_sig": false, "md5_digest": "cab1e4188590f9d1030ab8ec67c37dcc", "packagetype": "sdist", "python_version": "source", "requires_python": ">3.6", "size": 3812, "upload_time": "2019-06-06T14:23:21", "url": "https://files.pythonhosted.org/packages/04/b3/99434fac84c3fe5345b3121f47be637897cbd0f577cc82ad861985d9df8e/argson-0.2.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "cab1e4188590f9d1030ab8ec67c37dcc", "sha256": "cd1a836022d6e1b8c4e79a6025c6af0640db0c14c102ab5c146b25766422ae73" }, "downloads": -1, "filename": "argson-0.2.1.tar.gz", "has_sig": false, "md5_digest": "cab1e4188590f9d1030ab8ec67c37dcc", "packagetype": "sdist", "python_version": "source", "requires_python": ">3.6", "size": 3812, "upload_time": "2019-06-06T14:23:21", "url": "https://files.pythonhosted.org/packages/04/b3/99434fac84c3fe5345b3121f47be637897cbd0f577cc82ad861985d9df8e/argson-0.2.1.tar.gz" } ] }