Skip to content

Instantly share code, notes, and snippets.

@jengel3
Last active November 23, 2016 07:33
Show Gist options
  • Save jengel3/9957bf125c41f8b7299d42f6dbb22310 to your computer and use it in GitHub Desktop.
Save jengel3/9957bf125c41f8b7299d42f6dbb22310 to your computer and use it in GitHub Desktop.
Flex Output Parser
import xml.etree.ElementTree as et
import xml.etree.cElementTree as et
import lxml.etree as et
import os as os
e = et.parse('com.burbn.instagram.dat').getroot()
items = list(e[0])[1]
descriptors = {}
for child in items:
clazz_name = None
super_clazz = None
clazz_methods = []
for i, clazz in enumerate(child):
if clazz.tag == 'key':
if clazz.text == 'name':
clazz_name = child[i+1].text
# print clazz_name
elif clazz.text == 'methods':
dicts = child[i+1]
for dic in dicts:
for idx, item in enumerate(dic):
if item.tag == 'key':
if item.text == 'displayName':
# print(item.text)
display = dic[idx+1].text
clazz_methods.append(display)
# print(clazz_name)
# print(clazz_methods)
descriptors[clazz_name] = clazz_methods
os.mkdir("output")
for k, v in descriptors.iteritems():
outputstr = ""
f = open('output/' + k + '.h', 'w')
outputstr += "@interface " + k + "\n"
for item in v:
outputstr += item + "\n"
outputstr += "@end"
f.write(outputstr)
f.close()
print(outputstr)
import xml.etree.ElementTree as et
import xml.etree.cElementTree as et
import lxml.etree as et
e = et.parse('com.burbn.instagram.dat').getroot()
items = list(e[0])[1]
descriptors = {}
for child in items:
clazz_name = None
super_clazz = None
clazz_methods = []
for i, clazz in enumerate(child):
if clazz.tag == 'key':
if clazz.text == 'name':
clazz_name = child[i+1].text
# print clazz_name
elif clazz.text == 'methods':
dicts = child[i+1]
for dic in dicts:
for idx, item in enumerate(dic):
if item.tag == 'key':
if item.text == 'displayName':
# print(item.text)
display = dic[idx+1].text
clazz_methods.append(display)
# print(clazz_name)
# print(clazz_methods)
descriptors[clazz_name] = clazz_methods
outputstr = ""
for k, v in descriptors.iteritems():
outputstr += "@interface " + k + "\n"
for item in v:
outputstr += item + "\n"
outputstr += "@end\n\n"
print(outputstr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment