Replace_GameRes_Utils.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536
  1. # -*- coding:utf-8 -*-
  2. from V1 import Json_Util
  3. import os
  4. import shutil
  5. from V1.PrintLog import printlog
  6. def ReplaceGameResource(apk_decompile_tmp_dir,resourcepaths):
  7. for resourcepath in resourcepaths:
  8. # PrintLog("resourcepaths:%s"%resourcepaths)
  9. resource = resourcepath[0]
  10. path = resourcepath[1]
  11. if resource != None and resource != "" and path != None and path != "":
  12. # PrintLog("game resource: %s"%resource)
  13. if not os.path.exists(path):
  14. printlog("game resource is not exists in:%s" % path)
  15. return False, "game resource is not exists in:%s"%resource
  16. apkrespath = "%s/%s"%(apk_decompile_tmp_dir, resource)
  17. # PrintLog("game apkrespath: %s"%apkrespath)
  18. # dislogopath = "%s/assets/shansu/%s"%(decompilepath, QuickPackContants.getQuickPackLogoName())
  19. if not os.path.exists(os.path.dirname(apkrespath)):
  20. os.makedirs(os.path.dirname(apkrespath))
  21. shutil.copy(path, apkrespath)
  22. pass
  23. def replaceAdGameResource(apk_decompile_tmp_dir,resourcepaths,resourceconfigs):
  24. pathkeys = Json_Util.getJsonKeys(resourcepaths)
  25. for key in pathkeys:
  26. path = resourcepaths[key]
  27. printlog("GameResourcePath:%s" % path)
  28. if path != None and path != "":
  29. print(resourceconfigs[key]["default"])
  30. apkrespath = "%s/%s"%(apk_decompile_tmp_dir,resourceconfigs[key]["default"])
  31. if not os.path.exists(os.path.dirname(apkrespath)):
  32. os.makedirs(os.path.dirname(apkrespath))
  33. shutil.copy(path, apkrespath)
  34. pass