|
|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
@author: olivier.massot, sept 218
|
|
|
'''
|
|
|
+import importlib
|
|
|
from tempfile import TemporaryDirectory
|
|
|
|
|
|
from flask import request
|
|
|
@@ -11,8 +12,6 @@ from path import Path
|
|
|
from werkzeug.utils import secure_filename
|
|
|
|
|
|
from core.constants import MAIN
|
|
|
-from schemas.netgeo_2_2_doe.validator import Netgeo22DoeValidator
|
|
|
-
|
|
|
|
|
|
app = Flask(__name__)
|
|
|
|
|
|
@@ -32,13 +31,16 @@ def report():
|
|
|
if Path(filename).ext != ".zip":
|
|
|
return render_template("index.html", validation_error="Le fichier doit être un fichier .ZIP ({})".format(Path(filename).ext))
|
|
|
|
|
|
- try:
|
|
|
- with TemporaryDirectory(dir=MAIN / "upload") as d:
|
|
|
- filename = Path(d) / filename
|
|
|
- f.save(filename)
|
|
|
- report = Netgeo22DoeValidator.submit(filename)
|
|
|
- except Exception as e:
|
|
|
- return render_template("index.html", validation_error=str(e))
|
|
|
+ schema_lib_name = request.form['schema']
|
|
|
+ schema_lib = importlib.import_module("schemas." + schema_lib_name)
|
|
|
+
|
|
|
+# try:
|
|
|
+ with TemporaryDirectory(dir=MAIN / "upload") as d:
|
|
|
+ filename = Path(d) / filename
|
|
|
+ f.save(filename)
|
|
|
+ report = schema_lib.validator.submit(filename)
|
|
|
+# except Exception as e:
|
|
|
+# return render_template("index.html", validation_error=str(e))
|
|
|
|
|
|
return render_template("report.html", report=report)
|
|
|
|