{ "info": { "author": "simfu", "author_email": "simfu@free.fr", "bugtrack_url": null, "classifiers": [], "description": "=====\nPyonf\n=====\n--------------------------------------------------------------------------------------------\nEasy configuration parsing for your Python script, using command line argument or YAML file.\n--------------------------------------------------------------------------------------------\n\n\nQuickstart\n----------\n\nContent of ``myapp.py``:\n::\n #!/usr/bin/env python\n from pyonf import pyonf\n\n default_configuration = {\n 'user': 'foo',\n 'password': 'changeme',\n 'debug': False\n }\n conf = pyonf(default_configuration)\n print(conf)\n\nSet configuration from command line:\n::\n $ ./myapp.py --user simfu -d\n {'debug': True, 'password': 'changeme', 'user': 'simfu'}\n\nOr from YAML configuration file ``myconfig.yml``:\n::\n user: simfu\n password: secretpass\n\ngives:\n::\n $ ./myapp.py myconfig.yml\n {'debug': False, 'password': 'secretpass', 'user': 'simfu'}\n\nGet script usage:\n::\n $ ./myapp.py --help\n usage: myapp.py [-h] [--debug] [--password PASSWORD] [--user USER] [conf_file]\n \n Configuration file:\n conf_file Path to YAML configuration file (optional)\n \n Options:\n -h, --help show this help message and exit\n --debug, -d turn on \"debug\"\n --password PASSWORD, -p PASSWORD\n set \"password\" value, as str (default is changeme)\n --user USER, -u USER set \"user\" value, as str (default is foo)\n\n\nFeatures\n--------\n- Automatically build a command line or configuration file parser by providing a default configuration\n- Support for complex configuration schemes (e.g.: lists, dict of dict of ...), mandatory options\n- Default configuration can be provided as Python dict object, YAML string or YAML file\n- Compatible with Python 2 & 3\n\n\nMore Examples\n-------------\n\nAutomatic argparse'ing: help message, short and long parameters\n::\n $ ./myapp.py --help\n usage: myapp.py [-h] [--debug] [--password PASSWORD] [--user USER] [conf_file]\n \n Configuration file:\n conf_file Path to YAML configuration file (optional)\n \n Options:\n -h, --help show this help message and exit\n --debug, -d turn on \"debug\"\n --password PASSWORD, -p PASSWORD\n set \"password\" value, as str (default is changeme)\n --user USER, -u USER set \"user\" value, as str (default is foo)\n\n $ ./myapp.py -u simfu\n {'debug': False, 'password': 'changeme', 'user': 'simfu'}\n\n $ ./myapp.py --user simfu\n {'debug': False, 'password': 'changeme', 'user': 'simfu'}\n\n\nUse both configuration file and command line argument (the latter takes precedence)\n::\n $ ./myapp.py myconfig.yml -d\n {'debug': True, 'password': 'secretpass', 'user': 'simfu'}\n\n\nMultiple input for default configuration\n::\n # Using a dict\n default_configuration = {\n 'user': 'foo',\n 'password': 'changeme',\n 'debug': False\n }\n\n # Using a YAML String\n default_configuration = \"\"\"\n user: foo\n password: changeme\n debug: false\n \"\"\"\n conf = pyonf(defaulf_configuration)\n print(conf)\n\n # Using a YAML file\n default_configuration = \"/etc/myapp.conf\"\n conf = pyonf(defaulf_configuration)\n print(conf)\n\n\nSmart parsing of option type\n::\n default_configuration = \"\"\"\n user: foo\n password: changeme\n debug: false\n level: 3\n \"\"\"\n conf = pyonf(defaulf_configuration)\n print(conf)\n\ni.e.:\n::\n ./myapp.py -l 4 # OK\n ./myapp.py -l quatre # Will not work, level needs to be an integer\n\n # Boolean option does not need argument, its value will be switched\n ./myapp.py -d\n\n\nComplex configuration scheme\n::\n default_configuration = \"\"\"\n user: foo\n password: changeme\n suboptions:\n param1: value1\n param2: value2\n \"\"\"\n conf = pyonf(defaulf_configuration)\n print(conf)\n\nset \"sub-keys\" with:\n::\n $ ./myapp.py --suboptions-param1 my_new_value\n\nMandatory options:\n::\n default_configuration = \"\"\"\n user: foo\n password: changeme\n debug: false\n level: 3\n \"\"\"\n conf = pyonf(defaulf_configuration, mandatory_opts = ['user', 'password'])\n print(conf)\n\nyou have to defined ``user`` and ``password`` option:\n::\n $ ./my_app.py\n Error: \"user\" option is not set", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/simfu/pyonf", "keywords": "configuration option argparse yaml command line argument", "license": "GPL", "maintainer": null, "maintainer_email": null, "name": "pyonf", "package_url": "https://pypi.org/project/pyonf/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/pyonf/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/simfu/pyonf" }, "release_url": "https://pypi.org/project/pyonf/0.1/", "requires_dist": null, "requires_python": null, "summary": "Easy configuration from command line or YAML file", "version": "0.1" }, "last_serial": 2137986, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "da95fe4ccb8537cac3be4abc8f0f0515", "sha256": "500b48ee8d56a762d37a4f2c62cd019ff2cdaff9787e3ee3da982b69f15e6c8b" }, "downloads": -1, "filename": "pyonf-0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "da95fe4ccb8537cac3be4abc8f0f0515", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6304, "upload_time": "2016-05-28T08:52:08", "url": "https://files.pythonhosted.org/packages/95/44/7e83013aa6dba4d2b1a5305bb7d276b1d4c710c4d35c5de5071bf3c3c871/pyonf-0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "379836a4743d878fbde6059ef31cd88f", "sha256": "ad973485d55cae8f8110f517a35c9b02677d144225a26c77d08efa1796c8b357" }, "downloads": -1, "filename": "pyonf-0.1.tar.gz", "has_sig": false, "md5_digest": "379836a4743d878fbde6059ef31cd88f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4673, "upload_time": "2016-05-28T08:52:13", "url": "https://files.pythonhosted.org/packages/2e/11/798843053f241bef4e960467533eef483f44b113343559c5cc240c995a60/pyonf-0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "da95fe4ccb8537cac3be4abc8f0f0515", "sha256": "500b48ee8d56a762d37a4f2c62cd019ff2cdaff9787e3ee3da982b69f15e6c8b" }, "downloads": -1, "filename": "pyonf-0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "da95fe4ccb8537cac3be4abc8f0f0515", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6304, "upload_time": "2016-05-28T08:52:08", "url": "https://files.pythonhosted.org/packages/95/44/7e83013aa6dba4d2b1a5305bb7d276b1d4c710c4d35c5de5071bf3c3c871/pyonf-0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "379836a4743d878fbde6059ef31cd88f", "sha256": "ad973485d55cae8f8110f517a35c9b02677d144225a26c77d08efa1796c8b357" }, "downloads": -1, "filename": "pyonf-0.1.tar.gz", "has_sig": false, "md5_digest": "379836a4743d878fbde6059ef31cd88f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4673, "upload_time": "2016-05-28T08:52:13", "url": "https://files.pythonhosted.org/packages/2e/11/798843053f241bef4e960467533eef483f44b113343559c5cc240c995a60/pyonf-0.1.tar.gz" } ] }