Skip to main content

Library to use plugins in Python programs.

Project description

ZS-PluginManager

PluginManager to use entry-points in projects

Usage

Import

from zs_pluginmanager.manager import PluginManager

Load plugins (entry-points)

plugins_manager = PluginManager()
plugins_manager.load_global("distutils.commands", label="commands")
plugins_manager.load_global("distutils.setup_keywords", label="setup_keywords")

Show loaded plugins (entry-points)

All

print("print all plugins (entry-points):")
for plugin in plugins_manager:
    print("", plugin.name, plugin.plugin)

Output:

print all plugins (entry-points):
 alias <class 'setuptools.command.alias.alias'>
 bdist_egg <class 'setuptools.command.bdist_egg.bdist_egg'>
 bdist_rpm <class 'setuptools.command.bdist_rpm.bdist_rpm'>
 bdist_wininst <class 'setuptools.command.bdist_wininst.bdist_wininst'>
 build_clib <class 'setuptools.command.build_clib.build_clib'>
 build_ext <class 'setuptools.command.build_ext.build_ext'>
 build_py <class 'setuptools.command.build_py.build_py'>
 develop <class 'setuptools.command.develop.develop'>
 dist_info <class 'setuptools.command.dist_info.dist_info'>
 easy_install <class 'setuptools.command.easy_install.easy_install'>
 egg_info <class 'setuptools.command.egg_info.egg_info'>
 install <class 'setuptools.command.install.install'>
 install_egg_info <class 'setuptools.command.install_egg_info.install_egg_info'>
 install_lib <class 'setuptools.command.install_lib.install_lib'>
 install_scripts <class 'setuptools.command.install_scripts.install_scripts'>
 rotate <class 'setuptools.command.rotate.rotate'>
 saveopts <class 'setuptools.command.saveopts.saveopts'>
 sdist <class 'setuptools.command.sdist.sdist'>
 setopt <class 'setuptools.command.setopt.setopt'>
 test <class 'setuptools.command.test.test'>
 upload_docs <class 'setuptools.command.upload_docs.upload_docs'>
 bdist_wheel <class 'wheel.bdist_wheel.bdist_wheel'>
 convert_2to3_doctests <function assert_string_list at 0x000001A90BCDF160>
 dependency_links <function assert_string_list at 0x000001A90BCDF160>
 eager_resources <function assert_string_list at 0x000001A90BCDF160>
 entry_points <function check_entry_points at 0x000001A90BCDF550>
 exclude_package_data <function check_package_data at 0x000001A90BCDF670>
 extras_require <function check_extras at 0x000001A90BCDF280>
 include_package_data <function assert_bool at 0x000001A90BCDF3A0>
 install_requires <function check_requirements at 0x000001A90BCDF430>
 namespace_packages <function check_nsp at 0x000001A90BCDF1F0>
 package_data <function check_package_data at 0x000001A90BCDF670>
 packages <function check_packages at 0x000001A90BCDF700>
 python_requires <function check_specifier at 0x000001A90BCDF4C0>
 setup_requires <function check_requirements at 0x000001A90BCDF430>
 test_loader <function check_importable at 0x000001A90BCDF0D0>
 test_runner <function check_importable at 0x000001A90BCDF0D0>
 test_suite <function check_test_suite at 0x000001A90BCDF5E0>
 tests_require <function check_requirements at 0x000001A90BCDF430>
 use_2to3 <function assert_bool at 0x000001A90BCDF3A0>
 use_2to3_exclude_fixers <function assert_string_list at 0x000001A90BCDF160>
 use_2to3_fixers <function assert_string_list at 0x000001A90BCDF160>
 zip_safe <function assert_bool at 0x000001A90BCDF3A0>

Only selected

print("print selected entry-points by label:")
for plugin in plugins_manager.filter(label="commands"):
    print("", plugin.name, plugin.plugin)

Output:

print selected entry-points by label:
 alias <class 'setuptools.command.alias.alias'>
 bdist_egg <class 'setuptools.command.bdist_egg.bdist_egg'>
 bdist_rpm <class 'setuptools.command.bdist_rpm.bdist_rpm'>
 bdist_wininst <class 'setuptools.command.bdist_wininst.bdist_wininst'>
 build_clib <class 'setuptools.command.build_clib.build_clib'>
 build_ext <class 'setuptools.command.build_ext.build_ext'>
 build_py <class 'setuptools.command.build_py.build_py'>
 develop <class 'setuptools.command.develop.develop'>
 dist_info <class 'setuptools.command.dist_info.dist_info'>
 easy_install <class 'setuptools.command.easy_install.easy_install'>
 egg_info <class 'setuptools.command.egg_info.egg_info'>
 install <class 'setuptools.command.install.install'>
 install_egg_info <class 'setuptools.command.install_egg_info.install_egg_info'>
 install_lib <class 'setuptools.command.install_lib.install_lib'>
 install_scripts <class 'setuptools.command.install_scripts.install_scripts'>
 rotate <class 'setuptools.command.rotate.rotate'>
 saveopts <class 'setuptools.command.saveopts.saveopts'>
 sdist <class 'setuptools.command.sdist.sdist'>
 setopt <class 'setuptools.command.setopt.setopt'>
 test <class 'setuptools.command.test.test'>
 upload_docs <class 'setuptools.command.upload_docs.upload_docs'>
 bdist_wheel <class 'wheel.bdist_wheel.bdist_wheel'>

Limitation

Key of PluginManager.plugins Should be unique by (namespace, entry_point.name, label, local).
If one name of entry_point is in several different groups, then it will be several times.
To find exact pligun do use plugins_manager.filter() which filter plugins by different options.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ZS_PluginManager-0.0.1-py3-none-any.whl (20.1 kB view details)

Uploaded Python 3

File details

Details for the file ZS_PluginManager-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: ZS_PluginManager-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 20.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

File hashes

Hashes for ZS_PluginManager-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a84af31f39597753ea399a7805320c6b09555c0b0c9fca27a1cc5db3c56a739b
MD5 4635adad5f7a19a237bc9346815a103d
BLAKE2b-256 737a4252f25d526213ad6da2caee8da57a57b812ea00a0b284f36a7cc51a7aed

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page