Created
December 14, 2015 10:32
-
-
Save ohmerhe/28f48ab316efdd14bdbe to your computer and use it in GitHub Desktop.
解析AS的UnusedRes分析并删除对应图片资源
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import os.path | |
import xml.etree.ElementTree as ET | |
tree = ET.parse('AndroidLintUnusedResources.xml') | |
root = tree.getroot() | |
def deleteFile(): | |
today = datetime.datetime.today() | |
return xmlrpclib.DateTime(today) | |
for problem in root.findall('problem'): | |
filepath = problem.find('file').text[7:] | |
line = problem.find('line').text | |
if int(line) != 0 and int(line) != 1 : | |
print "resource in strings.xml or colors.xml" | |
elif os.path.isfile(filepath) : | |
print "delete file : \n" + filepath | |
os.remove(filepath) | |
else : | |
print "Can not find file : \n" + filepath |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment