Commit 9b97b6c8 authored by Martin Matějek's avatar Martin Matějek

fixup! Refactor jinja env creation and usage in module

parent ccd30bff
......@@ -37,7 +37,7 @@ class Plugin:
def from_file(cls, filepath, plugin_dir, templates_dir):
def from_file(cls, filepath, templates_dir):
with open(filepath, 'r') as f:
data = yaml.safe_load(f)
......@@ -55,13 +55,12 @@ class Plugin:
# TODO: filter out extra unnecessary data
# i.e. anything not needed for plugin that is present in yaml file
# Get only file name without suffix
filename = pathlib.Path(filepath).stem
path = pathlib.Path(filepath)
filename = path.stem
# TODO: fix absolute plugin_dir path
jinja_template_dirs = [
os.path.join(templates_dir, filename),
os.path.join(os.getcwd(), plugin_dir),
return cls(filename, jinja_template_dirs, **data)
......@@ -26,7 +26,7 @@ class PluginStorage:
def load(self):
"""Load plugins from FS"""
for filepath in glob.glob(os.path.join(self.plugin_dir, '*.yml')):
p = Plugin.from_file(filepath, self.plugin_dir, self.templates_dir)
p = Plugin.from_file(filepath, self.templates_dir)
if p:
self.plugins[] = p
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment