{ "info": { "author": "Johan Nestaas", "author_email": "johannestaas@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Environment :: Console", "Environment :: MacOS X", "Environment :: Win32 (MS Windows)", "Environment :: X11 Applications :: Qt", "Operating System :: MacOS :: MacOS X", "Operating System :: Microsoft :: Windows", "Operating System :: POSIX", "Programming Language :: Python" ], "description": "doconf\n======\n\nConfiguration specified through documentation.\n\nInstallation\n------------\n\nFrom the project root directory::\n\n $ python setup.py install\n\nOr from pip::\n\n $ pip install doconf\n\nAPI Usage\n---------\n\ndoconf is relatively simple to use. Simply install it, then write out a config module with\na class in a similar format::\n\n from doconf import DoconfConfig\n\n\n class Config(DoconfConfig):\n '''\n name: echo_server\n\n {default}\n\n [server]\n HOST (str:\"127.0.0.1\"): this is the host passed to the app, by default serves locally\n PORT (int:8080): by default it serves on port 8080.\n DEBUG (bool:true): Debug mode is on by default\n\n [logger]\n LOG_LEVEL (str): the log level, one of debug/info/warning/error. This is required since it has no default\n LOG_PATH: we didn't specify a type so it is by default a string, and required.\n LOG_FORMAT (str:null): None by default\n\n {production}\n\n [server]\n HOST (str:\"0.0.0.0\"): serve to the world\n PORT (int:8081): serve on port 8081\n DEBUG (bool:false): default to false for production\n\n [logger]\n LOG_LEVEL (str:\"INFO\"): default to INFO in production\n LOG_PATH (str:\"/var/log/echo_server.log\"): put in /var/log/ in production\n LOG_FORMAT (str:null): don't care still\n '''\n pass\n\n\n config = Config.load()\n\n # And now we can access values from it with dictionary access.\n log_level = config['logger']['LOG_LEVEL']\n\n # It's case insensitive on section and variable names.\n if 'log_path' in config['logger']:\n print('this is true, case insensitive')\n\n\nIn the above example, we can see that we specified a subclass of DoconfConfig, and it's a config for\nan app named \"echo_server\".\nWe specify a {default} environment first (required), and a few sections and variables with their types and\ndefault values.\nThen we specify a {production} environment next and make a few changes to defaults.\n\nUsing that, we can now load our config wth ``Config.load()`` below the class definition. It'll automatically\nlook for echo_server.{conf,cfg,config} in serveral locations depending on the environment, and validate the\nconfig it finds and load it and coerce the values into the types specified. It'll raise an error if a required\nvalue (missing default value) isn't defined, or if the type is wrong. To figure out which paths it'd look for\na config file, check the ``find`` command under the CLI Usage section.\n\nWe simply run ``config = Config.load()`` to discover and load our config, and it'll preload it with the default\nvalues based on the default environment. We can also specify the default environment like::\n\n config = Config.load(env='production')\n assert config['server']['HOST'] == '0.0.0.0'\n\nAnd we can pass in a custom path to a config like so::\n\n config = Config.load(path='/my/custom/path.config')\n\nIt provides simple dictionary access, and is case-insensitive when matching against section or variable names.\n\n\nCLI Usage\n---------\n\nYou can use the CLI tools to find where it locates its config (``doconf find ``), you can generate\nexample documented configs using ``doconf generate ``, and you can validate configuration files\nwith ``doconf validate ``.\n\nUse --help/-h to view info on the arguments::\n\n $ doconf --help\n\n usage: doconf [-h] {find,validate,generate} ...\n\n positional arguments:\n {find,validate,generate}\n find find where the config file would be loaded from\n validate validate your config files match the format\n generate generate example config files\n\n optional arguments:\n -h, --help show this help message and exit\n\n\nFind will show you where the config would be loaded from in the current environment::\n\n $ doconf find --help\n usage: doconf find [-h] class_path\n\n positional arguments:\n class_path path to the module and class, eg:\n custom_example.config:CustomConfig\n\n optional arguments:\n -h, --help show this help message and exit\n\nHere we can see where the environment would discover a config specified by the class CustomConfig in the directory\nexamples/my_example_app/config.py::\n\n $ doconf find examples.my_example_app.config:CustomConfig\n\nValidate will find your config and parse it, tell you whether it has all required variables and show you the values::\n\n $ doconf validate --help | sed 's/ / /g'\n usage: doconf validate [-h] [--config-path CONFIG_PATH] [--env ENV] class_path\n\n positional arguments:\n class_path path to the module and class, eg:\n custom_example.config:CustomConfig\n\n optional arguments:\n -h, --help show this help message and exit\n --config-path CONFIG_PATH, -c CONFIG_PATH\n direct path to config\n --env ENV, -e ENV the environment to use\n\nThis will validate that the config passed via --config-path matches the format, and we will see the values it sets::\n\n $ doconf validate examples.my_example_app.config:CustomConfig --config-path examples/my_example_app/my_example_app.cfg\n\nGenerate will dump example configuration files for you to provide as examples::\n\n $ doconf generate --help\n usage: doconf generate [-h] [--out OUT] class_path\n\n positional arguments:\n class_path path to the module and class, eg:\n custom_example.config:CustomConfig\n\n optional arguments:\n -h, --help show this help message and exit\n --out OUT, -o OUT output directory, default to current directory\n\nThis will dump out an example documented config for the default environment and the production environment::\n\n $ doconf generate examples.my_example_app.config:CustomConfig --out .\n\nRelease Notes\n-------------\n\n:0.2.0:\n - Handle multiline descriptions.\n - Add simple example in ./examples\n - Fix issue with sys.path when running doconf on local python modules.\n:0.1.2:\n - Better example in API usage.\n:0.1.1:\n - Extended README.rst with an example.\n:0.1.0:\n - Implemented main logic, including parser and DoconfConfig class.\n - Implemented CLI tools: find, validate, generate.\n - Added examples.\n:0.0.1:\n - Project created.", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/johannestaas/doconf", "keywords": "documentation configuration config conf cfg", "license": "GPLv3", "maintainer": "", "maintainer_email": "", "name": "doconf", "package_url": "https://pypi.org/project/doconf/", "platform": "", "project_url": "https://pypi.org/project/doconf/", "project_urls": { "Homepage": "https://github.com/johannestaas/doconf" }, "release_url": "https://pypi.org/project/doconf/0.2.0/", "requires_dist": null, "requires_python": "", "summary": "Configuration specified through documentation, supporting multiple formats.", "version": "0.2.0" }, "last_serial": 5256929, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "e49b9878b93edcab4c61a3d77aee21a1", "sha256": "7cd6487b53c4323bcb15cd753dbc77ceb0eb1b2c20d04868a1636549bb9aaa6c" }, "downloads": -1, "filename": "doconf-0.0.1.tar.gz", "has_sig": false, "md5_digest": "e49b9878b93edcab4c61a3d77aee21a1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2447, "upload_time": "2019-05-05T07:38:20", "url": "https://files.pythonhosted.org/packages/c5/96/18cca42534bd820223f0104159bf7060736146e68fdd4064e908325b9478/doconf-0.0.1.tar.gz" } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "23946c21ae1811ecb617ee27144ffda1", "sha256": "059cb7284a50a311c3f1764270850a1aba293a8bb891ff9b69631113850ad403" }, "downloads": -1, "filename": "doconf-0.1.0.tar.gz", "has_sig": false, "md5_digest": "23946c21ae1811ecb617ee27144ffda1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7734, "upload_time": "2019-05-10T23:35:05", "url": "https://files.pythonhosted.org/packages/31/4d/79a0821ef24db089114171cffb364dd6e3375e133011f677c078383b7de6/doconf-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "8a73f5b58d40fbbd6bf164ac8536fa25", "sha256": "7df13881b48c24b8f4274fd950094dbf7654c36b120fc452b1de71f03836592a" }, "downloads": -1, "filename": "doconf-0.1.1.tar.gz", "has_sig": false, "md5_digest": "8a73f5b58d40fbbd6bf164ac8536fa25", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8802, "upload_time": "2019-05-10T23:49:31", "url": "https://files.pythonhosted.org/packages/a4/1c/189ad6da7fd619f4b76c236c27a19188cdab10fa72b1f0effca03ea9efa9/doconf-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "5b7b94743f7caeb0098323d524a4d68e", "sha256": "d5c707feac0427b0f49fad61e4a08025c587f618282991f9134ef0ab26d6d66e" }, "downloads": -1, "filename": "doconf-0.1.2.tar.gz", "has_sig": false, "md5_digest": "5b7b94743f7caeb0098323d524a4d68e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9299, "upload_time": "2019-05-10T23:55:02", "url": "https://files.pythonhosted.org/packages/2f/63/5c4142ae9a46b689e3fb7a09a65ca418579c535396d2f873b45495d8dc5e/doconf-0.1.2.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "09cf148339e84d87bb566a53eda79627", "sha256": "10defbecbe103076f3b9ca46cf619eede620b6aa137fa7db5666e8bcfce47919" }, "downloads": -1, "filename": "doconf-0.2.0.tar.gz", "has_sig": false, "md5_digest": "09cf148339e84d87bb566a53eda79627", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9544, "upload_time": "2019-05-11T18:52:11", "url": "https://files.pythonhosted.org/packages/b8/33/bc42ecad2d9b1e6baae819c08f26ca7a02bfa308d04f33e3f8f796093573/doconf-0.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "09cf148339e84d87bb566a53eda79627", "sha256": "10defbecbe103076f3b9ca46cf619eede620b6aa137fa7db5666e8bcfce47919" }, "downloads": -1, "filename": "doconf-0.2.0.tar.gz", "has_sig": false, "md5_digest": "09cf148339e84d87bb566a53eda79627", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9544, "upload_time": "2019-05-11T18:52:11", "url": "https://files.pythonhosted.org/packages/b8/33/bc42ecad2d9b1e6baae819c08f26ca7a02bfa308d04f33e3f8f796093573/doconf-0.2.0.tar.gz" } ] }