Skip to content

Commit

Permalink
Merge pull request #448 from moevm/426_min_and_max_lit_references
Browse files Browse the repository at this point in the history
add min and max border lit_references
  • Loading branch information
HadronCollider authored Nov 17, 2023
2 parents c46bda2 + 386f1a5 commit 342728e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions app/main/checks/report_checks/literature_references.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ class ReferencesToLiteratureCheck(BaseReportCriterion):
description = "Проверка наличия ссылок на все источники"
id = 'literature_references'

def __init__(self, file_info):
def __init__(self, file_info, min_ref=1, max_ref=1000):
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

def late_init_vkr(self):
self.headers = self.file.make_chapters(self.file_type['report_type'])
Expand Down Expand Up @@ -47,7 +49,10 @@ def check(self):
for i in range(1, number_of_sources + 1):
all_numbers.add(i)
if len(references.symmetric_difference(all_numbers)) == 0:
return answer(True, f"Пройдена!")
if not self.min_ref <= number_of_sources <= self.max_ref:
return answer(False, f'Список источников оформлен верно, однако их количество ({number_of_sources}) не удовлетворяет необходимому критерию. <br> Количество источников должно быть от {self.min_ref} до {self.max_ref}.')
else:
return answer(True, f"Пройдена!")
elif len(references.difference(all_numbers)):
if len(all_numbers.difference(references)) == 0:
references -= all_numbers
Expand Down Expand Up @@ -137,4 +142,4 @@ def search_literature_start_pdf(self):
if re.search('приложение а[\n .]', lowercase_str):
end_page = i
break
return start_page, end_page
return start_page, end_page

0 comments on commit 342728e

Please sign in to comment.