-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfig.py
More file actions
142 lines (113 loc) · 3.96 KB
/
Copy pathConfig.py
File metadata and controls
142 lines (113 loc) · 3.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/usr/bin/python
# coding=utf-8
import sys
import zipfile
import shutil
import os
import os.path
import time
import datetime
import json
# o_path = os.getcwd() # 返回当前工作目录
# sys.path.append(o_path) # 添加自己指定的搜索路径
# 当前工作目录 Common/PythonCreator/ProjectConfig/Script
sys.path.append('../../')
sys.path.append('./')
from Common import Source
from Project.Resource import mainResource
class Config():
jsonRoot:None
jsonPlat:None
jsonShare:None
jsonCommonRoot:None
#构造函数
def __init__(self):
dir = mainResource.GetRootUnityAssetsResource()+"/ConfigData/config"
# self.LoadCommonJson(dir)
def GetConfigCommonFile(self,dir):
filepath = dir + "/config_common.json"
return filepath
def GetConfigFile(self,osSrc, isHd):
dir = mainResource.GetConfigDir()
if isHd:
filepath = dir + "/config_" + osSrc + "_hd" + ".json"
else:
filepath = dir + "/config_" + osSrc + ".json"
return filepath
def LoadCommonJson(self,dir):
jsonfile = self.GetConfigCommonFile(dir)
with open(jsonfile) as json_file:
self.jsonCommonRoot = json.load(json_file)
def LoadJson(self,osSrc, isHd):
jsonfile = self.GetConfigFile(osSrc, isHd)
with open(jsonfile) as json_file:
self.jsonRoot = json.load(json_file)
self.jsonShare = self.jsonRoot["SHARE"]
self.jsonPlat = self.jsonShare["platform"]
def GetConfigAppType(self,dir):
self.LoadCommonJson(dir)
return self.jsonCommonRoot["APP_TYPE"]
def GetConfigAppName(self,dir):
self.LoadCommonJson(dir)
return self.jsonCommonRoot["APP_NAME_KEYWORD"]
def IsForKid(self):
dir = mainResource.GetRootUnityAssetsResource()+"/ConfigData/config"
self.LoadCommonJson(dir)
return self.jsonCommonRoot["APP_FOR_KIDS"]
def IsNoIDFASDK(self):
dir = mainResource.GetRootUnityAssetsResource()+"/ConfigData/config"
self.LoadCommonJson(dir)
if "NoIDFASDK" in self.jsonCommonRoot:
return self.jsonCommonRoot["NoIDFASDK"]
return False
def IsCloudRes(self):
dir = mainResource.GetRootUnityAssetsResource()+"/ConfigData/config"
self.LoadCommonJson(dir)
if "CloudRes" in self.jsonCommonRoot:
return True
return False
def GetShareAppId(self,src, osSrc, isHd):
self.LoadJson(osSrc, isHd)
appid = "0"
for jsontmp in self.jsonPlat:
if jsontmp["source"] == src:
appid = jsontmp["id"]
return appid
def GetShareAppKey(self,src, osSrc, isHd):
self.LoadJson(osSrc, isHd)
appkey = "0"
for jsontmp in self.jsonPlat:
if jsontmp["source"] == src:
appkey = jsontmp["key"]
return appkey
# qq: appID:100424468 1、tencent100424468
# 2、QQ05fc5b14 QQ05fc5b14为100424468转十六进制而来,因不足8位向前补0,然后加"QQ"前缀
def QQEncodeAppID(self,appid):
ret ="QQ"
str_hex = hex(int(appid))
len_hex = len(str_hex)
# 去除 0x 前缀
str_hex = str_hex[2:len_hex]
len_hex = len(str_hex)
if len_hex<8:
for i in range(0,8-len_hex):
ret+="0"
ret+=str_hex
return ret
# CFBundleURLSchemes
def XcodeUrlScheme(self,src, appid, idx):
ret = appid
if src == Source.WEIBO:
ret = "wb" + appid
if src == Source.WEIXIN or src == Source.WEIXINFRIEND:
ret = appid
if src == Source.QQ or src == Source.QQZONE:
if idx ==0:
ret = self.QQEncodeAppID(appid)
if idx ==1:
ret = "tencent"+appid
if ret=="0" or len(ret)==0:
# xcode UrlScheme 首字母不能为数字
ret = "wx0"
return ret
mainConfig = Config()