{ "info": { "author": "Shrikant Sharat", "author_email": "shrikantsharat.k@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "Figs\n====\n\nFigs is a library for reading *ini* like configuration files easily. Figs\nleverages the ``ConfigParser`` module from python's standard libraries.\n\nI personally don't like the ``ConfigParser`` API very much, so I wrote this. The\nidea is that the developer should have little overhead in thinking when using\nthis library, i.e., an intuitive API.\n\nUsage\n=====\n\nIf you are familiar with ``PyYaml`` or the standard library's ``json`` modules,\nthe following should be quite familiar to you.\n\nTo load a configuration, use the ``load``/``loads`` functions. The following\nreturn the same::\n\n >>> # Takes a filename\n >>> conf = figs.load('config.ini')\n\n >>> # or a file-like object\n >>> conf = figs.load(open('config.ini'))\n\n >>> # Takes a string to be parsed\n >>> conf = figs.loads('''\\\n [universe]\n answer = 42\n is_active = yes\n status = expanding\n ''')\n\nAnd, to *dump* configuration::\n\n >>> # Takes a filename\n >>> figs.dump(conf, 'config.ini')\n\n >>> # or a file-like object\n >>> figs.dump(conf, open('config.ini'))\n\n >>> # Dump to string\n >>> figs.dumps(conf)\n [universe]\n answer = 42\n is_active = yes\n status = expanding\n\n >>> # You can also dump just a section\n >>> figs.dumps(conf.universe)\n answer = 42\n is_active = yes\n status = expanding\n\nThose are the only functions in the figs module that you should be concerned\nwith.\n\nOnce you have the config object, how'd you use it? Surprise surprise! Anyway you\nfeel comfortable :)\n\nDictification\n-------------\n\nI know, you just want a dict of properties from the config file and be done with\nit. Lets see if you can guess how this can be done?::\n\n >>> # Returns a dict like {'section-name':
}\n >>> dict(conf)\n\n >>> # Returns a dict like {'key': }\n >>> dict(conf.universe)\n\nYou should keep in mind that ``dict`` on does *not* automatically do a ``dict``\non its Section objects. The ``TypeableStr`` class is a subclass of ``unicode``\nwith a few methods added (``as_bool``, ``as_int`` and ``as_float``).\n\nIf you want a dict of dicts, though, you can get that too.::\n\n >>> figs.as_dict(conf)\n\n >>> # or when loading\n >>> conf = figs.load('config.ini', as_dict=True)\n\nThe ``loads`` method also takes the ``as_dict`` argument. Note that the\n``as_dict`` *has* to be a keyword argument.\n\nAccesses\n--------\n\n::\n\n >>> conf.universe.answer\n u'42'\n >>> conf.universe.answer.as_int\n 42\n >>> conf.universe.is_active\n u'yes'\n >>> conf.universe.is_active.as_bool\n True\n >>> conf.universe.status\n u'expanding'\n >>> conf.universe['status']\n u'expanding'\n\nSimilary to ``as_int`` as shown above, there are also ``as_bool`` (boolean\nconversion done similar to how ``ConfigParser.getboolean`` does) and\n``as_float``.\n\nCheck for presence\n------------------\n\n::\n\n >>> 'universe' in conf\n True\n >>> 'multiverse' in conf\n False\n >>> 'answer' in conf.universe\n True\n >>> 'is_active' in conf.universe\n True\n >>> 'is-active' in conf.universe\n False\n\nModifying configs\n-----------------\n\nSet new options...::\n\n >>> conf.universe.is_active = False\n >>> conf.universe.planet_maker = 'Magrathea'\n >>> conf.universe['earth-owners'] = 'mice'\n >>> figs.dumps(conf)\n [universe]\n answer = 42\n is_active = false\n status = expanding\n planet_maker = Magrathea\n earth-owners = mice\n\n...on new sections::\n\n >>> conf.multiverse.is_active = True\n >>> figs.dumps(conf)\n [universe]\n answer = 42\n is_active = false\n status = expanding\n\n [multiverse]\n is_active = true\n\nDeleting\n--------\n\nThe API is very boring isn't it?::\n\n >>> del conf.universe.answer\n >>> del conf.multiverse\n\nNow what?\n=========\n\nWell, if you have a life, get on with it. Seriously, there's nothing else to\nreading config files here.\n\nMeta\n====\n\nAuthor\n------\n\nShrikant Sharat (http://sharats.me). `@sharat87`_ on twitter.\n\n.. _@sharat87: http://twitter.com/sharat87\n\nLicense\n-------\n\nMIT License (http://mit.sharats.me).\n\nContributing\n------------\n\nCode is available at the `github repository`_. Clone. Modify. Send pull request.\nIf the modification is fairly large, I prefer you open a `github issue`_ first\nto discuss it.\n\n.. _github repository: https://github.com/sharat87/figs\n.. _github issue: https://github.com/sharat87/figs/issues\n\nChangelog\n---------\n\n0.1.2\n Move to github.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://figs.sharats.me", "keywords": null, "license": "MIT - http://mit.sharats.me", "maintainer": null, "maintainer_email": null, "name": "figs", "package_url": "https://pypi.org/project/figs/", "platform": "any", "project_url": "https://pypi.org/project/figs/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://figs.sharats.me" }, "release_url": "https://pypi.org/project/figs/0.1.2/", "requires_dist": null, "requires_python": null, "summary": "A towel wrapped ConfigParser API.", "version": "0.1.2" }, "last_serial": 791951, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "5f716596a11fd5040738405b5cb1d710", "sha256": "d8b2e6fa072817fb0a423c0d682e70405c300a001b0254b56b206c5c5f55fd9a" }, "downloads": -1, "filename": "figs-0.1.tar.gz", "has_sig": false, "md5_digest": "5f716596a11fd5040738405b5cb1d710", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6218, "upload_time": "2012-02-29T12:14:43", "url": "https://files.pythonhosted.org/packages/c4/8d/9e28da20d99ea859b287c103006820975f6425155246294f6bcd22f17cfb/figs-0.1.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "9bcb3da85418cf894db3bbd00d361b61", "sha256": "e913405ea392538a769b071fd4f18b00e512ea9adf6cd669a75ab1d8a83a695f" }, "downloads": -1, "filename": "figs-0.1.1.tar.gz", "has_sig": false, "md5_digest": "9bcb3da85418cf894db3bbd00d361b61", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6225, "upload_time": "2012-02-29T12:15:29", "url": "https://files.pythonhosted.org/packages/02/d4/db81ea167457c138707f913df57020976dcade0d77ba5369684a6db6e56e/figs-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "3c31c3fe6f48f25bc5271bc83bed8da7", "sha256": "91e99fd6d291c8149e017f1f0007a30ced860ec6f89eb684ae1e004de408ec1a" }, "downloads": -1, "filename": "figs-0.1.2.tar.gz", "has_sig": false, "md5_digest": "3c31c3fe6f48f25bc5271bc83bed8da7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6238, "upload_time": "2012-05-08T14:13:14", "url": "https://files.pythonhosted.org/packages/45/c4/e2c636b3589175a5abf59ab660d51599bb6bf83de45e86419006e594edf8/figs-0.1.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "3c31c3fe6f48f25bc5271bc83bed8da7", "sha256": "91e99fd6d291c8149e017f1f0007a30ced860ec6f89eb684ae1e004de408ec1a" }, "downloads": -1, "filename": "figs-0.1.2.tar.gz", "has_sig": false, "md5_digest": "3c31c3fe6f48f25bc5271bc83bed8da7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6238, "upload_time": "2012-05-08T14:13:14", "url": "https://files.pythonhosted.org/packages/45/c4/e2c636b3589175a5abf59ab660d51599bb6bf83de45e86419006e594edf8/figs-0.1.2.tar.gz" } ] }