{ "info": { "author": "Bernhard Posselt", "author_email": "dev@bernhard-posselt.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", "Programming Language :: Python :: 3 :: Only", "Topic :: Software Development :: Libraries" ], "description": "===========================================================\nPymple - A Simple Inversion of Control Container For Python\n===========================================================\n\n.. image:: https://travis-ci.org/BernhardPosselt/pymple.svg?branch=master\n :target: https://travis-ci.org/BernhardPosselt/pymple\n\nWhy\n===\nIf you search for Inversion of Control containers for Python you often encounter the argument \"Python is dynamic and does not need those things that static languages need\". This is partly true.\n\nDependency Injection and Inversion of Control is a pattern and not a language feature. It not only makes your code easier to test, but also way more readable. The dependencies are clearly noted in the constructor and your IDEs will give you autocompletion support. If you need to test a class, it is clear where and how to pass in the mocks.\n\nTherefore Inversion and Control and Dependency Injection (which go hand in hand) should also be practiced in dynamic languages. If you think this is not viable, check out `AngularJS `_ which also makes use of the above mentioned patterns in a dynamic programming language, namely JavaScript.\n\nFor further information watch `Google's Clean Code Talks `_\n\nLimitations\n===========\nPymple does currently not support:\n\n* Threadsafety\n* Lifetimes\n\nInstallation\n============\nThis library is a Python 3.4+ library. On Python 3.4 however the **typings** package is required.\n\nInstall it via pip for Python 3::\n\n sudo pip3 install pymple\n\nUsage\n=====\nPymple knows two types of parameters:\n\n* Singletons: A singleton is a **callable** that is executed once and the result is saved so future calls to the build method will return the same instance\n* Factories: A factory is **callable** that is executed again every time it is accessed\n\nBy default Pymple tries to resolved a singleton based on the annotated type, e.g.:\n\n.. code:: python\n\n from pymple import Container\n\n class A:\n def __init__(self):\n pass\n\n class B:\n def __init__(self, param: A):\n self.a = A\n\n container = Container()\n b = container.resolve(B)\n isinstance(b.a, A) == True\n\nOverriding The Default Behavior\n===============================\nHowever you can also override it by defining it explicitly:\n\n.. code:: python\n\n container = Container()\n ccontainer.register(B, lambda c: B('hi'))\n\n b = container.resolve(B)\n b.a == 'hi'\n\nThe first passed in variable to the lambda is the container instance itself, so you can also resolve other classes on it:\n\n.. code:: python\n\n container = Container()\n ccontainer.register(B, lambda c: B(c.resolve(A)))\n\n b = container.resolve(B)\n isinstance(b.a, A) == True\n\nRegistering Factories\n=====================\nIf you want to register a factory instead of a singleton, simple pass False as the second parameter:\n\n.. code:: python\n\n container = Container()\n ccontainer.register(B, lambda c: B('hi'), False)\n\n b = container.resolve(B)\n c = container.resolve(B)\n b != c\n\nAliasing\n========\nSometimes a type interface uses an abstract class as type annotation. In that case you can simply define an alias:\n\n.. code:: python\n\n container = Container()\n ccontainer.alias(ConcreteClass, AbstractClass)\n\n clazz = container.resolve(AbstractClass)\n isinstance(clazz, ConcreteClass) == True\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Raydiation/pymple", "keywords": "pymple", "license": "GPL", "maintainer": "", "maintainer_email": "", "name": "pymple", "package_url": "https://pypi.org/project/pymple/", "platform": "", "project_url": "https://pypi.org/project/pymple/", "project_urls": { "Homepage": "https://github.com/Raydiation/pymple" }, "release_url": "https://pypi.org/project/pymple/0.1.3/", "requires_dist": null, "requires_python": "", "summary": "A simple Inversion of Control container", "version": "0.1.3" }, "last_serial": 2355306, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "0644e03717412b057fa8f46ce07893d6", "sha256": "30b5eecd74f550f9341f65762e73c821e9bad6d576108ca32dfbda9fc632d025" }, "downloads": -1, "filename": "pymple-0.0.1.tar.gz", "has_sig": false, "md5_digest": "0644e03717412b057fa8f46ce07893d6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14248, "upload_time": "2015-01-08T13:41:02", "url": "https://files.pythonhosted.org/packages/08/05/888353d9c94e573dc7c8fe3e6a1d52d534be606da99d6713c51de61c0130/pymple-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "9db7be924fa816741f1eda26d75d041d", "sha256": "2ff64f8d0c479adb491ddc508a8d1a7287a8030b16c625d17a68203fe6174650" }, "downloads": -1, "filename": "pymple-0.0.2.tar.gz", "has_sig": false, "md5_digest": "9db7be924fa816741f1eda26d75d041d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15070, "upload_time": "2015-01-08T15:20:22", "url": "https://files.pythonhosted.org/packages/8c/4d/02f72c23b7bd14ce745e1d2b1d7af896f432d1c3e75e924cffaccf3d9135/pymple-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "45b36f40c909b77d1b9c939aaf1d12c3", "sha256": "8455b767004428fd314ba6803a17d5da4b9f4138b1a41e3255f473aef4dad408" }, "downloads": -1, "filename": "pymple-0.0.3.tar.gz", "has_sig": false, "md5_digest": "45b36f40c909b77d1b9c939aaf1d12c3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14902, "upload_time": "2015-01-08T15:50:19", "url": "https://files.pythonhosted.org/packages/2d/28/00613970b2700181e1600c322f2a1e330a0c492b7b4446b7ee05409495b7/pymple-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "b94f09ee3083cc0a0e8e5b1afd64d358", "sha256": "be84b58db8b71fbe57e1a301228d70561bcdae21cbc2a0c62fb940601863da1b" }, "downloads": -1, "filename": "pymple-0.0.4.tar.gz", "has_sig": false, "md5_digest": "b94f09ee3083cc0a0e8e5b1afd64d358", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14906, "upload_time": "2015-01-08T15:54:37", "url": "https://files.pythonhosted.org/packages/e1/ad/cccbf75a2f42624c3904660c4ad4ebb3669bd104e44df284a46d2c05a961/pymple-0.0.4.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "e5b6b3fc2c283c4cf09df77af0c824d2", "sha256": "a429cfbee734e303ec698d8e8c41eaeb178eba39f66a39e3126f2a321766c79b" }, "downloads": -1, "filename": "pymple-0.0.5.tar.gz", "has_sig": false, "md5_digest": "e5b6b3fc2c283c4cf09df77af0c824d2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15641, "upload_time": "2015-01-08T19:15:29", "url": "https://files.pythonhosted.org/packages/b4/4d/6dc749da30a2ec5e58461e3a24a8ac2b08ab9a11e85bd5bcfa87cd32b64e/pymple-0.0.5.tar.gz" } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "221bc0ff7e2fc3472b511c29d3f4b4d3", "sha256": "68efbd323c73499757f8f0be8339eba7299a312938cce3a073bcaa1db4570637" }, "downloads": -1, "filename": "pymple-0.1.0.tar.gz", "has_sig": false, "md5_digest": "221bc0ff7e2fc3472b511c29d3f4b4d3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16197, "upload_time": "2016-06-15T16:49:13", "url": "https://files.pythonhosted.org/packages/b3/65/2d41618e74a94dc9ec61b0a42adb71e732402d205cb6c7345a0f003d51a1/pymple-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "d4e705ac3f213e850e5c8f58270feead", "sha256": "f8cb95a7e6161174c9ec1cb6847b58a41252ac21872cf0efdc7250c436c76843" }, "downloads": -1, "filename": "pymple-0.1.1.tar.gz", "has_sig": false, "md5_digest": "d4e705ac3f213e850e5c8f58270feead", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16224, "upload_time": "2016-09-16T20:08:28", "url": "https://files.pythonhosted.org/packages/be/04/bd8834bef2d8b34497e4e605534e366f84f22f7cf155ebaeba6c96471f51/pymple-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "04835dd43c097fa80d7ad1579b0510e0", "sha256": "81b1f4fc549c1c27b0910f71771fc557fbb209c3d191b143bb1469718ad5085f" }, "downloads": -1, "filename": "pymple-0.1.2.tar.gz", "has_sig": false, "md5_digest": "04835dd43c097fa80d7ad1579b0510e0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16313, "upload_time": "2016-09-17T07:54:11", "url": "https://files.pythonhosted.org/packages/e5/bd/8cfa595b6ec10781fe64694ec50720c133265192f7d6f6c4d490479d879e/pymple-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "5e745d473f38523a8b595e8b7ad6ca8e", "sha256": "7c3e3ffe0d26d05e851e600e4eb74c91d96545573cf55a10bdcbec41dab19971" }, "downloads": -1, "filename": "pymple-0.1.3.tar.gz", "has_sig": false, "md5_digest": "5e745d473f38523a8b595e8b7ad6ca8e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16280, "upload_time": "2016-09-21T15:22:04", "url": "https://files.pythonhosted.org/packages/7b/24/11d988543e605cde8909e41313afabe981acaeefd37153c5df2a501a3069/pymple-0.1.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "5e745d473f38523a8b595e8b7ad6ca8e", "sha256": "7c3e3ffe0d26d05e851e600e4eb74c91d96545573cf55a10bdcbec41dab19971" }, "downloads": -1, "filename": "pymple-0.1.3.tar.gz", "has_sig": false, "md5_digest": "5e745d473f38523a8b595e8b7ad6ca8e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16280, "upload_time": "2016-09-21T15:22:04", "url": "https://files.pythonhosted.org/packages/7b/24/11d988543e605cde8909e41313afabe981acaeefd37153c5df2a501a3069/pymple-0.1.3.tar.gz" } ] }