Browse Source

WIP Enumerates the plugins types instead of using magic strings

plugins
Zykino 3 years ago
parent
commit
4f4842fd1f
2 changed files with 16 additions and 9 deletions
  1. +9
    -9
      prismedia/core.py
  2. +7
    -0
      prismedia/pluginInterfaces.py

+ 9
- 9
prismedia/core.py View File

@ -40,9 +40,9 @@ def loadPlugins(basePluginsPath):
# Define the various categories corresponding to the different
# kinds of plugins you have defined
manager.setCategoriesFilter({
"Interface" : pi.IInterfacePlugin,
"Platform" : pi.IPlatformPlugin,
"Consumer" : pi.IConsumerPlugin,
pi.PluginTypes.INTERFACE : pi.IInterfacePlugin,
pi.PluginTypes.PLATFORM : pi.IPlatformPlugin,
pi.PluginTypes.CONSUMER : pi.IConsumerPlugin,
})
manager.collectPlugins()
@ -52,16 +52,16 @@ def listPlugins():
print("The plugins are stored in the following folders:", manager.getPluginLocator().plugins_places)
print("Category: Interface")
for plugin in manager.getPluginsOfCategory("Interface"):
print("Category:", pi.PluginTypes.INTERFACE.value)
for plugin in manager.getPluginsOfCategory(pi.PluginTypes.INTERFACE):
print(plugin.name)
print("Category: Platform")
for plugin in manager.getPluginsOfCategory("Platform"):
print("Category:", pi.PluginTypes.PLATFORM.value)
for plugin in manager.getPluginsOfCategory(pi.PluginTypes.PLATFORM):
print(plugin.name)
print("Category: Consumer")
for plugin in manager.getPluginsOfCategory("Consumer"):
print("Category:", pi.PluginTypes.CONSUMER.value)
for plugin in manager.getPluginsOfCategory(pi.PluginTypes.CONSUMER):
print(plugin.name)
def main():

+ 7
- 0
prismedia/pluginInterfaces.py View File

@ -1,5 +1,12 @@
from enum import Enum
from yapsy.IPlugin import IPlugin
class PluginTypes(Enum):
"""Plugin Types possibles to instantiate in this program."""
INTERFACE = "Interface"
PLATFORM = "Platform"
CONSUMER = "Consumer"
###
# Interface
###

Loading…
Cancel
Save