-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathformatter.py
More file actions
32 lines (23 loc) · 909 Bytes
/
formatter.py
File metadata and controls
32 lines (23 loc) · 909 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from docx import Document
from os import path
from main_req_formatter import MainRequirementsFormatter
from source_links_formatter import SourceLinksFormatter
import argparse
def main():
parser = argparse.ArgumentParser()
parser.add_argument('path_to_docx', type=str, help='Path to docx file')
args = parser.parse_args()
if not path.exists(args.path_to_docx) or not path.isfile(args.path_to_docx):
print('Введен неверный путь до файла')
exit(1)
try:
doc = Document(args.path_to_docx)
except ValueError:
print('Документ должен быть типа docx')
exit(1)
MainRequirementsFormatter.format_document(doc)
MainRequirementsFormatter.change_title_page_year(doc, '2023')
SourceLinksFormatter.check_for_links_presence(doc)
doc.save("edited.docx")
if __name__ == '__main__':
main()