From 3c0ee0673e2cdb10a156d6f3531c5892cc3fd186 Mon Sep 17 00:00:00 2001 From: Marina Date: Wed, 8 Nov 2023 13:41:04 +0300 Subject: [PATCH] resolve conflicts --- app/main/reports/README.md | 9 ---- app/main/reports/md_uploader/md_uploader.py | 56 --------------------- requirements.txt | 4 -- 3 files changed, 69 deletions(-) diff --git a/app/main/reports/README.md b/app/main/reports/README.md index 6397fc34..ad84a14a 100644 --- a/app/main/reports/README.md +++ b/app/main/reports/README.md @@ -65,19 +65,10 @@ Proof-of-concept парсинг файлов `.docx` с выводом стру ```bash $ python3 -m app.main.mse22.pdf_document text_from_pages --filename path_to_file ``` -<<<<<<< HEAD -======= - ->>>>>>> master ## `MD` Парсинг файлов `.md` с выводом структуры файла в текстовом виде в stdout. ```bash $ python3 -m app.main.reports.md_uploader md_parser --mdfile path_to_md_file -<<<<<<< HEAD -``` -======= ``` - ->>>>>>> master diff --git a/app/main/reports/md_uploader/md_uploader.py b/app/main/reports/md_uploader/md_uploader.py index e3de1e51..25346ffc 100644 --- a/app/main/reports/md_uploader/md_uploader.py +++ b/app/main/reports/md_uploader/md_uploader.py @@ -1,4 +1,3 @@ -<<<<<<< HEAD '''Available checks for md-file: pack "BaseReportCriterionPackMd" @@ -83,27 +82,10 @@ def __init__(self, path_to_md_file): self.inline_shapes = [] def upload(self): -======= -import markdown #installation: pip install markdown -import re - -class MdUpload: - def __init__(self, path_to_md_file): - self.path_to_md_file = path_to_md_file - self.headers = [] - self.chapters = [] - self.paragraphs = [] - self.html_text = '' - self.tables = [] - self.chapter_with_text = [] - - def read_md_file(self): ->>>>>>> master with open(self.path_to_md_file, "r", encoding="utf-8") as f: md_text = f.read() return md_text -<<<<<<< HEAD def parse(self, md_text): self.html_text = markdown.markdown(md_text) self.paragraphs = self.make_paragraphs(self.html_text) @@ -219,29 +201,6 @@ def find_images(self): total_height += width self.inline_shapes.append((width, height)) return self.inline_shapes -======= - def get_html_from_md(self, md_text): - self.html_text = markdown.markdown(md_text) - self.paragraphs = self.html_text.split('\n') - - def get_headers(self): - header_regex = "

(.*?)<\/h1>" - self.headers = re.findall(header_regex, self.html_text) - - def get_chapters(self): - chapter_regex = "

(.*?)<\/h2>" - self.chapters = re.findall(chapter_regex, self.html_text) - - def get_chapter_with_text(self): - text = self.html_text - chapter_name = '' - for chapter in self.chapters: - self.split_chapter = text.split("

" + chapter + "

") - self.chapter_with_text.append(chapter_name + self.split_chapter[-2]) - chapter_name = chapter - text = self.split_chapter[-1] - self.chapter_with_text.append(chapter_name + text) ->>>>>>> master def get_tables_size(self): count_table_line = 0 @@ -251,7 +210,6 @@ def get_tables_size(self): count_table_line +=1 return round(count_table_line/count_paragraph, 4) -<<<<<<< HEAD def find_literature_vkr(self, work_type): if not self.literature_header: for header in self.make_chapters(work_type): @@ -273,21 +231,7 @@ def parse_md_file(self): self.find_literature_vkr(work_type="VKR") return f"Заголовки:\n{self.headers_main}\n\nГлавы\n{self.chapters}\n\nИзображения:\n\n{self.inline_shapes}" -======= - def parse_md_file(self): - md_text = self.read_md_file() - self.get_html_from_md(md_text) - self.get_headers() - self.get_chapters() - self.get_chapter_with_text() - self.get_tables_size() - return f"Заголовки:\n{self.headers}\n\nГлавы:\n{self.chapters}\n\nГлавы с текстом:\n{self.chapter_with_text}\n\nДоля таблиц в тексте:\n{self.get_tables_size()}" ->>>>>>> master def main(args): md_file = MdUpload(args.mdfile) print(md_file.parse_md_file()) -<<<<<<< HEAD -======= - ->>>>>>> master diff --git a/requirements.txt b/requirements.txt index 3aa2e61f..f29f2e0b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -27,9 +27,5 @@ pdfplumber==0.6.1 pytest~=7.1.2 filetype==1.2.0 language-tool-python==2.7.1 -<<<<<<< HEAD markdown md2pdf -======= -markdown==3.4.4 ->>>>>>> master