Subversion Repositories MeX

Compare Revisions

Ignore whitespace Rev 1 → Rev 2

/trunk/mex/data/plugins/CoreMetadataPlugin.py
0,0 → 1,21
# -*- coding: utf-8; tab-width: 4; indent-tabs-mode: t; python-indent: 4 -*-
#!/usr/bin/python
# -*- coding: utf-8 -*-
 
"""
# File: srv_application.py
# Author: Tomás Vírseda
# License: GPL v3
# Description: Plugin test
"""
 
 
from mex.core.mod_log import get_logger
from mex.services.srv_plugins import IMetadataPlugin
 
class CoreMetadataPlugin(IMetadataPlugin):
def print_name(self):
self.log = get_logger(__class__.__name__)
self.log.debug ("This is a simple Yapsy plugin")
 
 
/trunk/mex/data/plugins/SimplePlugin.py
0,0 → 1,19
# -*- coding: utf-8; tab-width: 4; indent-tabs-mode: t; python-indent: 4 -*-
#!/usr/bin/python
# -*- coding: utf-8 -*-
 
"""
# File: srv_application.py
# Author: Tomás Vírseda
# License: GPL v3
# Description: Plugin test
"""
 
from yapsy.IPlugin import IPlugin
from mex.core.mod_log import get_logger
from mex.services.srv_plugins import IMetadataPlugin
 
class SimplePlugin(IPlugin):
def print_name(self):
self.log = get_logger(__class__.__name__)
self.log.debug ("This is a simple Yapsy plugin")
/trunk/mex/data/plugins/coremetadataplugin.yapsy-plugin
0,0 → 1,10
[Core]
Name = Core Metadata
Module = CoreMetadataPlugin
 
[Documentation]
Author = Tomas Virseda
Version = 0.1
Website = http://t00mlabs.net
Description = Get core metadata from files
Copyright = 2019
/trunk/mex/data/plugins/simpleplugin.yapsy-plugin
0,0 → 1,10
[Core]
Name = Simple_Plugin
Module = SimplePlugin
 
[Documentation]
Author = Tomas Virseda
Version = 0.1
Website = http://t00mlabs.net
Description = A simple plugin usefull for basic testing
Copyright = 2019
/trunk/mex/services/srv_application.py
9,17 → 9,35
 
 
from mex.core.mod_srv import Service
from mex.core.mod_env import LPATH, APP
from mex.core.mod_env import GPATH, LPATH, APP
 
 
class MexAppSrv(Service):
def initialize(self):
pass
"""
Missing method docstring (missing-docstring)
"""
self.get_services()
 
 
def get_services(self):
"""
Missing method docstring (missing-docstring)
"""
self.srvutl = self.get_service('Utils')
self.srvplg = self.get_service('Plugins')
 
 
 
def run(self):
self.log.debug("Starting Metadata eXplorer")
self.plugins = self.get_service('Plugins')
self.srv_plugins = self.get_service('Plugins')
self.plugins = self.srv_plugins.get_plugins_by_category('Metadata')
self.log.debug("Found %d plugins for 'Metadata' category" % len(self.plugins))
for plugin in self.plugins:
self.log.debug("\tPlugin: %s" % plugin.name)
fileset = self.srvutl.get_files_from_dir(GPATH['ROOT'])
self.log.debug(fileset)
 
 
def end(self):
/trunk/mex/services/srv_plugins.py
9,15 → 9,44
 
 
from mex.core.mod_srv import Service
from mex.core.mod_env import LPATH, APP
from mex.core.mod_env import GPATH, LPATH, APP
from yapsy.PluginManager import PluginManager
from yapsy.IPlugin import IPlugin
 
class IMetadataPlugin(IPlugin):
pass
 
class MexPluginManager(Service):
def initialize(self):
self.log.debug("Loading Plugin Manager")
manager = PluginManager()
manager.setPluginPlaces([LPATH['PLUGINS']])
manager.collectPlugins()
self.manager = PluginManager()
 
for plugin in manager.getAllPlugins():
plugin.plugin_object.print_name()
# set plugins paths
self.manager.setPluginPlaces([GPATH['PLUGINS'], LPATH['PLUGINS']])
 
# allow only plugins belonging to the Metadata category
self.manager.setCategoriesFilter({
"Metadata" : IMetadataPlugin,
"Default" : IPlugin,
})
 
# Get all
self.manager.collectPlugins()
self.log.debug("Number of plugins found: %d" % len(self.manager.getAllPlugins()))
# ~ for plugin in self.manager.getAllPlugins():
# ~ self.log.debug("\tCategory: %s - Name: %s" % (plugin.category, plugin.name))
# ~ plugin.plugin_object.print_name()
 
 
def get_manager(self):
return self.manager
 
def get_plugins(self):
return self.manager.getAllPlugins()
 
def get_plugins_by_category(self, category):
try:
return self.manager.getPluginsOfCategory(category)
except:
self.log.warning("Plugin category '%s' doesn't exist" % category)
return []
/trunk/mex/services/srv_utils.py
0,0 → 1,44
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
# File: srv_utils.py
# Author: Tomás Vírseda
# License: GPL v3
# Description: Generic functions service
"""
 
import os
from mex.core.mod_env import GPATH, LPATH, FILE
from mex.core.mod_srv import Service
 
class MexUtils(Service):
"""
Missing class docstring (missing-docstring)
"""
 
def initialize(self):
"""
Missing method docstring (missing-docstring)
"""
self.get_services()
 
 
def get_services(self):
"""
Missing method docstring (missing-docstring)
"""
pass
 
 
def get_files_from_dir(self, path):
fileset = set()
for r,d,f in os.walk(path):
for filename in f:
if not filename.startswith('~'):
uri = os.path.join(r, filename)
if not os.path.isdir(uri):
fileset.add(uri)
return fileset
 
 
 
/trunk/mex/mex.py
16,8 → 16,8
from mex.core.mod_log import get_logger
from mex.services.srv_plugins import MexPluginManager
from mex.services.srv_application import MexAppSrv
from mex.services.srv_utils import MexUtils
 
 
#DOC: http://stackoverflow.com/questions/16410852/keyboard-interrupt-with-with-python-gtk
signal.signal(signal.SIGINT, signal.SIG_DFL)
 
69,8 → 69,10
self.services = {}
try:
services = {
'Utils' : MexUtils(),
'Application' : MexAppSrv(),
'Plugins' : MexPluginManager(),
 
}
 
for name in services:
/trunk/Changelog
0,0 → 1,11
2019-08-31 Tomás Vírseda <tomasvirseda@gmail.com>
 
* Added Yapsy plugin manager and some plugin examples
 
 
2019-08-30 Tomás Vírseda <tomasvirseda@gmail.com>
 
* Initial commit: just the application skeleton
 
 
 
/trunk/setup.py
33,7 → 33,7
try:
data_files_mex = [
('mex/data/share', []),
("mex/data/share/docs",
('mex/data/share/docs',
[
'AUTHORS',
'LICENSE',
42,6 → 42,13
'CREDITS',
'Changelog'
]),
('mex/data/plugins',
[
'mex/data/plugins/simpleplugin.yapsy-plugin',
'mex/data/plugins/SimplePlugin.py',
'mex/data/plugins/coremetadataplugin.yapsy-plugin',
'mex/data/plugins/CoreMetadataPlugin.py',
]),
]
return data_files_mex
except: