first commit
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Affiche les actions image photobooth-app en detail.
|
||||
Usage: echo JSON | python3 display_actions.py [--file backup.json]
|
||||
"""
|
||||
|
||||
import json, sys
|
||||
|
||||
def display_actions(actions):
|
||||
defaults_proc = {
|
||||
"remove_background": False,
|
||||
"fill_background_enable": False,
|
||||
"fill_background_color": "#ededed",
|
||||
"img_background_enable": False,
|
||||
"img_background_file": None,
|
||||
"image_filter": "original",
|
||||
"img_frame_enable": False,
|
||||
"img_frame_file": None,
|
||||
"texts_enable": False,
|
||||
}
|
||||
defaults_ui = {
|
||||
"show_button": False,
|
||||
"title": "",
|
||||
"icon": "photo_camera",
|
||||
"use_custom_color": False,
|
||||
"custom_color": "#196cb0",
|
||||
}
|
||||
|
||||
for i, a in enumerate(actions):
|
||||
name = a["name"]
|
||||
proc = a.get("processing", {})
|
||||
ui = a.get("trigger", {}).get("ui_trigger", {})
|
||||
|
||||
print(f" [{i}] {name}")
|
||||
|
||||
proc_diffs = []
|
||||
for key, default in defaults_proc.items():
|
||||
val = proc.get(key, default)
|
||||
if val != default and val is not None:
|
||||
if key.endswith("_file") and val:
|
||||
val = val.split("/")[-1]
|
||||
proc_diffs.append(f"{key}: {val}")
|
||||
|
||||
if proc_diffs:
|
||||
print(f" processing: {', '.join(proc_diffs)}")
|
||||
|
||||
show_button = ui.get("show_button", False)
|
||||
if show_button:
|
||||
ui_diffs = []
|
||||
for key, default in defaults_ui.items():
|
||||
val = ui.get(key, default)
|
||||
if val != default:
|
||||
ui_diffs.append(f"{key}: {val}")
|
||||
|
||||
if ui_diffs:
|
||||
print(f" ui_trigger: {', '.join(ui_diffs)}")
|
||||
|
||||
print()
|
||||
|
||||
print(f" Total: {len(actions)} action(s)")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if "--file" in sys.argv:
|
||||
filepath = sys.argv[sys.argv.index("--file") + 1]
|
||||
with open(filepath) as f:
|
||||
data = json.load(f)
|
||||
display_actions(data["image"])
|
||||
else:
|
||||
data = json.load(sys.stdin)
|
||||
if "actions" in data:
|
||||
display_actions(data["actions"]["image"])
|
||||
elif "image" in data:
|
||||
display_actions(data["image"])
|
||||
Reference in New Issue
Block a user