{"id":16247000,"url":"https://github.com/magmax/python-pluginloader","last_synced_at":"2025-10-27T04:02:21.914Z","repository":{"id":17263913,"uuid":"20033533","full_name":"magmax/python-pluginloader","owner":"magmax","description":"Library to manage python plugins/extensions","archived":false,"fork":false,"pushed_at":"2018-03-04T21:53:59.000Z","size":240,"stargazers_count":6,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-03T05:51:12.057Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/magmax.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-05-21T19:03:14.000Z","updated_at":"2018-07-12T12:11:00.000Z","dependencies_parsed_at":"2022-09-13T00:34:22.543Z","dependency_job_id":null,"html_url":"https://github.com/magmax/python-pluginloader","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/magmax/python-pluginloader","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magmax%2Fpython-pluginloader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magmax%2Fpython-pluginloader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magmax%2Fpython-pluginloader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magmax%2Fpython-pluginloader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/magmax","download_url":"https://codeload.github.com/magmax/python-pluginloader/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magmax%2Fpython-pluginloader/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265686610,"owners_count":23811209,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T14:35:24.919Z","updated_at":"2025-10-27T04:02:16.893Z","avatar_url":"https://github.com/magmax.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"==============  ===============  =========  ============\nVERSION         DOWNLOADS        TESTS      COVERAGE\n==============  ===============  =========  ============\n|pip version|   |pip downloads|  |travis|   |coveralls|\n==============  ===============  =========  ============\n\nGoal and Philosophy\n===================\n\n**Pluginloader** is a library to allow an easy way to **load plugins**. They can be managed by interfaces or just method validators.\n\nFeatures\n--------\n\n- Each plugin can be instanciated **several times**.\n- **Customizable filter** to select if a class should be loaded as a plugin.\n- **Sandboxed**: plugins cannot access the main program or other plugins by default, because they are loaded in isolated environments.\n- **Parameterizable context**: Sometimes you need to pass some classes, functions or variables preloaded to the plugins. It is possible and easy.\n\n\nDocumentation\n=============\n\nInstallation\n------------\n\nTwo options: to install it in your system/project::\n\n    pip install pluginloader\n\nUsage\n-----\n\nYou can load all plugins in a file, just doing:\n\n.. code:: python\n\n    loader = PluginLoader()\n    plugins = loader.load_file('plugins.py')\n\nWith those simple lines you will have in the variable :code:`plugins` a dictionary with each class inside the ``plugins.py`` file as key and a factory as value.\n\nLet's see an example. Using the ``plugins.py`` file:\n\n.. code:: python\n\n    class Foo(object):\n        pass\n\nWe can have an object of that class just with:\n\n.. code:: python\n\n    loader = PluginLoader()\n    plugins = loader.load_file('plugins.py')\n    instance1 = plugins['Foo']()\n    instance2 = plugins['Foo']()\n\nSimple and easy.\n\nAPI\n---\n\nThis is a simple module with a simple API. It just contains one class, :code:`PluginLoader`, with these public methods:\n\n:code:`load_file(filename, onlyif=None, context=None)`\n//////////////////////////////////////////////////////\n\nLoads all plugins in a file.\n\nParameters:\n\n- ``filename``: File name to be loaded.\n- ``onlyif``: Value or function that will be called with each class found. It will skip the plugin if this function returns :code:`False`.\n- ``context``: Dict with the context where the method should be loaded in. It usually will map a class, function or variable name to the class, function or value in the main program, so it can be used within the plugin.\n\n\n:code:`load_directory(path, onlyif=None, recursive=False))`\n///////////////////////////////////////////////////////////\n\nLoads all plugins in a directory.\n\nParameters:\n\n- ``path``: Path where plugins are in.\n- ``onlyif``: Value or function that will be called with each class found. It will skip the plugin if this function returns :code:`False`.\n- ``recursive``: Boolean value to allow recursive read of directories.\n- ``context``: Dict with the context where the method should be loaded in.\n\nLinks will always be ignored.\n\nThe :code:`onlyif` functions have this format:\n\n.. code:: python\n\n    def condition(obj_name, class_name, file_name)\n\nwhere:\n- ``obj_name`` is the name of the object. It can be a variable, function, class or instance.\n- ``class_name`` is the class of the object.\n- ``file_name`` is the file where the object has been declared.\n\n\nLicense\n=======\n\nCopyright (c) 2014 Miguel Ángel García (`@magmax9`_).\n\nLicensed under `the MIT license`_.\n\n\n.. |travis| image:: https://travis-ci.org/magmax/python-pluginloader.png\n  :target: `Travis`_\n  :alt: Travis results\n\n.. |coveralls| image:: https://coveralls.io/repos/magmax/python-pluginloader/badge.png\n  :target: `Coveralls`_\n  :alt: Coveralls results_\n\n.. |pip version| image:: https://pypip.in/v/pluginloader/badge.png\n    :target: https://pypi.python.org/pypi/pluginloader\n    :alt: Latest PyPI version\n\n.. |pip downloads| image:: https://pypip.in/d/pluginloader/badge.png\n    :target: https://pypi.python.org/pypi/pluginloader\n    :alt: Number of PyPI downloads\n\n.. _Travis: https://travis-ci.org/magmax/python-pluginloader\n.. _Coveralls: https://coveralls.io/r/magmax/python-pluginloader\n\n.. _@magmax9: https://twitter.com/magmax9\n\n.. _the MIT license: http://opensource.org/licenses/MIT\n.. _download the lastest zip: https://pypi.python.org/pypi/pluginloader\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagmax%2Fpython-pluginloader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmagmax%2Fpython-pluginloader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagmax%2Fpython-pluginloader/lists"}