簡單寫了一個python腳本記錄一下Mainfest中Activity的相關資訊,代碼如下:
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import xml.etree.ElementTree as ET
import pandas as pd
preix="{http://schemas.android.com/apk/res/android}"
def parseXml(filePath):
tree=ET.parse(filePath)
# print(tree.getroot().attrib)
root=tree.getroot()
activitylist=[]
noScreenRotateList=[]
for application in root:
if(application.tag == "application"):
for element in application.findall("activity"):
name= element.get(preix+'name')
configChange=element.get(preix+"configChanges")
if(configChange == None):
noScreenRotateList.append({name:configChange})
else:
activitylist.append({name:configChange})
activitylist=activitylist+noScreenRotateList
buildTable(activitylist)
def buildTable(list):
a = []
b = []
for item in list:
for key in item:
a.append(key)
b.append(item[key])
dit = {'Activity':a, 'ConfigChangeOptions':b}
file_path = r'output.xlsx'
writer = pd.ExcelWriter(file_path)
df = pd.DataFrame(dit)
#columns參數用于指定生成的excel中列的順序
df.to_excel(writer, columns=['Activity','ConfigChangeOptions'], index=False,encoding='utf-8',sheet_name='Sheet')
writer.save()
parseXml("AndroidManifest.xml")
最終輸出結果為一個excel表格檔案,裡面記錄了Activity的個數以及對象ConfigChanges參數的值
版權聲明:本文為CSDN部落客「weixin_34372728」的原創文章,遵循CC 4.0 BY-SA版權協定,轉載請附上原文出處連結及本聲明。
原文連結:https://blog.csdn.net/weixin_34372728/article/details/92416939