Last active
July 24, 2016 20:14
-
-
Save timonus/2897644e7c772c1db106 to your computer and use it in GitHub Desktop.
.ipa Visualizer
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 sys | |
import subprocess | |
import re | |
import os | |
import shutil | |
if len(sys.argv) < 2: | |
print "No path specified" | |
sys.exit() | |
path = sys.argv[1] | |
rootCopyPath = "visualize-ipa-output" | |
if os.path.exists(rootCopyPath): | |
print "Removing old copy" | |
shutil.rmtree(rootCopyPath) | |
# Captures the compressed size of the file and the path to it | |
sizeRegex = re.compile("\s*\d+\s+[A-Za-z:]+\s+(\d+)\s+-?\d+%\s+\d+-\d+-\d+\s+[0-9:]+\s+[0-9a-f]+\s+(.+)") | |
proc = subprocess.Popen(["unzip", "-vl", path], stdout=subprocess.PIPE) | |
while True: | |
line = proc.stdout.readline() | |
if line != "": | |
matches = sizeRegex.match(line) | |
if matches != None: | |
size = matches.group(1) | |
path = matches.group(2) | |
# print matches.group(1) + " " + matches.group(2) | |
copyPath = os.path.join(rootCopyPath, path) | |
copyPath = copyPath.replace(".app", "") | |
if copyPath.endswith("/"): | |
# create dir | |
if not os.path.exists(copyPath): | |
os.makedirs(copyPath) | |
else: | |
# print copyPath | |
file = open(copyPath, "w") | |
for i in range(0, int(size)): | |
file.write(str(i % 10)) | |
file.close() | |
if not os.path.exists(copyPath): | |
print "ERROR" | |
else: | |
print "Unable to parse: " + line.replace("\n", "") | |
else: | |
print "Done!" | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment