{ "info": { "author": "Kevin L. Mitchell", "author_email": "klmitch@mit.edu", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Plugins", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Software Development :: User Interfaces" ], "description": "=============================\nObject-like Entrypoint Access\n=============================\n\n.. image:: https://travis-ci.org/klmitch/entrypointer.svg?branch=master\n :target: https://travis-ci.org/klmitch/entrypointer\n\nThe ``setuptools`` package provides a handy feature known as\n\"entrypoints\". An entrypoint is a named reference to a Python object,\nsuch as a function, class, or value, which other packages can\nreference using the entrypoint group and name. These are useful for\ncreating extendable Python projects, as one project can create\nentrypoints that will be used as hooks or plugins by another project.\nHowever, making use of entrypoints is rather awkward; ``setuptools``\nprovides the ``pkg_resources.iter_entry_points()`` function, which\niterates through the defined entrypoints, but the caller must still\nload the entrypoint, which could possibly result in some errors which\nmust be caught so the next entrypoint with the given name can be\ntried.\n\nThis package provides an alternative interface to entrypoints which\neliminates this boilerplate, is easier to use, and also speeds up\nrepetitive access to specific entrypoints. This is done through the\ncreation of dictionary-like and list-like objects to represent\nentrypoint groups and lists of loaded entrypoints. A special object,\n``eps``, is also provided that allows reference to an entrypoint group\nvia simple attribute access.\n\nLooking Up an Entrypoint\n========================\n\nWe'll begin with an example. Let's say your application looks for an\nentrypoint named \"hook\" in the entrypoint group\n\"example_app.example_group\". This can be as simple as::\n\n hook = entrypointer.eps.example_app.example_group['hook']\n\nIf the named entrypoint doesn't exist, this will raise a ``KeyError``,\nbut you can use the ``get()`` method to return something else\ninstead::\n\n hook = entrypointer.eps.example_app.example_group.get('hook')\n\nFor a hook method, your application may actually prefer to call all\ndefined hooks. This can be accomplished like so::\n\n for hook in entrypointer.eps.example_app.example_group.get_all('hook', []):\n hook('calling your hook')\n\nSome applications may wish to use entrypoint group names that happen\nto not be valid Python identifiers, e.g., \"Example App.Example\nGroup\". This can be accomplished with a simple ``getattr()`` call on\n``entrypoint.eps``::\n\n group = getattr(entrypointer.eps, 'Example App.Example Group')\n\nThe only restriction on a group name is that no component can start\nwith a leading underscore ('_').\n\nUsing Entrypoints without ``entrypointer.eps``\n==============================================\n\nThe ``entrypointer.eps`` object is provided for convenience; it is not\nrequired to be used. To obtain a dictionary-like object for an\nentrypoint group, simply instantiate the\n``entrypointer.EntrypointDict`` class::\n\n group = entrypointer.EntrypointDict('example_app.example_group')\n hooks = group.get_all('hook')\n\nThis class provides all of the basic ``dict`` methods, such as\n``keys()`` and ``values()``. It also provides variants, such as\n``items_all()``, which yield list-like objects of entrypoints. This\nallows use of entrypoints for a wide variety of effects, such as the\n\"hook\" pattern demonstrated above, or for extending commands your\napplication makes available, or for a variety of other uses.\n\nObtaining a List of Entrypoints\n===============================\n\nAlthough it is recommended to use the ``entrypointer.EntrypointDict``\nclass for accessing entrypoints, it is possible to use the list-like\nobject, ``entrypointer.EntrypointList``, directly. It is instantiated\nwith the entrypoint group name and the name of the entrypoint itself,\ne.g.::\n\n hooks = entrypointer.EntrypointList('example_app.example_group', 'hook')\n\nEfficiency Considerations\n=========================\n\nThe ``pkg_resources.iter_entry_points()`` function is somewhat slow.\nThe ``entrypointer.EntrypointList`` and\n``entrypointer.EntrypointDict`` classes are designed to call it as few\ntimes as possible and cache the results for future use. Further, they\nare optimized for the common case of using the first entrypoint with a\ngiven name; they stop loading entrypoints after the first one that\nloads successfully. Finally, these classes do their work lazily,\ncalling ``pkg_resources.iter_entry_points()`` only when necessary to\nimplement the method being called. This causes the expense of using\nentrypoints to be amortized over the lifetime of the application,\nwhile still maintaining a high speed due to the caching. However, one\nside effect of this caching is that changes to the installed packages\nthat would be picked up by calling\n``pkg_resources.iter_entry_points()`` will not be detected when using\n``entrypointer``; if this is important to your application, you may\nwant to call the ``entrypointer.EntrypointDict`` and\n``entrypoint.EntrypointList`` classes directly and discard them when\nyou are done; note that this will reduce the efficiency, as they will\nneed to call ``pkg_resources.iter_entry_points()`` more frequently.", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/klmitch/entrypointer", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "entrypointer", "package_url": "https://pypi.org/project/entrypointer/", "platform": "", "project_url": "https://pypi.org/project/entrypointer/", "project_urls": { "Homepage": "https://github.com/klmitch/entrypointer" }, "release_url": "https://pypi.org/project/entrypointer/1.0.3/", "requires_dist": null, "requires_python": "", "summary": "Object-like Entrypoint Access", "version": "1.0.3" }, "last_serial": 5196714, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "61ca89bca0e7cf1c8c3bd3d7541a9034", "sha256": "37002ab98b47d332b9b61dbea403b611eb8176cfd95d555e98b4159166bdfee8" }, "downloads": -1, "filename": "entrypointer-1.0.0.tar.gz", "has_sig": false, "md5_digest": "61ca89bca0e7cf1c8c3bd3d7541a9034", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10283, "upload_time": "2017-04-23T00:27:08", "url": "https://files.pythonhosted.org/packages/b1/9a/afa4e04354202f46d1fbdc517d057b8d79d50837a59453cd1f0af0dd1e5e/entrypointer-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "d39e0ea645cc736ad6cb9069d4a308f1", "sha256": "620ecd6546a53244f55b4904ae9221ada66467fb5cb9c2d7f67a01b852ed7c3c" }, "downloads": -1, "filename": "entrypointer-1.0.1.tar.gz", "has_sig": false, "md5_digest": "d39e0ea645cc736ad6cb9069d4a308f1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10329, "upload_time": "2017-04-23T00:31:23", "url": "https://files.pythonhosted.org/packages/a3/2a/97030ea0a890c38c6f85895d800cc3cb16276abbf5354d8a12db23885f96/entrypointer-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "682d58234a3a6542b8b7d7d51206f07c", "sha256": "28096dba07350c7757fa3c3bbfa538a924954a1f67d122f0c09c4c63b5538213" }, "downloads": -1, "filename": "entrypointer-1.0.2.tar.gz", "has_sig": false, "md5_digest": "682d58234a3a6542b8b7d7d51206f07c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10407, "upload_time": "2019-04-27T13:37:43", "url": "https://files.pythonhosted.org/packages/d5/e7/0c14f526e024f5f283c8ed4fa51f8573b68ea6bc9624c79d10dc7d3df252/entrypointer-1.0.2.tar.gz" } ], "1.0.3": [ { "comment_text": "", "digests": { "md5": "e6a0546091660bc2bbcbe1eb1771f4fa", "sha256": "58ccfc366ce6b3bc038eb0d8d48f3ad4553ad8628563389cd0b1bf6fa7d9107b" }, "downloads": -1, "filename": "entrypointer-1.0.3.tar.gz", "has_sig": false, "md5_digest": "e6a0546091660bc2bbcbe1eb1771f4fa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10424, "upload_time": "2019-04-27T13:51:31", "url": "https://files.pythonhosted.org/packages/f0/f9/13bb3fbd4cc963f5b82aa362d146ca450bd2fa2eff5da06416dfb27aaa86/entrypointer-1.0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e6a0546091660bc2bbcbe1eb1771f4fa", "sha256": "58ccfc366ce6b3bc038eb0d8d48f3ad4553ad8628563389cd0b1bf6fa7d9107b" }, "downloads": -1, "filename": "entrypointer-1.0.3.tar.gz", "has_sig": false, "md5_digest": "e6a0546091660bc2bbcbe1eb1771f4fa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10424, "upload_time": "2019-04-27T13:51:31", "url": "https://files.pythonhosted.org/packages/f0/f9/13bb3fbd4cc963f5b82aa362d146ca450bd2fa2eff5da06416dfb27aaa86/entrypointer-1.0.3.tar.gz" } ] }