Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/main/checks/report_checks/literature_references.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 17 additions & 1 deletion app/main/checks/report_checks/main_character_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ class ReportMainCharacterCheck(BaseReportCriterion):
_description = ""
id = "main_character_check"
priority = True
calendar_plan_table_marker = "Наименование работ"

def __init__(self, file_info, tables_count_to_verify=8, edu_degree='bsc'):
super().__init__(file_info)
self.headers = []
self.first_check_list = None
self.second_check_list = None
self.calendar_plan_check_list = None
self.tables_count_to_verify = tables_count_to_verify
self.edu_degree = edu_degree

Expand All @@ -25,6 +27,7 @@ def late_init(self):
def check(self):
self.first_check_list = copy.deepcopy(ReportMainPageSetting.get_first_table(self.edu_degree))
self.second_check_list = copy.deepcopy(ReportMainPageSetting.SECOND_TABLE)
self.calendar_plan_check_list = copy.deepcopy(ReportMainPageSetting.CALENDAR_PLAN_TABLE)
if self.file.page_counter() < 4:
return answer(False, "В отчете недостаточно страниц. Нечего проверять.")
if self.tables_count_to_verify > len(self.file.tables):
Expand All @@ -33,6 +36,7 @@ def check(self):
f"Количество таблиц на страницах титульного листа, задания и календарного плана должно быть не меньше {self.tables_count_to_verify}", # noqa: E501
)
self.late_init()
calendar_table_index = self.find_calendar_plan_table_index()
result_str = ""
pages = []
for header in self.headers:
Expand All @@ -43,9 +47,11 @@ def check(self):
extract_table = self.extract_table_contents(table)
self.check_table(self.first_check_list, extract_table, i + 1)
self.check_table(self.second_check_list, extract_table, i + 1)
if i == calendar_table_index:
self.check_table(self.calendar_plan_check_list, extract_table, i + 1)
links = self.format_page_link(pages)
result_score = 1.0
check_result = self.first_check_list + self.second_check_list
check_result = self.first_check_list + self.second_check_list + self.calendar_plan_check_list
penalty_score = 1 / len(check_result)
for res in check_result:
if res["found_key"] > 1 and res["key"] == "Консультант":
Expand All @@ -72,6 +78,16 @@ def check(self):
)
return answer(result_score, result_str)

def find_calendar_plan_table_index(self):
for i in range(self.tables_count_to_verify):
rows = self.extract_table_contents(self.file.tables[i])
if not rows:
continue
columns = rows[0].split("|")
if len(columns) >= 2 and self.calendar_plan_table_marker in columns[1]:
return i
return None

def extract_table_contents(self, table):
contents = []
processed_cells = set()
Expand Down
17 changes: 16 additions & 1 deletion app/main/checks/report_checks/main_page_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ class ReportMainPageSetting:
"found_value": 0,
"found_key": 0,
"find": 3,
"value": [r"(Руководитель).*([кд]\..+\.н\., (доцент|профессор))[|]*([А-Я](?:\.-?[А-Я])?\.[А-Я]\. [А-Я][а-я]+)"], #
"value": [
r"(Руководитель).*([кд]\..+\.н\., (доцент|профессор))[|]*([А-Я](?:\.-?[А-Я])?\.[А-Я]\. [А-Я][а-я]+)"
], #
"logs": "",
},
{
Expand All @@ -75,6 +77,19 @@ class ReportMainPageSetting:
"logs": "",
},
]
CALENDAR_PLAN_TABLE = [
{
"key": "Предзащита",
"found_value": 0,
"found_key": 0,
"find": 1,
"value": [
# |ДД.ММ| в правой колонке, например |01.05| после склейки
r"\|((0[1-9]|[12]\d|3[01])\.(0[1-9]|1[0-2]))(\||$)",
],
"logs": "",
},
]

@classmethod
def get_first_table(cls, edu_degree='bsc'):
Expand Down
13 changes: 8 additions & 5 deletions app/utils/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading