Skip to content

Instantly share code, notes, and snippets.

@timonus
Last active July 24, 2016 20:14
Show Gist options
  • Save timonus/2897644e7c772c1db106 to your computer and use it in GitHub Desktop.
Save timonus/2897644e7c772c1db106 to your computer and use it in GitHub Desktop.
.ipa Visualizer
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