script.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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_second(workspace_sdk_dir, extract_dir, channel_sdk_info, new_game_channel_info, game_info):
  10. logging.info('script_second: ' + str(channel_sdk_info))
  11. # 逆向渠道id
  12. public_xml = os.path.join(extract_dir, "res/values/public.xml")
  13. a_list = ["a", "b", "c", "d", "e", "f", "g", "h", "j", "k", "l", "m", "n", "p", "r", "s", "t", "y", "z"]
  14. for a in a_list:
  15. handle_public_xml(public_xml, "smssdk_country_group_" + a)
  16. return
  17. def handle_public_xml(public_xml_path, remove_node):
  18. if not os.path.exists(public_xml_path):
  19. logging.info('public_xml is null: ' + public_xml_path)
  20. return
  21. new_lines = []
  22. with open(public_xml_path, 'r+') as f:
  23. for line in f.readlines():
  24. # l = line.strip()
  25. if line.find(remove_node) > -1:
  26. continue
  27. new_lines.append(line)
  28. f.seek(0)
  29. f.truncate()
  30. f.writelines(new_lines)
  31. return
  32. if __name__ == '__main__':
  33. ""
  34. # script_last('', 'E:/script_test', {}, {}, {})