How many xib and js scripts (python) and xibpython are used in the app?
Checks how many xib and js scripts are used by the app (python) by Wu xueying
#! /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)
Failed t 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'
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.