From f0cd5408e30ff8c27c0b6192db02716a9390e4ee Mon Sep 17 00:00:00 2001 From: Marina Date: Thu, 29 Aug 2024 20:11:47 +0300 Subject: [PATCH] check min and max literature ref is added --- .../checks/report_checks/literature_references.py | 14 +++++++++----- .../checks/report_checks/style_check_settings.py | 2 ++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/main/checks/report_checks/literature_references.py b/app/main/checks/report_checks/literature_references.py index 96f71791..4be154ab 100644 --- a/app/main/checks/report_checks/literature_references.py +++ b/app/main/checks/report_checks/literature_references.py @@ -1,5 +1,5 @@ import re - +from .style_check_settings import StyleCheckSettings from ..base_check import BaseReportCriterion, answer @@ -8,13 +8,17 @@ class ReferencesToLiteratureCheck(BaseReportCriterion): description = '' id = 'literature_references' - def __init__(self, file_info, min_ref=1, max_ref=1000): + def __init__(self, file_info, min_ref=1, max_ref=1000, headers_map=None): super().__init__(file_info) self.headers = [] self.literature_header = [] self.name_pattern = r'список[ \t]*(использованных|использованной|)[ \t]*(источников|литературы)' - self.min_ref = min_ref - self.max_ref = max_ref + if headers_map: + self.min_ref = StyleCheckSettings.CONFIGS.get(headers_map)['min_ref_for_literature_references_check'] + self.max_ref = StyleCheckSettings.CONFIGS.get(headers_map)['mах_ref_for_literature_references_check'] + else: + self.min_ref = min_ref + self.max_ref = max_ref def late_init_vkr(self): self.headers = self.file.make_chapters(self.file_type['report_type']) @@ -51,7 +55,7 @@ def check(self): all_numbers.add(i) if len(references.symmetric_difference(all_numbers)) == 0: if not self.min_ref <= number_of_sources <= self.max_ref: - return answer(False, f'Список источников оформлен верно, однако их количество ({number_of_sources}) не удовлетворяет необходимому критерию.
Количество источников должно быть от {self.min_ref} до {self.max_ref}.') + return answer(False, f'Список источников оформлен верно, однако их количество ({number_of_sources}) не удовлетворяет необходимому критерию.
Количество источников должно быть не менее {self.min_ref}.') else: return answer(True, f"Пройдена!") elif len(references.difference(all_numbers)): diff --git a/app/main/checks/report_checks/style_check_settings.py b/app/main/checks/report_checks/style_check_settings.py index a7d9308f..0462d950 100644 --- a/app/main/checks/report_checks/style_check_settings.py +++ b/app/main/checks/report_checks/style_check_settings.py @@ -204,6 +204,8 @@ class StyleCheckSettings: "unify_regex": None, "regex": HEADER_REGEX }, + 'min_ref_for_literature_references_check': 5, + 'mах_ref_for_literature_references_check': 1000, #just for future possible edit }