{ "info": { "author": "Mohammad Alghafli", "author_email": "thebsom@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Programming Language :: Python :: 3.5" ], "description": ":Date: 2018-10-06\n:Version: 1.0.2\n:Authors:\n * Mohammad Alghafli \n\nMultiple configuration directories for your program.\nThis library is useful if you have the following situation: you have a config\ndirectory where you store default configuration and another config directory\nwhere you store user custom configuration. When a user runs your program for the\nfirst time, no files exist in the user config directory and you want to read\neverything from the default config directory. When you write a config file, it\nmust always be written in the user config directory.\nThis library does this for you. You specify user config directory and any more\ndirectories you want to use for default config files. When you open a file for\nreading, the library opens the file from the user config directory if it exists.\nOtherwise, it searches for the file in the default config directories. When you\nopen a file for writing, it is always opened in the user config directory. A\ntypical usage example is below::\n \n from codi import *\n\n #assume we have 2 config directories:\n # * default-cfg/\n # * user-cfg/\n #\n #in other words, we have the following directory structure:\n #\n #\n #default-cfg/\n #|\n #--path/\n # |\n # --to/\n # |\n # |-file.txt\n # |\n # --file.bin\n #\n #\n #\n #user-cfg/\n\n\n #user config dir\n user_dir = 'user-cfg/'\n #default config dir\n default_dir = 'default-cfg/'\n\n #create a Codi object. you can give more than 2 dirs if you need.\n config_dirs = Codi(user_dir, default_dir)\n\n #read a file. args are same as builtin open\n #will first try to open `user-cfg/path/to/file.txt`. because the file does\n #not exist, will go to the next config dir and open\n #`default-cfg/path/to/file.txt`.\n f = config_dirs.open('path/to/file.txt')\n print(f.read())\n f.close()\n\n #write a file.\n #will always write in `user-cfg/path/to/file.txt`. any parent directories\n #that do not exist will be created\n f = config_dirs.open('path/to/file.txt', 'w')\n print('hello world', file=f)\n f.close()\n\n #convinience method to read data\n #text. default encoding is utf8\n #will open `user-cfg/path/to/file.txt` because it exists from our previous\n #write operation.\n print(config_dirs.read('path/to/file.txt', encoding='ascii'))\n #binary\n #will open `default-cfg/path/to/file.bin`\n print(config_dirs.read('path/to/file.bin', text=False))\n\n #convinience method to write data\n #text. default encoding is utf8\n #will always write in `user-cfg/path/to/file.txt`.\n config_dirs.write('path/to/file.txt', 'hello world', encoding='ascii')\n #binary\n #again, will always write in `user-cfg/path/to/file.bin`.\n config_dirs.write('path/to/file.bin', b'some binary data')\n \nThe library also provides `Config` class which acts as a dict for config values.\nIt adds the ability to set default values.\n\n --------\n Tutorial\n --------\n Check out codi tutorial at http://codi.readthedocs.io/", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/alghafli/codi", "keywords": "multiple,configuration", "license": "", "maintainer": "", "maintainer_email": "", "name": "codi", "package_url": "https://pypi.org/project/codi/", "platform": "", "project_url": "https://pypi.org/project/codi/", "project_urls": { "Homepage": "https://github.com/alghafli/codi" }, "release_url": "https://pypi.org/project/codi/1.0.2/", "requires_dist": null, "requires_python": "", "summary": "Multiple configuration directories for your program.", "version": "1.0.2" }, "last_serial": 4360068, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "c41b814a1dc519577908aa5d7b688f1d", "sha256": "12b2759df4a4ac76b69294ea121d1bea3945535af1d95f713b1d547c3d18bd83" }, "downloads": -1, "filename": "codi-1.0.0.tar.gz", "has_sig": false, "md5_digest": "c41b814a1dc519577908aa5d7b688f1d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16303, "upload_time": "2018-10-06T08:28:51", "url": "https://files.pythonhosted.org/packages/6f/b2/aa50e987e1fb8dc563f219620ffb0fde9bfc4fff713c7b83b7963014c031/codi-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "45e2a7122dc7342599969179e5958f66", "sha256": "02c5465fe9d342bf25c4746e00bd072d3741efec99112203ce01a65122f8e795" }, "downloads": -1, "filename": "codi-1.0.1.tar.gz", "has_sig": false, "md5_digest": "45e2a7122dc7342599969179e5958f66", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16288, "upload_time": "2018-10-08T17:53:43", "url": "https://files.pythonhosted.org/packages/3d/a1/2066dd9242b2397a38b23cedaa18f481d505f620f63896e27bf2ee2e67dd/codi-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "2e2c34a77258a996fc5c72e2dcc0056d", "sha256": "8fc0665d3abfbe9f1f2b799f386b7f6ddba2ce00788733322e1b14a62f1de5da" }, "downloads": -1, "filename": "codi-1.0.2.tar.gz", "has_sig": false, "md5_digest": "2e2c34a77258a996fc5c72e2dcc0056d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16287, "upload_time": "2018-10-10T13:48:00", "url": "https://files.pythonhosted.org/packages/d0/6e/6625547ba238ce08e5a56e67cb4123ff60f0db8b8bcc60b733d3420da86e/codi-1.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "2e2c34a77258a996fc5c72e2dcc0056d", "sha256": "8fc0665d3abfbe9f1f2b799f386b7f6ddba2ce00788733322e1b14a62f1de5da" }, "downloads": -1, "filename": "codi-1.0.2.tar.gz", "has_sig": false, "md5_digest": "2e2c34a77258a996fc5c72e2dcc0056d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16287, "upload_time": "2018-10-10T13:48:00", "url": "https://files.pythonhosted.org/packages/d0/6e/6625547ba238ce08e5a56e67cb4123ff60f0db8b8bcc60b733d3420da86e/codi-1.0.2.tar.gz" } ] }