Last active
November 23, 2016 07:33
-
-
Save jengel3/9957bf125c41f8b7299d42f6dbb22310 to your computer and use it in GitHub Desktop.
Flex Output Parser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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