{ "info": { "author": "Dustin Lacewell", "author_email": "dlacewell@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "deconf\n======\n\nAn object system for building declarative configurations in Python.\n\nA class that has rich(ish) keyword-parameter handling, including \n[explicit handling of required parameters](https://github.com/dustinlacewell/deconf#pass-through-parameters),\n[declaration of parameter dependencies](https://github.com/dustinlacewell/deconf#dependency-parameters) and\n[basic type-checking](https://github.com/dustinlacewell/deconf#type-checked-parameters).\n\nKeyword parameter processing will be performed for any method on the\n`Deconfigurable` that is decorated with the `@parameter` decorator. Each of these\ndecorated methods performs the processing specific to that parameter. The \nreturned value is then assigned on the appropriately named attribute.\n\n\n >>> @parameter('foo')\n >>> def handle_foo(self, value):\n ... return value\n\n\nPass-Through Parameters:\n------------------------\n\nIf your parameter doesn't require any special treatment and should simply\nbe stored on the Deconfigurable a shorthand can be used. Simply decorate \na parameter method that passes, and `value` will be used as is.\n\n\n >>> @parameter('foo')\n >>> def handle_foo(self, value):\n ... pass\n\n\nRequired Parameters:\n--------------------\n\nParameters are required by default. This means that a `RequiredParameterError`\nwill be raised if the `Deconfigurable.__init__` doesn't recieve the designated\nnamed argument. \n\nPassing `default=` to `@parameter` will prevent the parameter from\nraising `RequiredParameterError` if the parameter isn't provided a value.\n\n\n >>> @parameter('foo', default='bar')\n >>> def handle_foo(self, value):\n ... pass\n\n\nType-Checked Parameters:\n------------------------\n\nA basic mechanism is supplied for ensuring that the passed parameter value\nis of a specific type. By supplying a type value to the `@parameter`'s\n`ensure_type` keyword arguement any value passed in will be validated with\nan *isinstance check*.\n\n\n >>> @parameter('bars', ensure_type=list)\n >>> def handle_bars(self, value):\n ... pass\n\n\nDependency Parameters:\n----------------------\n \nSometimes we will want to defer processing of a parameter until some other\nparameter has been processed first. To do so, simply pass a list of\ndependencies, `depends_on`, to `@parameter`.\n\n\n >>> @parameter('foo')\n >>> def handle_foo(self, foo):\n ... pass\n\n >>> @parameter('bar', depends_on=('foo', ))\n >>> def handle_bar(self, bar):\n ... # offset bar by foo\n ... return bar + self.foo \n\n\nContrived Example:\n------------------\n\n class Person(Deconfigurable):\n @staticmethod\n def format_name(cls, name):\n return name.strip().lower().capitalize()\n\n @parameter('first_name', ensure_type=str)\n def handle_first(self, name): \n return Person.format_name(name)\n\n @parameter('last_name', ensure_type=str)\n def handle_last(self, name):\n return Person.format_name(name)\n\n @parameter('age', ensure_type=int)\n def handle_age(self, value): pass\n\n @parameter('registered_to_vote', ensure_type=bool, depends_on=('age',))\n def handle_vote(self, value):\n if self.age < 18:\n value = False\n return value\n\n >>> me = Person(\n ... first_name='Dustin',\n ... last_name='Lacewell',\n ... age=25, registered_to_vote=True,\n ... )\n >>> print me.first_name, ' can vote: ', me.registered_to_vote\n Dustin can vote: True\n\n >>> kid = Person(\n ... first_name='Some Kid',\n ... last_name='Smith',\n ... age=12, registered_to_vote=True,\n ... )\n >>> print kid.first_name, ' can vote: ', kid.registered_to_vote\n SomeKid can vote: False\n\n\n\nExample from Spidersilk (twisted.web config lib):\n-------\n\n from twisted.web.static import File\n from twisted.web.proxy import ReverseProxyResource\n\n from spidersilk import Domain, Httpd\n\n application = Httpd(\n port = 80,\n default = 'ldlework.com',\n domains = [\n Domain(\n hostname='ldlework.com',\n resource=File('/var/txweb/ldlework.com'),\n ),\n Domain(\n hostname='lichen.ldlework.com',\n resource=ReverseProxyResource('localhost', 8088, ''),\n ),\n ],\n )\n\n\nWhere Domain is implemented as:\n\n class Domain(Deconfigurable):\n @parameter('hostname', ensure_type=str)\n def _arg_hostname(self, hostname):\n pass\n\n @parameter('resource', ensure_type=twisted.web.resource.Resource)\n def _arg_resource(self, resource):\n pass", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/dustinlacewell/deconf", "keywords": null, "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "deconf", "package_url": "https://pypi.org/project/deconf/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/deconf/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/dustinlacewell/deconf" }, "release_url": "https://pypi.org/project/deconf/0.1.1/", "requires_dist": null, "requires_python": null, "summary": "An object system for building declarative configurations in Python.", "version": "0.1.1" }, "last_serial": 788873, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "3ca630ea045bada2277e6a33b6716aa6", "sha256": "a0f8c8a1e5d5eb840963b2d29e3a4f8468b29a1add2f59e72e7682242f07dceb" }, "downloads": -1, "filename": "deconf-0.1.tar.gz", "has_sig": false, "md5_digest": "3ca630ea045bada2277e6a33b6716aa6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3613, "upload_time": "2013-04-25T17:08:16", "url": "https://files.pythonhosted.org/packages/2e/a9/5307cb60bcd6d497ee5fb4ed9d287b2c4e7b5b29009a6b91b9c4ad45413d/deconf-0.1.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "9e6ec115b8c7dfe27a082c2288596b2e", "sha256": "8adfcbeb3c3dbacbbd21d45ea32b2523e664999034c341b17f7b820cc7baa369" }, "downloads": -1, "filename": "deconf-0.1.1.tar.gz", "has_sig": false, "md5_digest": "9e6ec115b8c7dfe27a082c2288596b2e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3972, "upload_time": "2013-05-02T01:29:35", "url": "https://files.pythonhosted.org/packages/39/0f/4b1bd02f7645e2b2842b45004bd1b4c2bc3a44115737f79a906fd31b6bae/deconf-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "9e6ec115b8c7dfe27a082c2288596b2e", "sha256": "8adfcbeb3c3dbacbbd21d45ea32b2523e664999034c341b17f7b820cc7baa369" }, "downloads": -1, "filename": "deconf-0.1.1.tar.gz", "has_sig": false, "md5_digest": "9e6ec115b8c7dfe27a082c2288596b2e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3972, "upload_time": "2013-05-02T01:29:35", "url": "https://files.pythonhosted.org/packages/39/0f/4b1bd02f7645e2b2842b45004bd1b4c2bc3a44115737f79a906fd31b6bae/deconf-0.1.1.tar.gz" } ] }