From 2b35eec0fca91d22048bc54e44b2eda5a57ca9f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Thu, 18 Mar 2021 17:27:19 +0100 Subject: [PATCH] [run_flaschengeist] fixed bool definition --- run_flaschengeist | 39 +++++++++++++++++++++++---------------- setup.py | 2 +- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/run_flaschengeist b/run_flaschengeist index 1e0e9c5..ce06a1c 100644 --- a/run_flaschengeist +++ b/run_flaschengeist @@ -10,27 +10,33 @@ from flaschengeist.config import config class PrefixMiddleware(object): - - def __init__(self, app, prefix=''): + def __init__(self, app, prefix=""): self.app = app self.prefix = prefix def __call__(self, environ, start_response): - if environ['PATH_INFO'].startswith(self.prefix): - environ['PATH_INFO'] = environ['PATH_INFO'][len(self.prefix):] - environ['SCRIPT_NAME'] = self.prefix + if environ["PATH_INFO"].startswith(self.prefix): + environ["PATH_INFO"] = environ["PATH_INFO"][len(self.prefix) :] + environ["SCRIPT_NAME"] = self.prefix return self.app(environ, start_response) else: - start_response('404', [('Content-Type', 'text/plain')]) + start_response("404", [("Content-Type", "text/plain")]) return ["This url does not belong to the app.".encode()] class InterfaceGenerator: known = [] classes = {} - mapper = {"str": "string", "int": "number", "float": "number", "date": "Date", "datetime": "Date", - "NoneType": "null"} + mapper = { + "str": "string", + "int": "number", + "float": "number", + "date": "Date", + "datetime": "Date", + "NoneType": "null", + "bool": "boolean", + } def __init__(self, namespace, filename): self.basename = "" @@ -45,6 +51,7 @@ class InterfaceGenerator: def _pytype(self, cls): import typing + origin = typing.get_origin(cls) arguments = typing.get_args(cls) @@ -76,19 +83,19 @@ class InterfaceGenerator: import typing if ( - inspect.ismodule(module[1]) - and module[1].__name__.startswith(self.basename) - and module[1].__name__ not in self.known + inspect.ismodule(module[1]) + and module[1].__name__.startswith(self.basename) + and module[1].__name__ not in self.known ): self.known.append(module[1].__name__) for cls in inspect.getmembers(module[1], lambda x: inspect.isclass(x) or inspect.ismodule(x)): self.walker(cls) elif ( - inspect.isclass(module[1]) - and module[1].__module__.startswith(self.basename) - and module[0] not in self.classes - and not module[0].startswith("_") - and hasattr(module[1], "__annotations__") + inspect.isclass(module[1]) + and module[1].__module__.startswith(self.basename) + and module[0] not in self.classes + and not module[0].startswith("_") + and hasattr(module[1], "__annotations__") ): self.this_type = module[0] print("\n\n" + module[0] + "\n") diff --git a/setup.py b/setup.py index cfab611..4be654d 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ setup( "flask_sqlalchemy", "flask_cors", "werkzeug", - mysql_driver + mysql_driver, ], extras_require={"ldap": ["flask_ldapconn", "ldap3"], "test": ["pytest", "coverage"]}, entry_points={