-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
39 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[flake8] | ||
max-line-length = 88 | ||
extend-ignore = E203 | ||
|
||
exclude = | ||
.tx, | ||
build, | ||
docker, | ||
LDMP/ext-libs, | ||
*.ipynb_checkpoints* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,12 +10,13 @@ | |
email : [email protected] | ||
***************************************************************************/ | ||
""" | ||
from __future__ import annotations | ||
|
||
import json | ||
import os | ||
import re | ||
import typing | ||
from copy import deepcopy | ||
from enum import Enum | ||
from pathlib import Path | ||
|
||
from marshmallow.exceptions import ValidationError | ||
|
@@ -25,7 +26,6 @@ | |
from qgis.PyQt import QtGui | ||
from qgis.PyQt import QtWidgets | ||
from qgis.PyQt import uic | ||
from qgis.utils import iface | ||
from te_schemas.land_cover import LCClass | ||
from te_schemas.land_cover import LCLegend | ||
from te_schemas.land_cover import LCLegendNesting | ||
|
@@ -1425,10 +1425,10 @@ class LandCoverSetupRemoteExecutionWidget( | |
def __init__( | ||
self, | ||
parent=None, | ||
hide_min_year: typing.Optional[bool] = False, | ||
hide_max_year: typing.Optional[bool] = False, | ||
selected_min_year: typing.Optional[int] = 2001, | ||
selected_max_year: typing.Optional[int] = 2015, | ||
hide_min_year: bool | None = False, | ||
hide_max_year: bool | None = False, | ||
selected_min_year: int | None = 2001, | ||
selected_max_year: int | None = 2015, | ||
): | ||
super().__init__(parent) | ||
self.setupUi(self) | ||
|
@@ -1480,9 +1480,7 @@ class LccInfoUtils: | |
CUSTOM_LEGEND_NAME = "Custom Land Cover" | ||
|
||
@staticmethod | ||
def save_settings( | ||
lcc_infos: typing.List["LCClassInfo"] = [], restore_default=True | ||
) -> bool: | ||
def save_settings(lcc_infos: list[LCClassInfo] = [], restore_default=True) -> bool: | ||
""" | ||
Saves list of LCClassInfo objects to settings but if settings is | ||
empty and 'restore_default' is True then it will restore the default | ||
|
@@ -1504,9 +1502,9 @@ def save_settings( | |
lcc_str = LCClassInfo.Schema().dumps(lcc) | ||
infos.append(lcc_str) | ||
conf.settings_manager.write_value(conf.Setting.LC_CLASSES, infos) | ||
except ValidationError as ve: | ||
except ValidationError: | ||
status = False | ||
except Exception as exc: | ||
except Exception: | ||
status = False | ||
|
||
# Update transition matrix and land cover nesting with our new custom | ||
|
@@ -1522,7 +1520,7 @@ def save_settings( | |
return status | ||
|
||
@staticmethod | ||
def load_settings() -> typing.Tuple[bool, typing.List["LCClassInfo"]]: | ||
def load_settings() -> tuple[bool, list[LCClassInfo]]: | ||
""" | ||
Loads LCCInfo objects from the settings. | ||
""" | ||
|
@@ -1535,26 +1533,26 @@ def load_settings() -> typing.Tuple[bool, typing.List["LCClassInfo"]]: | |
lcc_info = LCClassInfo.Schema().loads(lcc_info_str) | ||
lcc_infos.append(lcc_info) | ||
|
||
except ValidationError as ve: | ||
except ValidationError: | ||
status = False | ||
|
||
except Exception as exc: | ||
except Exception: | ||
status = False | ||
|
||
return status, lcc_infos | ||
|
||
@staticmethod | ||
def save_file(file_path: str, lcc_infos: typing.List["LCClassInfo"]) -> bool: | ||
def save_file(file_path: str, lcc_infos: list[LCClassInfo]) -> bool: | ||
# Saves the LC classes to JSON file. | ||
lc_cls_infos = [] | ||
status = True | ||
try: | ||
for lcc in lcc_infos: | ||
lcc_dict = LCClassInfo.Schema().dump(lcc) | ||
lc_cls_infos.append(lcc_dict) | ||
except ValidationError as ve: | ||
except ValidationError: | ||
status = False | ||
except Exception as exc: | ||
except Exception: | ||
status = False | ||
|
||
if not status: | ||
|
@@ -1577,7 +1575,7 @@ def save_file(file_path: str, lcc_infos: typing.List["LCClassInfo"]) -> bool: | |
return True | ||
|
||
@staticmethod | ||
def load_file(file_path: str) -> typing.Tuple[bool, typing.List["LCClassInfo"]]: | ||
def load_file(file_path: str) -> tuple[bool, list[LCClassInfo]]: | ||
# Load classes from file. | ||
fi = QtCore.QFileInfo(file_path) | ||
cls_dir = fi.dir().path() | ||
|
@@ -1608,8 +1606,8 @@ def load_file(file_path: str) -> typing.Tuple[bool, typing.List["LCClassInfo"]]: | |
|
||
@staticmethod | ||
def lcc_in_infos( | ||
lcc: LCClass, lcc_infos: typing.List["LCClassInfo"] | ||
) -> typing.Tuple[bool, "LCClassInfo"]: | ||
lcc: LCClass, lcc_infos: list[LCClassInfo] | ||
) -> tuple[bool, LCClassInfo]: | ||
""" | ||
Checks if the given lc class is in the collection using | ||
code to compare. | ||
|
@@ -1632,7 +1630,7 @@ def lc_nesting() -> LCLegendNesting: | |
return nesting | ||
|
||
@staticmethod | ||
def sync_trans_matrix(ref_lcc_infos: typing.List["LCClassInfo"]): | ||
def sync_trans_matrix(ref_lcc_infos: list[LCClassInfo]): | ||
""" | ||
Update transition matrix in settings with custom classes in the | ||
reference list. | ||
|
@@ -1713,7 +1711,7 @@ def sync_trans_matrix(ref_lcc_infos: typing.List["LCClassInfo"]): | |
) | ||
|
||
@staticmethod | ||
def save_lc_nesting_ipcc(ref_lcc_infos: typing.List["LCClassInfo"]): | ||
def save_lc_nesting_ipcc(ref_lcc_infos: list[LCClassInfo]): | ||
""" | ||
Save IPCC land cover nesting to settings. | ||
|
@@ -1775,7 +1773,7 @@ def save_lc_nesting_ipcc(ref_lcc_infos: typing.List["LCClassInfo"]): | |
) | ||
|
||
@staticmethod | ||
def save_lc_nesting_esa(ref_lcc_infos: typing.List["LCClassInfo"]): | ||
def save_lc_nesting_esa(ref_lcc_infos: list[LCClassInfo]): | ||
""" | ||
Save ESA land cover nesting to settings. | ||
|
@@ -1873,7 +1871,7 @@ def save_lc_nesting_esa(ref_lcc_infos: typing.List["LCClassInfo"]): | |
) | ||
|
||
@staticmethod | ||
def sync_lc_nesting(ref_lcc_infos: typing.List["LCClassInfo"]): | ||
def sync_lc_nesting(ref_lcc_infos: list[LCClassInfo]): | ||
""" | ||
Updates both IPCC and ESA land cover nestings in settings. | ||
""" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,13 @@ | ||
""" | ||
/*************************************************************************** | ||
LDMP - A QGIS plugin | ||
This plugin supports monitoring and reporting of land degradation to the UNCCD | ||
and in support of the SDG Land Degradation Neutrality (LDN) target. | ||
------------------- | ||
begin : 2017-05-23 | ||
git sha : $Format:%H$ | ||
copyright : (C) 2017 by Conservation International | ||
email : [email protected] | ||
***************************************************************************/ | ||
""" | ||
from future import standard_library | ||
|
||
standard_library.install_aliases() | ||
import sys | ||
import time | ||
|
||
import qgis.gui | ||
from qgis.utils import iface | ||
from qgis.core import Qgis | ||
|
||
from qgis.PyQt import QtCore | ||
from qgis.PyQt.QtCore import QThread, Qt, QEventLoop, QCoreApplication | ||
from qgis.PyQt.QtWidgets import QProgressBar, QPushButton | ||
from qgis.PyQt.QtCore import QCoreApplication | ||
from qgis.PyQt.QtCore import QEventLoop | ||
from qgis.PyQt.QtCore import Qt | ||
from qgis.PyQt.QtCore import QThread | ||
from qgis.PyQt.QtWidgets import QProgressBar | ||
from qgis.PyQt.QtWidgets import QPushButton | ||
from qgis.utils import iface | ||
|
||
from .logger import log | ||
|
||
|