script.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # coding:utf8
  2. import os
  3. import xml.etree.ElementTree as ET
  4. import logging
  5. import re
  6. import codecs
  7. ANDROID_NAMESPACE = 'http://schemas.android.com/apk/res/android'
  8. logger = logging.getLogger('script.py')
  9. def script_pre(workspace_sdk_dir, extract_dir, channel_sdk_info, new_game_channel_info, game_info):
  10. logging.info('script_pre: ' + str(channel_sdk_info))
  11. # 逆向渠道id
  12. public_xml = os.path.join(extract_dir, "res/values/public.xml")
  13. handle_public_xml(public_xml, "holo_light")
  14. handle_public_xml(public_xml, "holo_dark")
  15. return
  16. def handle_public_xml(public_xml_path, remove_node):
  17. if not os.path.exists(public_xml_path):
  18. logging.info('public_xml is null: ' + public_xml_path)
  19. return
  20. new_lines = []
  21. with open(public_xml_path, 'r+') as f:
  22. for line in f.readlines():
  23. # l = line.strip()
  24. if line.find(remove_node) > -1:
  25. continue
  26. new_lines.append(line)
  27. f.seek(0)
  28. f.truncate()
  29. f.writelines(new_lines)
  30. return
  31. if __name__ == '__main__':
  32. script_last('', 'E:/script_test', {}, {}, {})