|
|
|
|
@@ -168,8 +168,6 @@ def compare_pptx_files(file1_path, file2_path, **options):
|
|
|
|
|
for para1, para2 in zip(shape1.text_frame.paragraphs, shape2.text_frame.paragraphs):
|
|
|
|
|
# check if the runs are the same
|
|
|
|
|
for run1, run2 in zip(para1.runs, para2.runs):
|
|
|
|
|
if run1.text != run2.text and examine_text:
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
# check if the font properties are the same
|
|
|
|
|
if run1.font.name != run2.font.name and examine_font_name:
|
|
|
|
|
@@ -190,7 +188,8 @@ def compare_pptx_files(file1_path, file2_path, **options):
|
|
|
|
|
if run1.font.underline != run2.font.underline and examine_font_underline:
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
if run1.font._element.attrib.get('strike', 'noStrike') != run2.font._element.attrib.get('strike', 'noStrike') and examine_strike_through:
|
|
|
|
|
if run1.font._element.attrib.get('strike', 'noStrike') != run2.font._element.attrib.get(
|
|
|
|
|
'strike', 'noStrike') and examine_strike_through:
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
# fixme: Actually there are more properties to be compared, but we cannot get them through pptx
|
|
|
|
|
@@ -371,6 +370,50 @@ def check_page_number_colors(pptx_file, rules):
|
|
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def check_auto_saving_time(pptx_file, rules):
|
|
|
|
|
minutes = rules["minutes"]
|
|
|
|
|
|
|
|
|
|
# open and parse xml file
|
|
|
|
|
try:
|
|
|
|
|
tree = ET.parse(pptx_file)
|
|
|
|
|
root = tree.getroot()
|
|
|
|
|
|
|
|
|
|
# Traverse the XML tree to find the autosave time setting
|
|
|
|
|
autosave_time = None
|
|
|
|
|
for item in root.findall(".//item"):
|
|
|
|
|
# Check the path attribute
|
|
|
|
|
path = item.get('{http://openoffice.org/2001/registry}path')
|
|
|
|
|
if path == "/org.openoffice.Office.Common/Save/Document":
|
|
|
|
|
# Once the correct item is found, look for the prop element with the name "AutoSaveTimeIntervall"
|
|
|
|
|
for prop in item.findall(".//prop"):
|
|
|
|
|
name = prop.get('{http://openoffice.org/2001/registry}name')
|
|
|
|
|
if name == "AutoSaveTimeIntervall":
|
|
|
|
|
# Extract the value of the autosave time interval
|
|
|
|
|
autosave_time = prop.find(".//value").text
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
if autosave_time is None:
|
|
|
|
|
return 0
|
|
|
|
|
else:
|
|
|
|
|
autosave_time = int(autosave_time)
|
|
|
|
|
if autosave_time == minutes:
|
|
|
|
|
return 1
|
|
|
|
|
else:
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
except ET.ParseError as e:
|
|
|
|
|
logger.error(f"Error parsing XML: {e}")
|
|
|
|
|
except FileNotFoundError:
|
|
|
|
|
logger.error(f"File not found: {pptx_file}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
print(compare_pptx_files(r"C:\Users\tianbaox\Desktop\DesktopEnv\cache\550ce7e7-747b-495f-b122-acdc4d0b8e54\New_Club_Spring_2018_Training_Gold.pptx", r"C:\Users\tianbaox\Desktop\DesktopEnv\cache\550ce7e7-747b-495f-b122-acdc4d0b8e54\New_Club_Spring_2018_Training_Gold.pptx"))
|
|
|
|
|
# print(evaluate_presentation_fill_to_rgb_distance(r"C:\Users\tianbaox\Desktop\DesktopEnv\cache\3b27600c-3668-4abd-8f84-7bcdebbccbdb\lec17-gui-events.pptx", {"rgb": (0, 0, 255)}))
|
|
|
|
|
# print(compare_pptx_files(
|
|
|
|
|
# r"C:\Users\tianbaox\Desktop\DesktopEnv\cache\550ce7e7-747b-495f-b122-acdc4d0b8e54\New_Club_Spring_2018_Training_Gold.pptx",
|
|
|
|
|
# r"C:\Users\tianbaox\Desktop\DesktopEnv\cache\550ce7e7-747b-495f-b122-acdc4d0b8e54\New_Club_Spring_2018_Training_Gold.pptx"))
|
|
|
|
|
# print(evaluate_presentation_fill_to_rgb_distance(r"C:\Users\tianbaox\Desktop\DesktopEnv\cache\3b27600c-3668-4abd-8f84-7bcdebbccbdb\lec17-gui-events.pptx", {"rgb": (0, 0, 255)}))
|
|
|
|
|
# print(check_auto_saving_time(r"C:\Users\tianbaox\Desktop\DesktopEnv\cache\2cd43775-7085-45d8-89fa-9e35c0a915cf\registrymodifications.xcu", {"minutes": 3}))
|
|
|
|
|
print(compare_pptx_files(r"C:\Users\tianbaox\Desktop\DesktopEnv\cache\a669ef01-ded5-4099-9ea9-25e99b569840\Writing-Outlines.pptx",
|
|
|
|
|
r"C:\Users\tianbaox\Desktop\DesktopEnv\cache\a669ef01-ded5-4099-9ea9-25e99b569840\Writing-Outlines_Gold.pptx",
|
|
|
|
|
examine_shape=False))
|
|
|
|
|
|