diff --git a/app/main/check_packs/pack_config.py b/app/main/check_packs/pack_config.py index d31bc3c1..4c5346e2 100644 --- a/app/main/check_packs/pack_config.py +++ b/app/main/check_packs/pack_config.py @@ -54,6 +54,7 @@ ["water_in_the_text_check"], ["report_task_tracker"], ["report_was_were_check"], + ["report_intervals_paragraphs_check"], ] DEFAULT_TYPE = 'pres' diff --git a/app/main/checks/report_checks/intervals_between_paragraphs.py b/app/main/checks/report_checks/intervals_between_paragraphs.py new file mode 100644 index 00000000..0fd4305a --- /dev/null +++ b/app/main/checks/report_checks/intervals_between_paragraphs.py @@ -0,0 +1,47 @@ +from ..base_check import answer, BaseReportCriterion + + +class ReportIntervalsParagraphsCheck(BaseReportCriterion): + label = "Проверка значений интервалов между абзацами" + _description = "Межстрочный интервал должен быть равен 1.5, а интервал до и после абзаца сответсвенно равен 0pt" + id = "report_intervals_paragraphs_check" + + def __init__(self, file_info, max_line_spacing=1.5, max_space=12, max_indent=1.5): + super().__init__(file_info) + self.max_line_spacing = max_line_spacing + self.max_space = max_space + self.max_indent = max_indent + + def check(self): + try: + problematic_paragraphs = [] + + for i, paragraph in enumerate(self.file.paragraphs): + if not paragraph.paragraph_text or "heading" in paragraph.paragraph_style_name: + continue + + if ( + (paragraph.paragraph_space_after is not None and paragraph.paragraph_space_after != 0) + or (paragraph.paragraph_space_before is not None and paragraph.paragraph_space_before != 0) + or (paragraph.paragraph_line_spacing is not None and paragraph.paragraph_line_spacing != 1.5) + ): + preview_paragraph = paragraph.paragraph_text[:40].strip() + problematic_paragraphs.append({"preview": preview_paragraph, "number_paragraph": i}) + + if problematic_paragraphs: + details = "
".join( + [ + f"абзац (до первых 40 символов): {par['preview']} - номер параграфа: {par['number_paragraph']}" + for par in problematic_paragraphs + ] + ) + + return answer( + False, + f"Абзацы в работе имеют нерекомендованные интервалы: {details}", + ) + + return answer(True, "Все абзацы имеют рекомендованные интервалы") + + except Exception as e: + return answer(False, f"Ошибка при проверке интервалов: {str(e)}") diff --git a/app/main/checks/report_checks/literature_references.py b/app/main/checks/report_checks/literature_references.py index ba550d3d..8d95bd59 100644 --- a/app/main/checks/report_checks/literature_references.py +++ b/app/main/checks/report_checks/literature_references.py @@ -156,7 +156,7 @@ def search_references(self, start_par): match = re.search(r'Таблица ([.\d]+)', paragraph_text) table_text = '' if match: - index_table += 1 # int(match.group(1)) - 1 # TODO: fix logic + index_table += 1 # int(match.group(1)) - 1 # TODO: fix logic table_text = self.get_text_in_table(index_table) paragraph_text += table_text diff --git a/app/main/checks/report_checks/main_page_settings.py b/app/main/checks/report_checks/main_page_settings.py index e0ed9f06..bd50dab0 100644 --- a/app/main/checks/report_checks/main_page_settings.py +++ b/app/main/checks/report_checks/main_page_settings.py @@ -60,7 +60,9 @@ class ReportMainPageSetting: "found_value": 0, "found_key": 0, "find": 3, - "value": [r"(Руководитель).*([кд]\..+\.н\., (доцент|профессор))[|]*([А-Я](?:\.-?[А-Я])?\.[А-Я]\. [А-Я][а-я]+)"], # + "value": [ + r"(Руководитель).*([кд]\..+\.н\., (доцент|профессор))[|]*([А-Я](?:\.-?[А-Я])?\.[А-Я]\. [А-Я][а-я]+)" + ], # "logs": "", }, { diff --git a/app/main/checks/report_checks/style_check_settings.py b/app/main/checks/report_checks/style_check_settings.py index 44ebc054..53e0d664 100644 --- a/app/main/checks/report_checks/style_check_settings.py +++ b/app/main/checks/report_checks/style_check_settings.py @@ -214,6 +214,25 @@ class StyleCheckSettings: }, } + IND_PRAC_CONFIG = { + 'any_header': { + "style": HEADER_1_STYLE, + "docx_style": ["heading 2"], + "headers": [ + "ВВЕДЕНИЕ", + "ПОСТАНОВКА ЗАДАЧИ", + "РЕЗУЛЬТАТЫ РАБОТЫ", + "ИСПОЛЬЗУЕМЫЕ ТЕХНОЛОГИИ", + "ОТЗЫВ РУКОВОДИТЕЛЯ", + "ЗАКЛЮЧЕНИЕ", + ], + "unify_regex": None, + "regex": HEADER_REGEX, + "banned_words": STD_BANNED_WORDS, + "warned_words": STD_WARNED_WORDS, + }, + } + NIR1_CONFIG = { 'any_header': { "style": HEADER_1_STYLE, @@ -393,6 +412,7 @@ class StyleCheckSettings: 'LR_MAIN_TEXT': LR_MAIN_TEXT_CONFIG, 'VKR_HEADERS': VKR_CONFIG, 'VKR_MAIN_TEXT': VKR_MAIN_TEXT_CONFIG, + 'IND_PRAC_CONFIG': IND_PRAC_CONFIG, 'NIR_HEADERS': NIR2_CONFIG, 'NIR1_HEADERS': NIR1_CONFIG, 'NIR2_HEADERS': NIR2_CONFIG, diff --git a/app/utils/converter.py b/app/utils/converter.py index 821cc976..2c051eba 100644 --- a/app/utils/converter.py +++ b/app/utils/converter.py @@ -9,11 +9,14 @@ def run_process(cmd: str): def convert_to(filepath, target_format='pdf'): new_filename, outdir = None, dirname(filepath) - convert_cmd = "timeout 3m " + { - 'pdf': f"soffice --headless --convert-to pdf --outdir {outdir} {filepath}", - 'docx': f"soffice --headless --convert-to docx --outdir {outdir} {filepath}", - 'pptx': f"soffice --headless --convert-to pptx --outdir {outdir} {filepath}", - }[target_format] + convert_cmd = ( + "timeout 3m " + + { + 'pdf': f"soffice --headless --convert-to pdf --outdir {outdir} {filepath}", + 'docx': f"soffice --headless --convert-to docx --outdir {outdir} {filepath}", + 'pptx': f"soffice --headless --convert-to pptx --outdir {outdir} {filepath}", + }[target_format] + ) if run_process(convert_cmd).returncode == 0: # success conversion