Skip to content

Instantly share code, notes, and snippets.

@ohmerhe
Created December 14, 2015 10:32
Show Gist options
  • Save ohmerhe/28f48ab316efdd14bdbe to your computer and use it in GitHub Desktop.
Save ohmerhe/28f48ab316efdd14bdbe to your computer and use it in GitHub Desktop.
解析AS的UnusedRes分析并删除对应图片资源
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