Package Gnumed :: Package timelinelib :: Package plugin :: Module factory'
[frames] | no frames]

Source Code for Module Gnumed.timelinelib.plugin.factory'

 1  # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018  Rickard Lindberg, Roger Lindberg 
 2  # 
 3  # This file is part of Timeline. 
 4  # 
 5  # Timeline is free software: you can redistribute it and/or modify 
 6  # it under the terms of the GNU General Public License as published by 
 7  # the Free Software Foundation, either version 3 of the License, or 
 8  # (at your option) any later version. 
 9  # 
10  # Timeline is distributed in the hope that it will be useful, 
11  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
12  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
13  # GNU General Public License for more details. 
14  # 
15  # You should have received a copy of the GNU General Public License 
16  # along with Timeline.  If not, see <http://www.gnu.org/licenses/>. 
17   
18   
19  from timelinelib.plugin.plugins.eventboxdrawers import EVENTBOX_DRAWER 
20  from timelinelib.plugin.plugins.exporters import EXPORTER 
21  from timelinelib.plugin.plugins.texttransformers import TEXT_TRANSFORMER 
22  from timelinelib.plugin.plugins.eventboxdrawers.defaulteventboxdrawer import DefaultEventBoxDrawer 
23  from timelinelib.plugin.plugins.eventboxdrawers.gradienteventboxdrawer import GradientEventBoxDrawer 
24  from timelinelib.plugin.plugins.eventboxdrawers.othergradienteventboxdrawer import OtherGradientEventBoxDrawer 
25  from timelinelib.plugin.plugins.eventboxdrawers.othergradienteventboxdrawerfuzzyedges import OtherGradientEventBoxDrawerFuzzyEdges 
26  from timelinelib.plugin.plugins.exporters.timelineexporter import TimelineExporter 
27  from timelinelib.plugin.plugins.exporters.exporttosvg import SvgExporter 
28  from timelinelib.plugin.plugins.exporters.exporttolist import ListExporter 
29  from timelinelib.plugin.plugins.exporters.exporttobitmap import BitmapExporter 
30  from timelinelib.plugin.plugins.exporters.exporttobitmaps import MultiBitmapExporter 
31  from timelinelib.plugin.plugins.texttransformers.defaulttexttransformer import DefaultTextTransformer 
32  from timelinelib.plugin.plugins.texttransformers.plaintexttohtml import PlainTextToHtml 
33   
34   
35  VALID_SERVICES = [EVENTBOX_DRAWER, EXPORTER, TEXT_TRANSFORMER] 
36  PLUGINS = { 
37      EVENTBOX_DRAWER: [ 
38          DefaultEventBoxDrawer(), 
39          GradientEventBoxDrawer(), 
40          OtherGradientEventBoxDrawer(), 
41          OtherGradientEventBoxDrawerFuzzyEdges(), 
42      ], 
43      EXPORTER: [ 
44          SvgExporter(), 
45          ListExporter(), 
46          BitmapExporter(), 
47          MultiBitmapExporter(), 
48          TimelineExporter(), 
49      ], 
50      TEXT_TRANSFORMER: [ 
51          DefaultTextTransformer(), 
52          PlainTextToHtml(), 
53      ] 
54  } 
55   
56   
57 -class PluginException(Exception):
58 pass
59 60
61 -class PluginFactory(object):
62
63 - def get_plugins(self, service):
64 try: 65 return PLUGINS[service] 66 except: 67 return []
68
69 - def get_plugin(self, service, name):
70 try: 71 return [plugin for plugin in PLUGINS[service] if plugin.display_name() == name][0] 72 except: 73 pass
74