Skip to content

Commit

Permalink
draft init
Browse files Browse the repository at this point in the history
  • Loading branch information
metasmile committed Sep 22, 2018
1 parent f5d9aaf commit 7eb3052
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions strsync/strintentdefinition_draft.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 7eb3052

Please sign in to comment.