Dictionary instead of list?

This commit is contained in:
Benson Chu 2025-08-23 10:13:49 -05:00
parent 5797c991a0
commit ae7e236072

View file

@ -14,16 +14,20 @@ def do_modify_labels(lib, objs, label, action):
changed = []
for obj in objs:
labels = []
labels = {}
if action != 2:
if "mylabels" in obj:
labels = json.loads(obj["mylabels"])
split = label.split(":")
if action == 0:
labels.append(label)
labels = sorted(set(labels))
if len(split) == 1:
labels[label] = 0
else:
labels[split[0]] = int(split[1])
elif label in labels:
labels.remove(label)
del labels[label]
obj_mods = {
"mylabels": json.dumps(labels)