From 7eb3052e3b02011b0cf7fff8e3b30cfeb1a65261 Mon Sep 17 00:00:00 2001 From: metasmile Date: Sat, 22 Sep 2018 20:38:43 +0200 Subject: [PATCH] draft init --- strsync/strintentdefinition_draft.py | 37 ++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 strsync/strintentdefinition_draft.py diff --git a/strsync/strintentdefinition_draft.py b/strsync/strintentdefinition_draft.py new file mode 100644 index 0000000..198cb55 --- /dev/null +++ b/strsync/strintentdefinition_draft.py @@ -0,0 +1,37 @@ + # -*- coding: utf-8 -*- + +import plistlib + +def rget(dictionary, key, idKey): + items = [] + for k in dictionary: + if k == key: + items.append({"label": str(dictionary[k]), "id":str(dictionary[idKey])}) + else: + if isinstance(dictionary[k], list): + for item in dictionary[k]: + items += rget(item, key, idKey) + elif isinstance(dictionary[k], dict): + items += rget(dictionary[k], key, idKey) + return items + +l = plistlib.readPlist('/Users/blackgene/Documents/pap/pap/Resources/Intents/Base.lproj/Intents.intentdefinition') + +keys = [ + 'INIntentTitle', + 'INIntentDescription', + 'INEnumValueDisplayName', + 'INIntentParameterCombinationTitle', + 'INIntentResponseCodeFormatString', + 'INIntentParameterCombinationSubtitle' +] + +results = '' +for k in keys: + a = rget(l, k, k+"ID") + for kObj in a: + id, label = kObj['id'], kObj['label'] + if len(label): + results += '"{}" = "{}";\n'.format(id, label) + +print(results)