{ "info": { "author": "Dmitriy Selischev", "author_email": "zibertscrem@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Software Development :: Libraries :: Application Frameworks" ], "description": "hexdi\n=====\n\nHighly extensible Dependency Injection framework for humans\n\nProject location: https://github.com/zibertscrem/hexdi\n\nInstallation\n============\n\n.. code:: bash\n\n pip install hexdi\n\nYou **should** have python 3.5.\\* or higher\n\nUsage\n=====\n\nAll of that usages you can find in **examples** directory\n\nQuick usage reference\n---------------------\n\n.. code:: python\n\n import hexdi\n\n\n class SomeA:\n def foo(self): pass\n\n\n # mark that class as injectable with permanent lifetime for class SomeA\n @hexdi.permanent(SomeA)\n class SomeAimplementation(SomeA):\n def foo(self):\n return 42\n\n\n # inject instance of SomeA as a first argument\n @hexdi.inject(SomeA)\n def test_injection(a: SomeA):\n print('test_injection:', a.foo())\n\n\n class ClassWithDependency:\n # constructor injection\n @hexdi.inject(SomeA)\n def __init__(self, a: SomeA):\n print('ClassWithDependency.__init__:', a.foo())\n\n # after that we can use property like an instance of SomeA class\n @property\n @hexdi.dependency(SomeA)\n def some_a(self) -> SomeA: pass\n\n def foo(self):\n print('ClassWithDependency.foo:', self.some_a.foo())\n\n # method injection also works fine.\n # Because injection members are passing after all transmitted positional arguments\n @hexdi.inject(SomeA)\n def foo_with_injection(self, a: SomeA):\n print('ClassWithDependency.foo_with_injection:', a.foo())\n\n\n if __name__ == '__main__':\n # You don't need to provide any argument. DI container does it self\n # There also should not be cycle dependencies due to lazy loading of any injections\n test_injection() # prints: test_injection: 42\n cwd = ClassWithDependency() # prints: ClassWithDependency.__init__: 42\n cwd.foo() # prints: ClassWithDependency.foo: 42\n cwd.foo_with_injection() # prints: ClassWithDependency.foo_with_injection: 42\n\nSelf-binding\n------------\n\n.. code:: python\n\n import hexdi\n\n\n @hexdi.permanent()\n class SomeA:\n def foo(self):\n return 42\n\n\n @hexdi.inject(SomeA)\n def test(a):\n print(a.foo())\n\n\n if __name__ == '__main__':\n test() # prints: 42\n\nMultiple injection arguments\n----------------------------\n\n.. code:: python\n\n import hexdi\n\n\n @hexdi.permanent()\n class SomeA:\n def foo(self):\n return 42\n\n\n @hexdi.permanent()\n class SomeB:\n def foo(self):\n return 69\n\n\n @hexdi.inject(SomeA, SomeB)\n def test(a, b):\n print(a.foo() + b.foo())\n\n\n if __name__ == '__main__':\n test() # prints: 111\n\nPermanent lifetime and transient lifetime\n-----------------------------------------\n\n.. code:: python\n\n import hexdi\n\n\n @hexdi.permanent()\n class SomeA:\n NUMBER = 0\n\n def __init__(self):\n self.num = SomeA.NUMBER\n SomeA.NUMBER += 1\n\n def foo(self):\n print(self.__class__.__name__, self.num)\n\n\n @hexdi.transient()\n class SomeB:\n NUMBER = 0\n\n def __init__(self):\n self.num = SomeB.NUMBER\n SomeB.NUMBER += 1\n\n def foo(self):\n print(self.__class__.__name__, self.num)\n\n\n @hexdi.inject(SomeA)\n def test_a(a):\n a.foo()\n\n\n @hexdi.inject(SomeB)\n def test_b(b):\n b.foo()\n\n\n if __name__ == '__main__':\n test_a() # prints: SomeA 0\n test_a() # prints: SomeA 0\n test_a() # prints: SomeA 0\n test_b() # prints: SomeB 0\n test_b() # prints: SomeB 1\n test_b() # prints: SomeB 2\n\nUsage of container. Demonstration of lazy injection\n---------------------------------------------------\n\n.. code:: python\n\n import hexdi\n\n\n class SomeA:\n def foo(self): pass\n\n\n class SomeAImplementation(SomeA):\n def foo(self):\n return 42\n\n\n @hexdi.permanent()\n class SomeB:\n def foo(self):\n return 69\n\n\n class SomeC:\n def foo(self):\n return 100500\n\n\n @hexdi.inject(SomeC)\n def test(c):\n print(c.foo())\n\n\n if __name__ == '__main__':\n # getting of container\n container = hexdi.get_root_container()\n # binding SomeAImplementation on SomeA type with permanent lifetime\n container.bind_type(SomeAImplementation, SomeA, hexdi.lifetime.PermanentLifeTimeManager)\n instance = container.resolve(SomeA)\n print(instance.foo()) # prints: 42\n # resolve decorator-binded SomeB\n instance = container.resolve(SomeB)\n print(instance.foo()) # prints: 69\n # bind SomeC on itself with permanent lifetime\n container.bind_type(SomeC, SomeC, hexdi.lifetime.PermanentLifeTimeManager)\n # we mark SomeC for injection above in test func,\n # but all works fine, because it is lazy injection\n test() # prints: 100500\n\nMultifile project\n=================\n\nIf you have a project with separated base objects(to registration) and\nimplementations(to injecting) there will be problematically to identify\nthese implementations if you import it nowhere. For that situation,\nthere is a class loading abstraction with a basic implementation that\ngets a list of **specification** objects with implementation modules.\nThese specification object can be: - dot-separated module path as\nstring: 'pack1.pack2.module1' - a function/lambda without params that\nreturns a **specification** - a tuple that contains a function as a\nfirst argument and tuple of values as a second argument. Function should\nreturn a **specification**\n\n.. code:: python\n\n import hexdi\n from examples.multifile.interfaces import SomeA\n\n loader = hexdi.get_loader([\n 'examples.multifile.implementations'\n ])\n\n\n @hexdi.inject(SomeA)\n def test(a: SomeA):\n print(a.foo())\n\n\n if __name__ == '__main__':\n loader.load()\n test() # prints: 42\n\nYou also able to use recursive module finder to find all local packages,\nsite-packages, dist-packages modules that contains type registering. Use\nsame rules as module loader has\n\n.. code:: python\n\n import hexdi\n from examples.multifile.interfaces import SomeA\n\n # That finder will find that\n finder = hexdi.get_finder(['examples.multifile-finder'])\n loader = hexdi.get_loader(finder.find())\n\n\n @hexdi.inject(SomeA)\n def test(a: SomeA):\n print(a.foo())\n\n\n if __name__ == '__main__':\n loader.load()\n test() # prints: 69\n\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/zibertscrem/hexdi", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "hexdi", "package_url": "https://pypi.org/project/hexdi/", "platform": "", "project_url": "https://pypi.org/project/hexdi/", "project_urls": { "Homepage": "https://github.com/zibertscrem/hexdi" }, "release_url": "https://pypi.org/project/hexdi/0.2.1/", "requires_dist": [ "typing" ], "requires_python": ">=3.5,<4", "summary": "Highly extensible Dependency injection framework for humans", "version": "0.2.1" }, "last_serial": 3508038, "releases": { "0.1.2b1": [ { "comment_text": "", "digests": { "md5": "bd7b6a0000611a896e97482ce29b0de7", "sha256": "d9be736525bb2c184e1d3e2f895e9b505403f515340cfad2f6fc57ba464e48bb" }, "downloads": -1, "filename": "hexdi-0.1.2b1-py3-none-any.whl", "has_sig": false, "md5_digest": "bd7b6a0000611a896e97482ce29b0de7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5,<4", "size": 7024, "upload_time": "2017-12-12T01:13:22", "url": "https://files.pythonhosted.org/packages/b0/60/d2a104bfa52428eda43915f44458f28903d4fea583c2dddfb70c7c7bc8bb/hexdi-0.1.2b1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5164f3985ee614e694bb9bc1bb2ab691", "sha256": "187dfcf9eeca823586311fb4d358c8bda96f1f3989a44cc5ac407ecb306b2559" }, "downloads": -1, "filename": "hexdi-0.1.2b1.tar.gz", "has_sig": false, "md5_digest": "5164f3985ee614e694bb9bc1bb2ab691", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5,<4", "size": 3932, "upload_time": "2017-12-12T01:13:24", "url": "https://files.pythonhosted.org/packages/8f/1d/77699e926501000d6c782d18353b95731fca11c55f5047baef1ac34d96e0/hexdi-0.1.2b1.tar.gz" } ], "0.1.2b2": [ { "comment_text": "", "digests": { "md5": "11236637b3d85aca97572cbdbb04253c", "sha256": "f35d6f7e3f9016344d20dd37a88cbc9b729e2faccd0b9a42dcf7419591d68248" }, "downloads": -1, "filename": "hexdi-0.1.2b2-py3-none-any.whl", "has_sig": false, "md5_digest": "11236637b3d85aca97572cbdbb04253c", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5,<4", "size": 7096, "upload_time": "2017-12-12T01:25:26", "url": "https://files.pythonhosted.org/packages/9d/a6/3338f38d3643b9b1ef5497db31053717bfe281a4c08295a7da5bf47e3ff3/hexdi-0.1.2b2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9aec1127d904435cfe72545664c37dfb", "sha256": "b868ffdd68475563d7b1ddefc7c1ef6edcb90e2c02b6e174f19c8ce04fde1d09" }, "downloads": -1, "filename": "hexdi-0.1.2b2.tar.gz", "has_sig": false, "md5_digest": "9aec1127d904435cfe72545664c37dfb", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5,<4", "size": 4418, "upload_time": "2017-12-12T01:25:27", "url": "https://files.pythonhosted.org/packages/49/67/80bb841901c33b8289b976c7108410358f4c4ea6f44f55e5f916aa4ea3e7/hexdi-0.1.2b2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "895658127513db4d88fb3e555455fed8", "sha256": "838fb2a80ac423c001fcc2f377be625c84eead8eebd6bad55da8142433462d3f" }, "downloads": -1, "filename": "hexdi-0.1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "895658127513db4d88fb3e555455fed8", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5,<4", "size": 10726, "upload_time": "2017-12-27T18:29:19", "url": "https://files.pythonhosted.org/packages/df/82/ed6d411b87f79c813c7676d89688f0ce4ae844253764c69684e004c99275/hexdi-0.1.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "49ce2ada27b6111935d7c73c99edab47", "sha256": "36a9662dc9ce3e0c65e02c5c930a45168d6242c3e5b32b617fcc93d561cc49d8" }, "downloads": -1, "filename": "hexdi-0.1.3.tar.gz", "has_sig": false, "md5_digest": "49ce2ada27b6111935d7c73c99edab47", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5,<4", "size": 6883, "upload_time": "2017-12-27T18:29:22", "url": "https://files.pythonhosted.org/packages/86/b0/0cf7a3c800334723ea49e65a7512e7225b7d31815d7b847fc3d43df9a733/hexdi-0.1.3.tar.gz" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "f5c735a38a7d7aa5d9abf701f68a66a0", "sha256": "f000ae8ae20232be0f0888f543fedbef2a8419113d964b118f15263d1b183700" }, "downloads": -1, "filename": "hexdi-0.1.4-py3-none-any.whl", "has_sig": false, "md5_digest": "f5c735a38a7d7aa5d9abf701f68a66a0", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5,<4", "size": 16946, "upload_time": "2018-01-16T17:50:52", "url": "https://files.pythonhosted.org/packages/f2/55/ca7c1250f6d9943d42d661437e8c50fc8e673ae3b6738164608e04514d53/hexdi-0.1.4-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "471dfc329c79585f77703560e1b85a8a", "sha256": "a4b9fa7c2f781139b6b5306e27babaa892248d1c4556405dfd3ddba4a9f6b3c3" }, "downloads": -1, "filename": "hexdi-0.1.4.tar.gz", "has_sig": false, "md5_digest": "471dfc329c79585f77703560e1b85a8a", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5,<4", "size": 7644, "upload_time": "2018-01-16T17:50:54", "url": "https://files.pythonhosted.org/packages/21/06/0f87112130c94f74cadc844e6e6ae64b96c18edf6c1c9218a848c20ee397/hexdi-0.1.4.tar.gz" } ], "0.1.5": [ { "comment_text": "", "digests": { "md5": "71a7b3dbb06523a39c983ddc3f4bd419", "sha256": "b0ce3b6e80fd966a367e0dd345da58f0dda0c2f8d57016c93b434bbb44fe7ca4" }, "downloads": -1, "filename": "hexdi-0.1.5-py3-none-any.whl", "has_sig": false, "md5_digest": "71a7b3dbb06523a39c983ddc3f4bd419", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5,<4", "size": 16944, "upload_time": "2018-01-16T17:59:28", "url": "https://files.pythonhosted.org/packages/d8/30/406f7f891d4f01f01acfe096e127fabe3861052cd04e8e6fc1ad682b5b4a/hexdi-0.1.5-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "24e93597f3dc316bf04fd34e1373262c", "sha256": "545cb1621340df2e332b35d514ae39a1e219aff90602c7e242d47baa41a1e1f5" }, "downloads": -1, "filename": "hexdi-0.1.5.tar.gz", "has_sig": false, "md5_digest": "24e93597f3dc316bf04fd34e1373262c", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5,<4", "size": 7650, "upload_time": "2018-01-16T17:59:30", "url": "https://files.pythonhosted.org/packages/c9/25/15ba07a50977972861c49339fd6335e7c9daf71a828abd812bb2eba17660/hexdi-0.1.5.tar.gz" } ], "0.1.6": [ { "comment_text": "", "digests": { "md5": "8c0a4811f1a09098e8633d3214435df5", "sha256": "4dcb3ef66b667b6daccbc3144e7fcbb22b6e9aeb0da79eb4844319bf97911009" }, "downloads": -1, "filename": "hexdi-0.1.6-py3-none-any.whl", "has_sig": false, "md5_digest": "8c0a4811f1a09098e8633d3214435df5", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5,<4", "size": 16932, "upload_time": "2018-01-16T18:03:50", "url": "https://files.pythonhosted.org/packages/c4/20/69da1b3b751ebd5f744485ca9e2a209e95916373a6159915fbd28585b1f6/hexdi-0.1.6-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ed4ecc4f4ce98f3eb4d66a694471c178", "sha256": "25c2617c0995e09f8c36c5b08157c2dd589f34001e12f1a1ed9fee1439ace75e" }, "downloads": -1, "filename": "hexdi-0.1.6.tar.gz", "has_sig": false, "md5_digest": "ed4ecc4f4ce98f3eb4d66a694471c178", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5,<4", "size": 7634, "upload_time": "2018-01-16T18:03:53", "url": "https://files.pythonhosted.org/packages/07/b9/004ddd35331e4eecf4c4ad36ab6084bf4811e5dbac4c8f562a5050c45b5b/hexdi-0.1.6.tar.gz" } ], "0.1.7": [ { "comment_text": "", "digests": { "md5": "bb88ae014f9975fe372614eac58cac96", "sha256": "0e09be9adb7bdfb58d0b46902673483eb5bc479f910aedf6c53ed79f99065dfa" }, "downloads": -1, "filename": "hexdi-0.1.7-py3-none-any.whl", "has_sig": false, "md5_digest": "bb88ae014f9975fe372614eac58cac96", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5,<4", "size": 16927, "upload_time": "2018-01-16T18:14:03", "url": "https://files.pythonhosted.org/packages/c5/01/d4cf3a376a756973e25695ca5de4df9465dd4965a7f14023aa3b60f78169/hexdi-0.1.7-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1b93dcf5e9706f2357d104b2078f99f8", "sha256": "4dad2d1033b4d28b6731d67b9b5e50a81aa57604ae85e925b780c7823b9a4f79" }, "downloads": -1, "filename": "hexdi-0.1.7.tar.gz", "has_sig": false, "md5_digest": "1b93dcf5e9706f2357d104b2078f99f8", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5,<4", "size": 7636, "upload_time": "2018-01-16T18:14:04", "url": "https://files.pythonhosted.org/packages/a2/68/da7bc5b40ba9d46d8badc4fda24ef3474c6adc445027041e5f85cfe5f7a2/hexdi-0.1.7.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "aa39f382a25d5726c3e2992d88752a76", "sha256": "347f0781c5cd23c966121d60ec2c52c8f9f8a4f504128dc06952c957257b4f0a" }, "downloads": -1, "filename": "hexdi-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "aa39f382a25d5726c3e2992d88752a76", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5,<4", "size": 16981, "upload_time": "2018-01-17T10:36:24", "url": "https://files.pythonhosted.org/packages/a9/6b/cd90ef13efd1fd3607144cf63f4363289a2658bbfb85069e5f73d3be7785/hexdi-0.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2599b3871bf30e0ec2c5f7e32ad61464", "sha256": "cabc73a10551bdba0e721265c2526d61382ef81dc07c67db62a2a7a37e6fd441" }, "downloads": -1, "filename": "hexdi-0.2.0.tar.gz", "has_sig": false, "md5_digest": "2599b3871bf30e0ec2c5f7e32ad61464", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5,<4", "size": 7658, "upload_time": "2018-01-17T10:36:25", "url": "https://files.pythonhosted.org/packages/55/98/33768381f38c81f2f7cc7b0234bda8326376f8f1eb3ca003e9297ed24bd5/hexdi-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "3eb0b46ab7eb8d49b7cc70bb386fbd14", "sha256": "840d7a15884f73c20dd569af714c304e1a5bd35969da0f7f909f39f580bb0274" }, "downloads": -1, "filename": "hexdi-0.2.1-py3-none-any.whl", "has_sig": false, "md5_digest": "3eb0b46ab7eb8d49b7cc70bb386fbd14", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5,<4", "size": 17197, "upload_time": "2018-01-21T03:17:41", "url": "https://files.pythonhosted.org/packages/cb/07/3afe3507d5bd69b78cf7ac508e0c5e4b50fb7f32df1842028f748f02b082/hexdi-0.2.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e11c0159b7e958212afd6408facef343", "sha256": "634e9d8f6526fb6a95043a574211ea5c04aa232cb7c033fc44d48026cfc4288c" }, "downloads": -1, "filename": "hexdi-0.2.1.tar.gz", "has_sig": false, "md5_digest": "e11c0159b7e958212afd6408facef343", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5,<4", "size": 7837, "upload_time": "2018-01-21T03:17:42", "url": "https://files.pythonhosted.org/packages/05/25/ab021523c719393a0a0c32a4f611d59a8567bcab8f0c6e0df8ffbbee1b89/hexdi-0.2.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "3eb0b46ab7eb8d49b7cc70bb386fbd14", "sha256": "840d7a15884f73c20dd569af714c304e1a5bd35969da0f7f909f39f580bb0274" }, "downloads": -1, "filename": "hexdi-0.2.1-py3-none-any.whl", "has_sig": false, "md5_digest": "3eb0b46ab7eb8d49b7cc70bb386fbd14", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5,<4", "size": 17197, "upload_time": "2018-01-21T03:17:41", "url": "https://files.pythonhosted.org/packages/cb/07/3afe3507d5bd69b78cf7ac508e0c5e4b50fb7f32df1842028f748f02b082/hexdi-0.2.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e11c0159b7e958212afd6408facef343", "sha256": "634e9d8f6526fb6a95043a574211ea5c04aa232cb7c033fc44d48026cfc4288c" }, "downloads": -1, "filename": "hexdi-0.2.1.tar.gz", "has_sig": false, "md5_digest": "e11c0159b7e958212afd6408facef343", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5,<4", "size": 7837, "upload_time": "2018-01-21T03:17:42", "url": "https://files.pythonhosted.org/packages/05/25/ab021523c719393a0a0c32a4f611d59a8567bcab8f0c6e0df8ffbbee1b89/hexdi-0.2.1.tar.gz" } ] }