码迷,mamicode.com
首页 > 移动开发 > 详细

检测app使用了多少个xib和js的脚本(python)

时间:2015-07-07 14:50:27      阅读:157      评论:0      收藏:0      [点我收藏+]

标签:脚本   ios   js   xib   

检测app使用了多少个xib和js的脚本(python)

by 伍雪颖

#!/usr/bin/env python
# coding=utf-8
import os, sys

def countTargetFile(targetDir):
    resultStr =
‘‘
    targetTypes = [
‘.nib‘, ‘.m‘, ‘.js‘]
   
for targetType in targetTypes:
        targetCount =
0
       
for root, dirs, files in 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

def deal(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()

def process():
    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‘

版权声明:本文为博主原创文章,未经博主允许不得转载。

检测app使用了多少个xib和js的脚本(python)

标签:脚本   ios   js   xib   

原文地址:http://blog.csdn.net/rainlesvio/article/details/46788107

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!