load libreoffice writer eval -batch 2
This commit is contained in:
@@ -56,15 +56,34 @@ def compare_docx_files(file1, file2):
|
||||
doc2_paragraphs = [p.text for p in doc2.paragraphs]
|
||||
|
||||
if len(doc1_paragraphs) != len(doc2_paragraphs):
|
||||
# print(len(doc1_paragraphs))
|
||||
# print(len(doc2_paragraphs))
|
||||
return 0
|
||||
|
||||
# Compare each paragraph
|
||||
for p1, p2 in zip(doc1_paragraphs, doc2_paragraphs):
|
||||
if p1 != p2:
|
||||
# print(p1)
|
||||
# print(p2)
|
||||
return 0
|
||||
|
||||
return 1
|
||||
|
||||
def compare_init_lines(file1, file2):
|
||||
doc1 = Document(file1)
|
||||
doc2 = Document(file2)
|
||||
|
||||
doc1_paragraphs = [p.text for p in doc1.paragraphs]
|
||||
doc2_paragraphs = [p.text for p in doc2.paragraphs]
|
||||
|
||||
# Compare each paragraph
|
||||
for p1, p2 in zip(doc1_paragraphs, doc2_paragraphs):
|
||||
if p1 != p2:
|
||||
# print(p1)
|
||||
# print(p2)
|
||||
return 0
|
||||
|
||||
return 1
|
||||
|
||||
def compare_docx_tables(docx_file1, docx_file2):
|
||||
doc1 = Document(docx_file1)
|
||||
@@ -93,6 +112,8 @@ def compare_docx_tables(docx_file1, docx_file2):
|
||||
|
||||
|
||||
def compare_line_spacing(docx_file1, docx_file2):
|
||||
if not compare_docx_files(docx_file1, docx_file2):
|
||||
return 0
|
||||
doc1 = Document(docx_file1)
|
||||
doc2 = Document(docx_file2)
|
||||
|
||||
@@ -200,8 +221,10 @@ def compare_contains_image(docx_file1, docx_file2):
|
||||
# print(find_default_font("Ani", config_path))
|
||||
|
||||
|
||||
def evaluate_colored_words_in_tables(file_path):
|
||||
document = Document(file_path)
|
||||
def evaluate_colored_words_in_tables(file_path1, file_path2):
|
||||
if not compare_docx_files(file_path1, file_path2):
|
||||
return 0
|
||||
document = Document(file_path1)
|
||||
|
||||
for table in document.tables:
|
||||
# Iterate through rows and cells in the table
|
||||
@@ -221,8 +244,10 @@ def evaluate_colored_words_in_tables(file_path):
|
||||
return 1 # All words in tables are correctly colored
|
||||
|
||||
|
||||
def check_highlighted_words(file_path):
|
||||
document = Document(file_path)
|
||||
def check_highlighted_words(file_path1, file_path2):
|
||||
if not compare_docx_files(file_path1, file_path2):
|
||||
return 0
|
||||
document = Document(file_path1)
|
||||
|
||||
for paragraph in document.paragraphs:
|
||||
for run in paragraph.runs:
|
||||
@@ -232,8 +257,10 @@ def check_highlighted_words(file_path):
|
||||
return 1 # No highlighted words found
|
||||
|
||||
|
||||
def evaluate_strike_through_last_paragraph(file_path):
|
||||
document = Document(file_path)
|
||||
def evaluate_strike_through_last_paragraph(file_path1, file_path2):
|
||||
if not compare_docx_files(file_path1, file_path2):
|
||||
return 0
|
||||
document = Document(file_path1)
|
||||
|
||||
# Get the last paragraph
|
||||
last_paragraph = document.paragraphs[-1]
|
||||
@@ -278,8 +305,10 @@ def evaluate_spacing(file_path):
|
||||
return 0
|
||||
|
||||
|
||||
def check_italic_font_size_14(path):
|
||||
document = Document(path)
|
||||
def check_italic_font_size_14(path1, path2):
|
||||
if not compare_docx_files(path1, path2):
|
||||
return 0
|
||||
document = Document(path1)
|
||||
for paragraph in document.paragraphs:
|
||||
for run in paragraph.runs:
|
||||
if run.italic:
|
||||
@@ -365,6 +394,8 @@ def compare_docx_lines(file1, file2):
|
||||
|
||||
doc2 = Document(file2)
|
||||
doc2_lines = [p.text.strip() for p in doc2.paragraphs if p.text.strip()]
|
||||
# print(doc1_lines)
|
||||
# print(doc2_lines)
|
||||
|
||||
# Convert the list of lines to sets and compare
|
||||
return set(doc1_lines) == set(doc2_lines)
|
||||
|
||||
Reference in New Issue
Block a user