[run_flaschengeist] Improved export command
Export now supports --no-core flag, if set no core models will get exported. Also --plugins was changed to support a list of plugins, if no list is given the old behavior is taken (export all plugins). If a list of plugins is given, only those plugins are exported.
This commit is contained in:
parent
776332d5fe
commit
8696699ecb
|
@ -567,6 +567,7 @@ def get_columns(userid, current_session):
|
||||||
userController.persist()
|
userController.persist()
|
||||||
return no_content()
|
return no_content()
|
||||||
|
|
||||||
|
|
||||||
@PriceListPlugin.blueprint.route("/users/<userid>/pricecalc_columns_order", methods=["GET", "PUT"])
|
@PriceListPlugin.blueprint.route("/users/<userid>/pricecalc_columns_order", methods=["GET", "PUT"])
|
||||||
@login_required()
|
@login_required()
|
||||||
def get_columns_order(userid, current_session):
|
def get_columns_order(userid, current_session):
|
||||||
|
|
|
@ -17,7 +17,7 @@ class PrefixMiddleware(object):
|
||||||
def __call__(self, environ, start_response):
|
def __call__(self, environ, start_response):
|
||||||
|
|
||||||
if environ["PATH_INFO"].startswith(self.prefix):
|
if environ["PATH_INFO"].startswith(self.prefix):
|
||||||
environ["PATH_INFO"] = environ["PATH_INFO"][len(self.prefix):]
|
environ["PATH_INFO"] = environ["PATH_INFO"][len(self.prefix) :]
|
||||||
environ["SCRIPT_NAME"] = self.prefix
|
environ["SCRIPT_NAME"] = self.prefix
|
||||||
return self.app(environ, start_response)
|
return self.app(environ, start_response)
|
||||||
else:
|
else:
|
||||||
|
@ -83,19 +83,19 @@ class InterfaceGenerator:
|
||||||
import typing
|
import typing
|
||||||
|
|
||||||
if (
|
if (
|
||||||
inspect.ismodule(module[1])
|
inspect.ismodule(module[1])
|
||||||
and module[1].__name__.startswith(self.basename)
|
and module[1].__name__.startswith(self.basename)
|
||||||
and module[1].__name__ not in self.known
|
and module[1].__name__ not in self.known
|
||||||
):
|
):
|
||||||
self.known.append(module[1].__name__)
|
self.known.append(module[1].__name__)
|
||||||
for cls in inspect.getmembers(module[1], lambda x: inspect.isclass(x) or inspect.ismodule(x)):
|
for cls in inspect.getmembers(module[1], lambda x: inspect.isclass(x) or inspect.ismodule(x)):
|
||||||
self.walker(cls)
|
self.walker(cls)
|
||||||
elif (
|
elif (
|
||||||
inspect.isclass(module[1])
|
inspect.isclass(module[1])
|
||||||
and module[1].__module__.startswith(self.basename)
|
and module[1].__module__.startswith(self.basename)
|
||||||
and module[0] not in self.classes
|
and module[0] not in self.classes
|
||||||
and not module[0].startswith("_")
|
and not module[0].startswith("_")
|
||||||
and hasattr(module[1], "__annotations__")
|
and hasattr(module[1], "__annotations__")
|
||||||
):
|
):
|
||||||
self.this_type = module[0]
|
self.this_type = module[0]
|
||||||
print("\n\n" + module[0] + "\n")
|
print("\n\n" + module[0] + "\n")
|
||||||
|
@ -156,12 +156,14 @@ def export(arguments):
|
||||||
app = create_app()
|
app = create_app()
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
gen = InterfaceGenerator(arguments.namespace, arguments.file)
|
gen = InterfaceGenerator(arguments.namespace, arguments.file)
|
||||||
gen.run(models)
|
if not arguments.no_core:
|
||||||
if arguments.plugins:
|
gen.run(models)
|
||||||
|
if arguments.plugins is not None:
|
||||||
for entry_point in pkg_resources.iter_entry_points("flaschengeist.plugin"):
|
for entry_point in pkg_resources.iter_entry_points("flaschengeist.plugin"):
|
||||||
plg = entry_point.load()
|
if len(arguments.plugins) == 0 or entry_point.name in arguments.plugins:
|
||||||
if hasattr(plg, "models") and plg.models is not None:
|
plg = entry_point.load()
|
||||||
gen.run(plg.models)
|
if hasattr(plg, "models") and plg.models is not None:
|
||||||
|
gen.run(plg.models)
|
||||||
gen.write()
|
gen.write()
|
||||||
|
|
||||||
|
|
||||||
|
@ -183,7 +185,12 @@ if __name__ == "__main__":
|
||||||
parser_export.set_defaults(func=export)
|
parser_export.set_defaults(func=export)
|
||||||
parser_export.add_argument("--file", help="Filename where to save", default="flaschengeist.d.ts")
|
parser_export.add_argument("--file", help="Filename where to save", default="flaschengeist.d.ts")
|
||||||
parser_export.add_argument("--namespace", help="Namespace of declarations", default="FG")
|
parser_export.add_argument("--namespace", help="Namespace of declarations", default="FG")
|
||||||
parser_export.add_argument("--plugins", help="Also export plugins", action="store_true")
|
parser_export.add_argument(
|
||||||
|
"--no-core",
|
||||||
|
help="Do not export core declarations (only useful in conjunction with --plugins)",
|
||||||
|
action="store_true",
|
||||||
|
)
|
||||||
|
parser_export.add_argument("--plugins", help="Also export plugins (none means all)", nargs="*")
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
args.func(args)
|
args.func(args)
|
||||||
|
|
Loading…
Reference in New Issue