"""解析XML文件"""
curlist=listdir(trash)
folderlist = []
xmllist=[]
dict2,dict4= {},{}
for filename in curlist:
if filename.endswith('.apk'):
folderlist.append(filename.rstrip('.apk'))
for i in folderlist:
j = trash + "\\"+ i+"\AndroidManifest.xml"
xmllist.append(j)
"""取出CHANNEL字符"""
for xmls in xmllist:
file = open(xmls)
matchline = ''' <meta-data android:name="CHANNEL'''
for line in file.readlines():
if line.startswith(matchline):
line = re.sub(r' <meta-data android:name="CHANNEL" android:value="','',line)
line = line.replace(r'"/>','').rstrip('\n')
xmls= xmls.replace(local_path,"").rstrip('AndroidManifest.xml').replace("\\","")
dict1 = {xmls:line}
dict2.update(dict1)
file.close()
for xmls1 in xmllist:
file1 = open(xmls1)
matchline1 = ''' <meta-data android:name="tinker_version" android:value="'''
for line1 in file1.readlines():
if line1.startswith(matchline1):
line1 = re.sub(r' <meta-data android:name="tinker_version" android:value="','',line1)
line1 = line1.replace(r'"/>','').rstrip('\n')
xmls1= xmls1.replace(local_path,"").rstrip('AndroidManifest.xml').replace("\\","")
dict3 = {xmls1:line1}
dict4.update(dict3)
file1.close()