檢測app使用了多少個xib和js的指令碼(python),xibpython
檢測app使用了多少個xib和js的指令碼(python)by 伍雪穎
#!/usr/bin/env python
# coding=utf-8
importos, sys
defcountTargetFile(targetDir):
resultStr = ''
targetTypes = ['.nib','.m','.js']
for targetType in targetTypes:
targetCount = 0
for root, dirs, filesin os.walk(targetDir):
for file in files:
if file.endswith(targetType):
print os.path.join(root, file)
targetCount += 1
oneResult = 'type = ' + targetType +', target count = '+ str(targetCount)
print oneResult
resultStr += oneResult + '\n'
return resultStr
defdeal(baseDir, filename):
print 'process file:' + baseDir + filename
tmpDir = os.getcwd() + '/unzip_folders/' + filename.replace(' ','_')
print tmpDir
try:
os.mkdir(tmpDir)
zipFile = tmpDir + '/' + 'tmp.zip'
command = 'cp ' + baseDir + filename.replace(' ','\ ') +' ' + zipFile
os.system(command)
command = 'unzip ' + zipFile +' -d '+ tmpDir
print command
os.system(command)
except OSError:
print 'file exist, ignore'
resultStr = countTargetFile(tmpDir + '/Payload')
file = open(tmpDir.replace('.ipa','') + '_result.txt', 'w')
file.write(filename + ':\n')
file.write(resultStr)
file.write('\n')
file.close()
defprocess():
baseDir = os.getcwd()
targetFiles = os.listdir('./ipa_folders')
print targetFiles
for oneFile in targetFiles:
if oneFile.endswith('.ipa'):
deal(baseDir + '/ipa_folders/', oneFile)
if__name__ == '__main__':
process() print 'over'
著作權聲明:本文為博主原創文章,未經博主允許不得轉載。