Verified Commit 50f574f6 authored by Dan Jones's avatar Dan Jones
Browse files

chore: lint changes with black

parent 0383a95b
......@@ -35,7 +35,7 @@ FLASK_DEBUG = os.getenv("FLASK_DEBUG", "False").lower() in ("true", "1", "t")
def get_swagger_config(reload=False):
if reload:
print("Reload specified: Ignoring cached refs")
swagger_config = {
"openapi": "3.0.2",
"swagger_ui": True,
......@@ -195,26 +195,26 @@ def downgrade_schema_30x_compatible(schema):
downgrade_schema_30x_compatible(propConfig["items"])
def get_remote_ref_cache_path(remote_ref):
def get_remote_ref_cache_path(remote_ref):
parsed_ref = urlparse(remote_ref)
return f"remotes/{parsed_ref.hostname}{parsed_ref.path}"
def get_cached_ref(remote_ref):
def get_cached_ref(remote_ref):
ref_path = get_remote_ref_cache_path(remote_ref)
ref = None
if os.path.exists(ref_path):
print(f"loading cached ref: {remote_ref}")
with open(ref_path, 'r') as ref_file:
with open(ref_path, "r") as ref_file:
ref = json.load(ref_file)
return ref
def store_cached_ref(remote_ref, definition):
ref_path = get_remote_ref_cache_path(remote_ref)
ref_dirs = re.sub(r'\/[^\/]+$', '', ref_path)
ref_dirs = re.sub(r"\/[^\/]+$", "", ref_path)
os.makedirs(ref_dirs, 0o775, True)
with open(ref_path, 'w') as ref_file:
with open(ref_path, "w") as ref_file:
json.dump(definition, ref_file)
......@@ -234,7 +234,7 @@ def inject_schema(schema, remote_ref, reload=False):
# get schema from cache if present
ref_schema = None if reload else get_cached_ref(remote_ref)
if not ref_schema:
print(f"ref not cached: {remote_ref}")
print(f"ref not cached: {remote_ref}")
ref_schema = resolve_ref(remote_ref)
downgrade_schema_30x_compatible(ref_schema)
store_cached_ref(remote_ref, ref_schema)
......@@ -393,7 +393,7 @@ if __name__ == "__main__":
# Parse script args
config = get_options()
swagger_config = get_swagger_config(config.get('reload_schemas'))
swagger_config = get_swagger_config(config.get("reload_schemas"))
# Output compiled schema
if config.get("output_file"):
......
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