Fix Impress examples
This commit is contained in:
@@ -13,6 +13,8 @@ def get_vm_command_line(env, config: Dict[str, str]):
|
||||
|
||||
response = requests.post(f"http://{vm_ip}:{port}/execute", json={"command": command, "shell": shell})
|
||||
|
||||
print(response.json())
|
||||
|
||||
if response.status_code == 200:
|
||||
return response.json()["output"]
|
||||
else:
|
||||
|
||||
@@ -31,9 +31,7 @@ from .docs import (
|
||||
evaluate_alignment,
|
||||
get_unique_train_ids,
|
||||
check_no_duplicates,
|
||||
compare_init_lines
|
||||
)
|
||||
from .docs import (
|
||||
compare_init_lines,
|
||||
find_default_font,
|
||||
contains_page_break,
|
||||
compare_docx_files,
|
||||
@@ -87,7 +85,8 @@ from .slides import (
|
||||
evaluate_presentation_fill_to_rgb_distance,
|
||||
check_left_panel,
|
||||
check_transition,
|
||||
check_page_number_colors
|
||||
check_page_number_colors,
|
||||
check_auto_saving_time
|
||||
)
|
||||
from .table import (
|
||||
compare_table,
|
||||
|
||||
@@ -46,7 +46,6 @@ def check_text_enlarged(scaling_factor_str):
|
||||
|
||||
|
||||
def check_moved_jpgs(directory_list, rule):
|
||||
|
||||
expected_jpgs = rule["expected"]
|
||||
moved_jpgs = [node['name'] for node in directory_list['children']]
|
||||
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"id": "071d4ace-091a-4ec3-886e-f4be55ae375d",
|
||||
"snapshot": "libreoffice_impress",
|
||||
"instruction": "Please hide slide numbers and slide footer on first and second slide",
|
||||
"source": "https://superuser.com/questions/706860/hide-slide-numbers-and-slide-footer-on-first-and-second-slide-in-libreoffice-imp?rq=1",
|
||||
"config": [],
|
||||
"trajectory": "trajectories/",
|
||||
"related_apps": [
|
||||
""
|
||||
],
|
||||
"evaluator": "evaluation_dir"
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"id": "2cd43775-7085-45d8-89fa-9e35c0a915cf",
|
||||
"snapshot": "libreoffice_impress",
|
||||
"instruction": "Enable auto-save every 3min for me, so that I don't need to hit \"ctrl-s\" that much",
|
||||
"source": "https://www.libreofficehelp.com/enable-autosave-libreoffice/",
|
||||
"config": [
|
||||
{
|
||||
"type": "launch",
|
||||
"parameters": {
|
||||
"command": [
|
||||
"libreoffice",
|
||||
"--impress"
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"trajectory": "trajectories/",
|
||||
"related_apps": [
|
||||
"libreoffice_impress"
|
||||
],
|
||||
"evaluator": {
|
||||
"func": "check_auto_saving_time",
|
||||
"result": {
|
||||
"type": "vm_file",
|
||||
"path": "/home/user/.config/libreoffice/4/user/registrymodifications.xcu",
|
||||
"dest": "registrymodifications.xcu"
|
||||
},
|
||||
"expected": {
|
||||
"type": "rule",
|
||||
"rules": {
|
||||
"minutes": 3
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
{
|
||||
"id": "358aa0a7-6677-453f-ae35-e440f004c31e",
|
||||
"snapshot": "libreoffice_impress",
|
||||
"instruction": "Do you have any suggestions on how to modify the font for all text boxes in an Impress presentation? I want to standardize the font to 'Liberation Sans Narrow', but I don't want to manually select each individual text box.",
|
||||
"source": "https://superuser.com/questions/296101/change-all-text-fonts-in-libreoffice-impress-presentation",
|
||||
"config": [
|
||||
{
|
||||
"type": "download",
|
||||
"parameters": {
|
||||
"files": [
|
||||
{
|
||||
"url": "https://drive.usercontent.google.com/download?id=1ot4dssmIzd4_qkATrmwcmJAGVChg8b3M&export=download&authuser=0&confirm=t&uuid=442b7baf-95e0-4983-82e0-8b59f946e508&at=APZUnTUyzyB-2iFPUDdcT2ntpdCQ:1707296688907",
|
||||
"path": "/home/user/Desktop/note-taking-strategies.pptx"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "open",
|
||||
"parameters": {
|
||||
"path": "/home/user/Desktop/note-taking-strategies.pptx"
|
||||
}
|
||||
}
|
||||
],
|
||||
"trajectory": "trajectories/",
|
||||
"related_apps": [
|
||||
"libreoffice_impress"
|
||||
],
|
||||
"evaluator": {
|
||||
"postconfig": [
|
||||
{
|
||||
"type": "activate_window",
|
||||
"parameters": {
|
||||
"window_name": "note-taking-strategies.pptx - LibreOffice Impress",
|
||||
"strict": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "sleep",
|
||||
"parameters": {
|
||||
"seconds": 3
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "execute",
|
||||
"parameters": {
|
||||
"command": [
|
||||
"python",
|
||||
"-c",
|
||||
"import pyautogui; import time; pyautogui.hotkey('ctrl', 's'); time.sleep(0.5);"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "sleep",
|
||||
"parameters": {
|
||||
"seconds": 0.5
|
||||
}
|
||||
}
|
||||
],
|
||||
"func": "compare_pptx_files",
|
||||
"expected": {
|
||||
"type": "cloud_file",
|
||||
"path": "https://drive.usercontent.google.com/download?id=1bUCqqJhIuvWUkSxBjjo5O2ud2XN_kGsb&export=download&authuser=0&confirm=t&uuid=def54def-0383-4663-b3c4-2d740bc7904f&at=APZUnTWbv-n_VD2ArRkxCre9-5X1:1707298399387",
|
||||
"dest": "note-taking-strategies_Gold.pptx"
|
||||
},
|
||||
"result": {
|
||||
"type": "vm_file",
|
||||
"path": "/home/user/Desktop/note-taking-strategies.pptx",
|
||||
"dest": "note-taking-strategies.pptx"
|
||||
},
|
||||
"options": {
|
||||
"examine_shape": false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"id": "3cc4f35d-fa2e-4555-afb9-741b7c062a74",
|
||||
"snapshot": "libreoffice_impress",
|
||||
"instruction": "Could you help me create a master slide and rename it \"master\"?",
|
||||
"source": "https://documentation.libreoffice.org/assets/Uploads/Documentation/en/IG7.6/IG76-ImpressGuide.pdf",
|
||||
"config": [],
|
||||
"trajectory": "trajectories/",
|
||||
"related_apps": [
|
||||
""
|
||||
],
|
||||
"evaluator": "evaluation_dir"
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
{
|
||||
"id": "a669ef01-ded5-4099-9ea9-25e99b569840",
|
||||
"snapshot": "libreoffice_impress",
|
||||
"instruction": "I want to do something like the following on Page 3 of the current LibreOffice Impress file:\n\n- Main idea\n- Sub topics\n - first point of sub topics\n - second point of sub topics\n continuation of the sub topics\n\nthe \"continuation of the sub topics\" is indented the same as the first line of the second item, but it's essentially a second paragraph (I wouldn't mind a nested subitems mechanism, but LO Impress doesn't work that way) with an indentation.\n\nCould you help me with it?",
|
||||
"source": "https://superuser.com/questions/1628656/in-libreoffice-impress-how-can-i-have-a-bullet-indentation-no-bullet-item",
|
||||
"config": [
|
||||
{
|
||||
"type": "download",
|
||||
"parameters": {
|
||||
"files": [
|
||||
{
|
||||
"url": "https://drive.usercontent.google.com/download?id=1C0u-Qvvwa6UbJVTzzQHfdNIgp2i051xA&export=download&authuser=0&confirm=t&uuid=5551a43c-3ff7-424f-b82c-50a5c96b5809&at=APZUnTViShb8pJUviOkmVtn7Pums:1707299959829",
|
||||
"path": "/home/user/Desktop/Writing-Outlines.pptx"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "open",
|
||||
"parameters": {
|
||||
"path": "/home/user/Desktop/Writing-Outlines.pptx"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "execute",
|
||||
"parameters": {
|
||||
"command": [
|
||||
"python",
|
||||
"-c",
|
||||
"import pyautogui; import time; pyautogui.click(960, 540); time.sleep(0.5);"
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"trajectory": "trajectories/",
|
||||
"related_apps": [
|
||||
"libreoffice_impress"
|
||||
],
|
||||
"evaluator": {
|
||||
"postconfig": [
|
||||
{
|
||||
"type": "activate_window",
|
||||
"parameters": {
|
||||
"window_name": "Writing-Outlines.pptx - LibreOffice Impress",
|
||||
"strict": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "sleep",
|
||||
"parameters": {
|
||||
"seconds": 0.5
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "execute",
|
||||
"parameters": {
|
||||
"command": [
|
||||
"python",
|
||||
"-c",
|
||||
"import pyautogui; import time; pyautogui.hotkey('ctrl', 's'); time.sleep(0.5);"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "sleep",
|
||||
"parameters": {
|
||||
"seconds": 0.5
|
||||
}
|
||||
}
|
||||
],
|
||||
"func": "compare_pptx_files",
|
||||
"expected": {
|
||||
"type": "cloud_file",
|
||||
"path": "https://drive.usercontent.google.com/download?id=1d4WJwm7KDhDIOJ9r9vKhRTrt_bF3PSln&export=download&authuser=0&confirm=t&uuid=a8ec87de-96cf-49f0-98e4-faa1218354fe&at=APZUnTWiOoiHFjyM4jTunLP4t5wE:1707299961717",
|
||||
"dest": "Writing-Outlines_Gold.pptx"
|
||||
},
|
||||
"result": {
|
||||
"type": "vm_file",
|
||||
"path": "/home/user/Desktop/Writing-Outlines.pptx",
|
||||
"dest": "Writing-Outlines.pptx"
|
||||
},
|
||||
"options": {
|
||||
"examine_shape": false
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user