{ "info": { "author": "Max Zheng", "author_email": "maxzheng.os @t gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Topic :: Software Development" ], "description": "localconfig\n===========\n\nA simplified interface to `ConfigParser`_ using dot notion with data type / comment support.\n\nFeature Summary\n===============\n\n* Simple access to config using dot notion and iterators\n* Full compatibility with `ConfigParser`_ ini formats (as that is used as the backend)\n* Data type support by intelligently guessing the data types based on value on read.\n* Multiple config source input (read from string, file pointer, file, or list of them)\n* Full comment support / retention on save\n* Lazy reading of config sources for performance (only read when a config value is accessed)\n\n.. _ConfigParser: https://docs.python.org/3/library/configparser.html\n\nQuick Start Tutorial\n====================\n\nTo install::\n\n pip install localconfig\n\nLet's say we have a script named `program` with the following config in `~/.config/program`:\n\n.. code-block:: ini\n\n [Web Server]\n # Server host\n host = 0.0.0.0\n\n # Server port\n port = 8080\n\n # Debug logging\n debug = off\n\nTo read the config, simply do:\n\n.. code-block:: python\n\n from localconfig import config\n\n start_server(config.web_server.host, config.web_server.port, config.web_server.debug)\n\n # Or use get method:\n # start_server(config.get('Web Server', 'host'),\n # config.get('Web Server', 'port'),\n # config.get('web_server', 'debug')) # Yes, 'web_server' also works here!\n #\n # Or if the config is in docstring, read from it:\n # config.read(__doc__)\n #\n # Or if the config file is elsewhere:\n # config.read('/etc/path/to/config.ini') # Non-existing file is ignored\n #\n # Or read from a list of sources\n # config.read(['string config', file_path, file_pointer, io.StringIO('config')])\n #\n # Or create another instance for another config:\n # from localconfig import LocalConfig\n # config2 = LocalConfig('/etc/path/to/another/config.ini')\n\nConfigs are read in the order they are called using `config.read()`, but the config file passed to the `LocalConfig()`\nconstructor (defaults to `~/.config/$script_name`) will be read last before the first access to config values, which\nallows us to read configs from various locations, like default configs from a string that is checked in with the code,\nwhile allowing them to be overrriden from the config file that is passed to the constructor.\n\nNow, let's do some inspection:\n\n.. code-block:: python\n\n # Iterate over sections and their keys/values\n for section in config:\n print(section) # Web Server\n\n for key, value in config.items(section):\n print(key, value, type(value)) # host 0.0.0.0 \n # port 8080 \n # debug False \n\n sections = list(config) # ['Web Server']\n\n # Iterate over keys/values\n for key, value in config.web_server:\n print(key, value, type(value)) # Same output as above config.items()\n\n items = list(config.web_server) # [('host', '0.0.0.0'), ('port', 8080), ('debug', False)]\n items = dict(config.web_server) # {'host': '0.0.0.0', 'port': 8080, 'debug': False}\n\n # Check if a section or key is set - any non-existing section or key defaults to None.\n if config.web_server or config.no_such_section:\n pass\n\n if config.web_server and (config.web_server.port or config.web_server.no_such_key):\n pass\n\nTo add a section and set a value:\n\n.. code-block:: python\n\n config.add_section('App Server', comment='Settings for application server')\n config.app_server.host = 'localhost'\n\n # Use `set` if you want to set a comment\n config.set('App Server', 'port', 9090, comment='App server port')\n\n # Set value for the DEFAULT section (default value for all other sections)\n config.env = 'prod'\n\nTo write the config:\n\n.. code-block:: python\n\n config.save()\n\n # Or simply get the config as a string:\n # config_str = str(config)\n #\n # Or save to a different location:\n # config.save('/path/to/save/to.ini')\n\nIf we open `~/.config/program` now, we would see::\n\n [DEFAULT]\n\n env = prod\n\n\n [Web Server]\n\n # Server host\n host = 0.0.0.0\n\n # Server port\n port = 8080\n\n # Debug logging\n debug = off\n\n\n # Settings for application server\n [App Server]\n\n host = localhost\n\n # App server port\n port = 9090\n\nSupported Data Types\n====================\n\nData type is guessed based on the value and converted on read.\n\nThe following types are supported:\n\n======= ===========================================\nType Example Value\n======= ===========================================\nint 1\nfloat 2.0\nbool true false yes no on off (case insensitive)\nNone none (case insensitive)\nstr Any other value not matched by above\n======= ===========================================\n\nRemote Config\n=============\n\nCheck out: https://pypi.python.org/pypi/remoteconfig\n\nMore\n====\n\n| Documentation: http://localconfig.readthedocs.org/\n|\n| PyPI Package: https://pypi.python.org/pypi/localconfig\n| GitHub Source: https://github.com/maxzheng/localconfig\n| Report Issues/Bugs: https://github.com/maxzheng/localconfig/issues\n|\n| Connect: https://www.linkedin.com/in/maxzheng\n| Contact: maxzheng.os @t gmail.com\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/maxzheng/localconfig", "keywords": "configuration config ConfigParser data type support", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "localconfig", "package_url": "https://pypi.org/project/localconfig/", "platform": "", "project_url": "https://pypi.org/project/localconfig/", "project_urls": { "Homepage": "https://github.com/maxzheng/localconfig" }, "release_url": "https://pypi.org/project/localconfig/1.1.3/", "requires_dist": null, "requires_python": ">=3.6", "summary": "A simplified interface to ConfigParser using dot notion with data type / comment support.", "version": "1.1.3" }, "last_serial": 5269514, "releases": { "0.4.1": [ { "comment_text": "", "digests": { "md5": "ae79fd9f8ebf839899b5ed34afaa255b", "sha256": "c11269cf32a41c524a72f59b72408691531971bd786fc15604786427fb7e9c8d" }, "downloads": -1, "filename": "localconfig-0.4.1.tar.gz", "has_sig": false, "md5_digest": "ae79fd9f8ebf839899b5ed34afaa255b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15287, "upload_time": "2015-01-17T23:56:46", "url": "https://files.pythonhosted.org/packages/d7/54/6cf6cbcfb3bc06d664dbeb727379ad841bc592117b1ad3d1f824c5a5ddcb/localconfig-0.4.1.tar.gz" } ], "0.4.2": [ { "comment_text": "", "digests": { "md5": "b7cfd7bae0e7691ce09cabd01758a36d", "sha256": "8feffd1c5b3f69c4054379bad018651242e51090bccbdc254d44d0cc2439c674" }, "downloads": -1, "filename": "localconfig-0.4.2.tar.gz", "has_sig": false, "md5_digest": "b7cfd7bae0e7691ce09cabd01758a36d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15707, "upload_time": "2015-08-14T19:22:52", "url": "https://files.pythonhosted.org/packages/63/3f/c7784815b13c5bb09778b607b93f7a85037901c5ad85ece45e590eb3a7be/localconfig-0.4.2.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "f0e4b1ee3beb9d182d35134fd2d77f85", "sha256": "96417069eeca3685f5639239242d6b7afea7bee2047d0fc94a9d5eb05f87fb0e" }, "downloads": -1, "filename": "localconfig-1.0.1.tar.gz", "has_sig": false, "md5_digest": "f0e4b1ee3beb9d182d35134fd2d77f85", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16038, "upload_time": "2017-04-27T13:36:33", "url": "https://files.pythonhosted.org/packages/ed/0a/3bcbe4eeb3c292ecbd02770058e31c772218898d30d95942997c89a443e2/localconfig-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "ad4e33221a75e374ef3616e968c2f7f7", "sha256": "04ceac9d3d48584bc9d3160a232a624c1608e2793c93f4f779ec2b1984993dac" }, "downloads": -1, "filename": "localconfig-1.0.2.tar.gz", "has_sig": false, "md5_digest": "ad4e33221a75e374ef3616e968c2f7f7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16055, "upload_time": "2017-05-25T06:07:10", "url": "https://files.pythonhosted.org/packages/d3/18/88a247533d56fb13ce86956faad1d3d3eeed684947eee440930f60da39d5/localconfig-1.0.2.tar.gz" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "9a7486323d1d6205a85f358f5961cee1", "sha256": "713211f3cce584272bbf27a4fda39ac97766395889080bc5e8b90bc4b4251edf" }, "downloads": -1, "filename": "localconfig-1.1.0.tar.gz", "has_sig": false, "md5_digest": "9a7486323d1d6205a85f358f5961cee1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16291, "upload_time": "2018-05-15T05:58:02", "url": "https://files.pythonhosted.org/packages/1f/b2/976127c768f205406b01554dcdcbb6697e56ed567a126c6d6e1f14541b81/localconfig-1.1.0.tar.gz" } ], "1.1.1": [ { "comment_text": "", "digests": { "md5": "60b69ad904c81cf1f3ee6f8b10c4b688", "sha256": "3a0ab6c3329edc30145344b87d494c72c163bab1c1d9335c016ffcabfc4e2f0f" }, "downloads": -1, "filename": "localconfig-1.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "60b69ad904c81cf1f3ee6f8b10c4b688", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7398, "upload_time": "2018-06-05T20:15:24", "url": "https://files.pythonhosted.org/packages/cd/8a/3dcc7ccd95ad351cbe0aa5df2655ac67d6773379ed5cc94d3599e2ec0e9c/localconfig-1.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "352ea11998e9a77c10a256c0fb89c4f8", "sha256": "501bb4bfe1a3e1365417645df8a0f0efd89a160ca37f1a4f2184244b5d94b43b" }, "downloads": -1, "filename": "localconfig-1.1.1.tar.gz", "has_sig": false, "md5_digest": "352ea11998e9a77c10a256c0fb89c4f8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16381, "upload_time": "2018-06-05T20:15:25", "url": "https://files.pythonhosted.org/packages/85/47/609a00fb488089817e4639f2b2f4a86d54a4d323260fff715735f9d4ad0b/localconfig-1.1.1.tar.gz" } ], "1.1.2": [ { "comment_text": "", "digests": { "md5": "1b28ee84e5d2d6cd21c9b5ec4897e025", "sha256": "b9d10e1f28a73b62196f9bb36b770d28c14321362042d612979fd27c3af6115b" }, "downloads": -1, "filename": "localconfig-1.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "1b28ee84e5d2d6cd21c9b5ec4897e025", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 7477, "upload_time": "2018-06-19T06:46:40", "url": "https://files.pythonhosted.org/packages/85/92/4c023b40a4d3b238ba1ec17321cc7ec88423dfaa7e30377a0cdf3602f1b1/localconfig-1.1.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e49b57abcf8b8fd8325b55150eb818ab", "sha256": "ee8f30969b5d11b9cf2e382daa5eb0ff59817b60757930212e6f951458af655c" }, "downloads": -1, "filename": "localconfig-1.1.2.tar.gz", "has_sig": false, "md5_digest": "e49b57abcf8b8fd8325b55150eb818ab", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 16591, "upload_time": "2018-06-19T06:46:43", "url": "https://files.pythonhosted.org/packages/f2/d0/275b941306eadb59e0993bce0fde6065499aefa1bbdd38d7856201a51498/localconfig-1.1.2.tar.gz" } ], "1.1.3": [ { "comment_text": "", "digests": { "md5": "3b62d10ba272e7e2fa2d988463c2df9e", "sha256": "7fa7102f29ab91fd34bc7ac20aeadfa0c7cddfcc308fdade0a2fa33aef9195d1" }, "downloads": -1, "filename": "localconfig-1.1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "3b62d10ba272e7e2fa2d988463c2df9e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 7678, "upload_time": "2019-05-14T21:44:06", "url": "https://files.pythonhosted.org/packages/07/0d/46d310f8c744e8642ed79f381151c0fab5ae8ff62e7cf2f0afed4db700e8/localconfig-1.1.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "25d7138bb2ac6252dad1f327baa0463f", "sha256": "6aeca93ef04f882e4199d2b7ccc02f76230ba60b9c71635398fc4ad5c03d079c" }, "downloads": -1, "filename": "localconfig-1.1.3.tar.gz", "has_sig": false, "md5_digest": "25d7138bb2ac6252dad1f327baa0463f", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 17266, "upload_time": "2019-05-14T21:44:07", "url": "https://files.pythonhosted.org/packages/f7/2e/c8d5a75ae8b98fb1bdbcdb6a99c909eef56149c3e833236450c1331d1476/localconfig-1.1.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "3b62d10ba272e7e2fa2d988463c2df9e", "sha256": "7fa7102f29ab91fd34bc7ac20aeadfa0c7cddfcc308fdade0a2fa33aef9195d1" }, "downloads": -1, "filename": "localconfig-1.1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "3b62d10ba272e7e2fa2d988463c2df9e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 7678, "upload_time": "2019-05-14T21:44:06", "url": "https://files.pythonhosted.org/packages/07/0d/46d310f8c744e8642ed79f381151c0fab5ae8ff62e7cf2f0afed4db700e8/localconfig-1.1.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "25d7138bb2ac6252dad1f327baa0463f", "sha256": "6aeca93ef04f882e4199d2b7ccc02f76230ba60b9c71635398fc4ad5c03d079c" }, "downloads": -1, "filename": "localconfig-1.1.3.tar.gz", "has_sig": false, "md5_digest": "25d7138bb2ac6252dad1f327baa0463f", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 17266, "upload_time": "2019-05-14T21:44:07", "url": "https://files.pythonhosted.org/packages/f7/2e/c8d5a75ae8b98fb1bdbcdb6a99c909eef56149c3e833236450c1331d1476/localconfig-1.1.3.tar.gz" } ] }