mirror of https://gitlab.com/pamhyr/pamhyr2
37 lines
1.0 KiB
Python
37 lines
1.0 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
from PyQt5.QtCore import QCoreApplication
|
|
|
|
from Checker.Checker import AbstractModelChecker, STATUS
|
|
|
|
_translate = QCoreApplication.translate
|
|
|
|
|
|
class StudyNetworkReachChecker(AbstractModelChecker):
|
|
def __init__(self):
|
|
super(StudyNetworkReachChecker, self).__init__()
|
|
|
|
self._name = _translate("Checker", "Study network reach checker")
|
|
self._description = _translate("Checker", "Check if exists at least one reach for study")
|
|
|
|
def run(self, study):
|
|
if study is None:
|
|
self._status = STATUS.ERROR
|
|
self._summary = "invalid_study"
|
|
return False
|
|
|
|
river = study.river
|
|
if river is None:
|
|
self._status = STATUS.ERROR
|
|
self._summary = "no_river_found"
|
|
return False
|
|
|
|
if len(river.edges()) == 0:
|
|
self._status = STATUS.ERROR
|
|
self._summary = "no_reach_defined"
|
|
return False
|
|
|
|
self._summary = "ok"
|
|
self._status = STATUS.OK
|
|
return True
|