Browse Source

删除publc.xml字段

zqbo 5 years ago
parent
commit
7bfe9ca162
3 changed files with 61 additions and 2 deletions
  1. 14 1
      package_utils_record.py
  2. BIN
      sdk/float/libs/FloatSDK-1.0.11.jar
  3. 47 1
      xml_utils.py

+ 14 - 1
package_utils_record.py

@@ -281,6 +281,7 @@ def removeSameRes(game, sdk, subChannel, config):
         print('no same res found')
         return 0
 
+    removeList = []
     # 移除相同的资源
     decompliePath = file_utils.getDecompliePath(game, sdk, subChannel, config['cache'])
     resPath = os.path.join(decompliePath, 'res')
@@ -290,7 +291,19 @@ def removeSameRes(game, sdk, subChannel, config):
 
         absPath = os.path.join(resPath, path)
         for resFile in os.listdir(absPath):
-            xml_utils.removeSameRes(os.path.join(absPath, resFile), resList)
+            print('resFile ==> ' + os.path.join(absPath, resFile))
+            #xml_utils.removeSameRes(os.path.join(absPath, resFile), resList)
+            removeList = xml_utils.removeSameRes2(os.path.join(absPath, resFile), resList, removeList)
+
+    print('--------------')
+    print(removeList)
+    if len(removeList) == 0:
+        print('no same res remove')
+        return 0
+    publicResPath = os.path.join(decompliePath, 'res/values/public.xml')
+    print('publicResPath ---->' + publicResPath)
+    xml_utils.removeIdFromPublic(publicResPath,removeList)
+
 
     return 0
 

BIN
sdk/float/libs/FloatSDK-1.0.11.jar


+ 47 - 1
xml_utils.py

@@ -428,6 +428,41 @@ def readAllRes(resFile, resList):
     resList += root.getchildren()
     return resList
 
+def removeIdFromPublic(pubFile, removeList):
+    '''
+    删除重复的资源
+    '''
+    tree = ET.parse(pubFile)
+    root = tree.getroot()
+
+    same = False
+    for node in root.getchildren():
+        if containPublic(node, removeList):
+            print('delete public node : type is %s, name is %s' % (node.attrib['type'], node.attrib['name']))
+            root.remove(node)
+            same = True
+    if same:
+        tree.write(pubFile, encoding)
+
+def removeSameRes2(resFile, resList, removeList):
+    '''
+    删除重复的资源
+    '''
+    tree = ET.parse(resFile)
+    root = tree.getroot()
+
+    same = False
+    for node in root.getchildren():
+        if containRes(node, resList):
+            print('delete node : tag is %s, name is %s' % (node.tag, node.attrib['name']))
+            root.remove(node)
+            removeList.append(node)
+            same = True
+
+    if same:
+        tree.write(resFile, encoding)
+    return removeList
+
 def removeSameRes(resFile, resList):
     '''
     删除重复的资源
@@ -450,11 +485,22 @@ def containRes(node, resList):
     是否重复
     '''
     for item in resList:
-        if item.tag == node.tag and item.attrib['name'] == node.attrib['name']:
+         if item.tag == node.tag and item.attrib['name'] == node.attrib['name']:
             return True
 
     return False
 
+def containPublic(node, removeList):
+    '''
+    是否重复
+    '''
+    for item in removeList:
+         if item.tag == node.attrib['type'] and item.attrib['name'] == node.attrib['name']:
+            return True
+
+    return False
+
+
 def removeRootAttr(manifest, attrType):
     for key in namespaces:
         ET.register_namespace(key, namespaces[key])