feature/migrations, closes #19 #20
|
@ -1,4 +1,5 @@
|
||||||
import click
|
import click
|
||||||
|
from importlib_metadata import entry_points
|
||||||
|
|
||||||
|
|
||||||
@click.command()
|
@click.command()
|
||||||
|
@ -8,14 +9,21 @@ import click
|
||||||
@click.option("--no-core", help="Skip models / types from flaschengeist core", is_flag=True)
|
@click.option("--no-core", help="Skip models / types from flaschengeist core", is_flag=True)
|
||||||
def export(namespace, output, no_core, plugin):
|
def export(namespace, output, no_core, plugin):
|
||||||
from flaschengeist import logger, models
|
from flaschengeist import logger, models
|
||||||
from flaschengeist.app import get_plugins
|
|
||||||
from .InterfaceGenerator import InterfaceGenerator
|
from .InterfaceGenerator import InterfaceGenerator
|
||||||
|
|
||||||
gen = InterfaceGenerator(namespace, output, logger)
|
gen = InterfaceGenerator(namespace, output, logger)
|
||||||
if not no_core:
|
if not no_core:
|
||||||
gen.run(models)
|
gen.run(models)
|
||||||
if plugin:
|
if plugin:
|
||||||
for plugin_class in get_plugins():
|
for entry_point in entry_points(group="flaschengeist.plugins"):
|
||||||
if (len(plugin) == 0 or plugin_class.id in plugin) and plugin_class.models is not None:
|
if len(plugin) == 0 or entry_point.name in plugin:
|
||||||
gen.run(plugin_class.models)
|
try:
|
||||||
|
plugin = entry_point.load()
|
||||||
|
gen.run(plugin.models)
|
||||||
|
except:
|
||||||
|
logger.error(
|
||||||
|
f"Plugin {entry_point.name} could not be loaded due to an error.",
|
||||||
|
exc_info=True,
|
||||||
|
)
|
||||||
|
continue
|
||||||
gen.write()
|
gen.write()
|
||||||
|
|
|
@ -97,7 +97,9 @@ def ls(enabled, no_header):
|
||||||
return p.version
|
return p.version
|
||||||
|
|
||||||
plugins = entry_points(group="flaschengeist.plugins")
|
plugins = entry_points(group="flaschengeist.plugins")
|
||||||
enabled_plugins = [key for key, value in config.items() if "enabled" in value and value["enabled"]] + [config["FLASCHENGEIST"]["auth"]]
|
enabled_plugins = [key for key, value in config.items() if "enabled" in value and value["enabled"]] + [
|
||||||
|
config["FLASCHENGEIST"]["auth"]
|
||||||
|
]
|
||||||
loaded_plugins = current_app.config["FG_PLUGINS"].keys()
|
loaded_plugins = current_app.config["FG_PLUGINS"].keys()
|
||||||
|
|
||||||
if not no_header:
|
if not no_header:
|
||||||
|
|
Loading…
Reference in New Issue