Commit fa4105c5 authored by Christophe Benz's avatar Christophe Benz
Browse files

Fix flake8 errors

parent 731260a6
......@@ -12,23 +12,21 @@ from urllib.parse import urlencode, urljoin
import frictionless
import jsonschema
import requests
import validata_core
from commonmark import commonmark
from flask import abort, make_response, redirect, render_template, request, url_for
from opendataschema import GitSchemaReference, by_commit_date
import validata_core
from validata_core.helpers import (
ValidataResource,
URLValidataResource,
FileContentValidataResource,
URLValidataResource,
ValidataResource,
)
from . import app, config, schema_catalog_registry, fetch_schema, pdf_service
from . import app, config, fetch_schema, pdf_service, schema_catalog_registry
from .model import Section
from .ui_util import flash_error, flash_warning
from .validata_util import strip_accents
log = logging.getLogger(__name__)
......@@ -41,7 +39,8 @@ class SchemaInstance:
"""Handy class to handle schema information"""
def __init__(self, parameter_dict):
"""Initializes schema instance from requests dict and tableschema catalog (for name ref)"""
"""Initializes schema instance from requests dict and tableschema Catalog
(for name ref)."""
self.section_name = None
self.section_title = None
self.name = None
......@@ -83,9 +82,8 @@ class SchemaInstance:
if schema_reference is None:
abort(
400,
"Schéma '{}' non trouvé dans le catalogue de la section '{}'".format(
self.name, self.section_name
),
f"Schéma {self.name!r} non trouvé dans le catalogue de la "
f"section {self.section_name!r}",
)
if isinstance(schema_reference, GitSchemaReference):
......@@ -453,7 +451,8 @@ def retrieve_schema_catalog(section: Section):
return f"""{err_msg}
<div class="float-right">
<button type="button" class="btn btn-info btn-xs" data-toggle="collapse" data-target="#exception_info">détails</button>
<button type="button" class="btn btn-info btn-xs" data-toggle="collapse"
data-target="#exception_info">détails</button>
</div>
<div id="exception_info" class="collapse">
<pre>{exception_text}</pre>
......@@ -519,14 +518,15 @@ def home():
table_schema = fetch_schema(schema_reference.get_schema_url())
except json.JSONDecodeError:
schema_info["err"] = True
schema_info[
"title"
] = f"le format du schéma « {schema_info['name']} » n'est pas reconnu"
schema_info["title"] = (
f"le format du schéma « {schema_info['name']} » "
"n'est pas reconnu"
)
except Exception:
schema_info["err"] = True
schema_info[
"title"
] = f"le schéma « {schema_info['name']} » n'est pas disponible"
schema_info["title"] = (
f"le schéma « {schema_info['name']} » " "n'est pas disponible"
)
else:
schema_info["title"] = (
table_schema.get("title") or schema_info["name"]
......@@ -576,7 +576,7 @@ def pdf_report():
# Ask for PDF report generation
try:
pdf_bytes_content = pdf_service.render(validation_url)
except Exception as ex:
except Exception:
log.exception(err_prefix)
flash_error(err_prefix + " : contactez votre administrateur")
return redirect(url_for("home"))
......@@ -605,7 +605,8 @@ def compute_schema_info(table_schema: frictionless.Schema, schema_url):
# Schema URL + schema metadata info
schema_info = {
"path": schema_url,
# a "path" metadata property can be found in Table Schema, and we'd like it to override the `schema_url`
# a "path" metadata property can be found in Table Schema,
# and we'd like it to override the `schema_url`
# given by the user (in case schema was given by URL)
**extract_schema_metadata(table_schema),
}
......
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