# -*- coding: utf-8 -*- """ /*************************************************************************** MnCheckDialog A QGIS plugin Contrôle des données FTTH format MN Generated by Plugin Builder: http://g-sherman.github.io/Qgis-Plugin-Builder/ ------------------- begin : 2018-12-07 git sha : $Format:%H$ copyright : (C) 2018 by Manche Numérique 2019 email : olivier.massot@manchenumerique.fr ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ """ import importlib import logging from PyQt5 import QtWidgets from PyQt5 import uic from PyQt5.Qt import QIcon, QPixmap from core.constants import MAIN, RSCDIR logger = logging.getLogger("mncheck") Ui_Main, _ = uic.loadUiType(MAIN / 'ui'/ 'dlg_main.ui') SCHEMAS = ["mn1_rec", "mn2_rec", "mn3_pro", "mn3_exe", "mn3_rec"] class DlgMain(QtWidgets.QDialog): def __init__(self, parent=None): super(DlgMain, self).__init__(parent) self.createWidgets() def createWidgets(self): """ set up the interface """ self.ui = Ui_Main() self.ui.setupUi(self) self.ui.stack.setCurrentIndex(0) self.ui.btn_play.setIcon(QIcon(RSCDIR / "play.png")) self.ui.btn_play.clicked.connect(self.run) self.ui.btn_help.setIcon(QIcon(RSCDIR / "question.png")) self.ui.btn_help.clicked.connect(self.show_help) self.ui.btn_settings.setIcon(QIcon(RSCDIR / "settings.png")) self.ui.btn_settings.clicked.connect(self.show_settings) self.ui.lbl_hourglass.setPixmap(QPixmap(RSCDIR / "hourglass.png")) self.ui.lbl_ok.setPixmap(QPixmap(RSCDIR / "ok_32.png")) self.ui.cbb_schemas.addItem("Schéma MN v1", 0) self.ui.cbb_schemas.addItem("Schéma MN v2", 1) self.ui.cbb_schemas.addItem("Schéma MN v3 PRO", 2) self.ui.cbb_schemas.addItem("Schéma MN v3 EXE", 3) self.ui.cbb_schemas.addItem("Schéma MN v3 REC", 4) # self.ui.cbb_schemas.addItem("GraceTHD v2.1", 5) self.ui.cbb_schemas.currentIndexChanged.connect(self.update_layers_list) self.update_layers_list() def update_layers_list(self): schema_lib_name = SCHEMAS[int(self.ui.cbb_schemas.itemData(self.ui.cbb_schemas.currentIndex()))] schema_lib = importlib.import_module("schemas." + schema_lib_name) logger.info("Selection du schema '{%s}'", schema_lib) def run(self): pass # try: # f = request.FILES['dossier'] # except KeyError: # return render(request, "index.html", {"validation_error": "Aucun fichier sélectionné"}) # # filename = secure_filename(f.name) # # if Path(filename).ext != ".zip": # return render(request, "index.html", {"validation_error": "Le fichier doit être un fichier .ZIP ({})".format(Path(filename).ext)}) # # schema_lib_name = request.POST['schema'] # schema_lib = importlib.import_module("schemas." + schema_lib_name) # # # try: # with TemporaryDirectory(dir=MAIN / "upload") as d: # filename = Path(d) / filename # with open(filename, 'wb+') as destination: # for chunk in f.chunks(): # destination.write(chunk) # report = schema_lib.validator.submit(filename) # # except Exception as e: # # return render_template("index.html", validation_error=str(e)) # # return render(request, "report.html", {"report": report}) def show_help(self): pass def show_settings(self): pass