Skip to content

Commit 97e5815

Browse files
committed
🚑 sometimes, PluginManager should have been declared before any plugin is declared
1 parent effc790 commit 97e5815

File tree

2 files changed

+31
-20
lines changed

2 files changed

+31
-20
lines changed

pyexcel_pygal/__init__.py

+15-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,21 @@
77
:copyright: (c) 2016-2017 by Onni Software Ltd.
88
:license: New BSD License, see LICENSE for further details
99
"""
10-
from pyexcel.plugins import PyexcelPluginChain
10+
from lml.plugin import PluginInfoChain, PluginInfo
1111

1212

13-
PyexcelPluginChain(__name__).add_a_renderer(
14-
relative_plugin_class_path='chart.ChartRenderer',
15-
file_types=['svg']
13+
class MyPluginInfo(PluginInfo):
14+
15+
def tags(self):
16+
file_types = self.file_types
17+
for file_type in file_types:
18+
yield file_type
19+
20+
21+
PluginInfoChain(__name__).add_a_plugin_instance(
22+
MyPluginInfo(
23+
'renderer',
24+
'%s.chart.ChartRenderer' % __name__,
25+
file_types=['svg']
26+
)
1627
)

pyexcel_pygal/chart.py

+16-16
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,22 @@
3232
histogram='Histogram')
3333

3434

35+
class ChartManager(PluginManager):
36+
def __init__(self):
37+
PluginManager.__init__(self, 'chart')
38+
39+
def get_a_plugin(self, key, **keywords):
40+
self._logger.debug("get a plugin called")
41+
plugin = self.load_me_now(key)
42+
return plugin(key)
43+
44+
def raise_exception(self, key):
45+
raise Exception("No support for " + key)
46+
47+
48+
MANAGER = ChartManager()
49+
50+
3551
class Chart(object):
3652

3753
def __init__(self, cls_name):
@@ -169,22 +185,6 @@ def _render_a_sheet(self, instance, sheet,
169185
instance.add(sheet.name, points)
170186

171187

172-
class ChartManager(PluginManager):
173-
def __init__(self):
174-
PluginManager.__init__(self, 'chart')
175-
176-
def get_a_plugin(self, key, **keywords):
177-
self._logger.debug("get a plugin called")
178-
plugin = self.load_me_now(key)
179-
return plugin(key)
180-
181-
def raise_exception(self, key):
182-
raise Exception("No support for " + key)
183-
184-
185-
MANAGER = ChartManager()
186-
187-
188188
class ChartRenderer(BinaryRenderer):
189189

190190
def render_sheet(self, sheet, title=DEFAULT_TITLE,

0 commit comments

Comments
 (0)