re-common 2.0.0__py3-none-any.whl → 2.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (200) hide show
  1. re_common/v2/baselibrary/tools/search_hash_tools.py +33 -0
  2. re_common/v2/baselibrary/tools/text_matcher.py +223 -0
  3. re_common/v2/baselibrary/utils/BusinessStringUtil.py +2 -2
  4. re_common/v2/baselibrary/utils/author_smi.py +308 -0
  5. re_common/v2/baselibrary/utils/string_clear.py +15 -1
  6. re_common/v2/baselibrary/utils/stringutils.py +36 -1
  7. {re_common-2.0.0.dist-info → re_common-2.0.1.dist-info}/METADATA +1 -1
  8. re_common-2.0.1.dist-info/RECORD +25 -0
  9. re_common/baselibrary/__init__.py +0 -4
  10. re_common/baselibrary/baseabs/__init__.py +0 -7
  11. re_common/baselibrary/baseabs/baseabs.py +0 -26
  12. re_common/baselibrary/database/mbuilder.py +0 -132
  13. re_common/baselibrary/database/moudle.py +0 -93
  14. re_common/baselibrary/database/msqlite3.py +0 -194
  15. re_common/baselibrary/database/mysql.py +0 -169
  16. re_common/baselibrary/database/sql_factory.py +0 -26
  17. re_common/baselibrary/mthread/MThreadingRun.py +0 -486
  18. re_common/baselibrary/mthread/MThreadingRunEvent.py +0 -349
  19. re_common/baselibrary/mthread/__init__.py +0 -3
  20. re_common/baselibrary/mthread/mythreading.py +0 -695
  21. re_common/baselibrary/pakge_other/__init__.py +0 -0
  22. re_common/baselibrary/pakge_other/socks.py +0 -404
  23. re_common/baselibrary/readconfig/__init__.py +0 -0
  24. re_common/baselibrary/readconfig/config_factory.py +0 -18
  25. re_common/baselibrary/readconfig/ini_config.py +0 -317
  26. re_common/baselibrary/readconfig/toml_config.py +0 -49
  27. re_common/baselibrary/temporary/__init__.py +0 -0
  28. re_common/baselibrary/temporary/envdata.py +0 -36
  29. re_common/baselibrary/tools/__init__.py +0 -0
  30. re_common/baselibrary/tools/all_requests/__init__.py +0 -0
  31. re_common/baselibrary/tools/all_requests/aiohttp_request.py +0 -118
  32. re_common/baselibrary/tools/all_requests/httpx_requet.py +0 -102
  33. re_common/baselibrary/tools/all_requests/mrequest.py +0 -412
  34. re_common/baselibrary/tools/all_requests/requests_request.py +0 -81
  35. re_common/baselibrary/tools/batch_compre/__init__.py +0 -0
  36. re_common/baselibrary/tools/batch_compre/bijiao_batch.py +0 -31
  37. re_common/baselibrary/tools/contrast_db3.py +0 -123
  38. re_common/baselibrary/tools/copy_file.py +0 -39
  39. re_common/baselibrary/tools/db3_2_sizedb3.py +0 -102
  40. re_common/baselibrary/tools/foreachgz.py +0 -40
  41. re_common/baselibrary/tools/get_attr.py +0 -11
  42. re_common/baselibrary/tools/image_to_pdf.py +0 -62
  43. re_common/baselibrary/tools/java_code_deal.py +0 -139
  44. re_common/baselibrary/tools/javacode.py +0 -79
  45. re_common/baselibrary/tools/mdb_db3.py +0 -48
  46. re_common/baselibrary/tools/merge_file.py +0 -171
  47. re_common/baselibrary/tools/merge_gz_file.py +0 -165
  48. re_common/baselibrary/tools/mhdfstools/__init__.py +0 -0
  49. re_common/baselibrary/tools/mhdfstools/down_hdfs_files.py +0 -42
  50. re_common/baselibrary/tools/mhdfstools/hdfst.py +0 -42
  51. re_common/baselibrary/tools/mhdfstools/up_hdfs_files.py +0 -38
  52. re_common/baselibrary/tools/mongo_tools.py +0 -50
  53. re_common/baselibrary/tools/move_file.py +0 -170
  54. re_common/baselibrary/tools/move_mongo/__init__.py +0 -0
  55. re_common/baselibrary/tools/move_mongo/mongo_table_to_file.py +0 -63
  56. re_common/baselibrary/tools/move_mongo/move_mongo_table.py +0 -354
  57. re_common/baselibrary/tools/move_mongo/use_mttf.py +0 -18
  58. re_common/baselibrary/tools/move_mongo/use_mv.py +0 -93
  59. re_common/baselibrary/tools/mpandas/__init__.py +0 -0
  60. re_common/baselibrary/tools/mpandas/mpandasreadexcel.py +0 -125
  61. re_common/baselibrary/tools/mpandas/pandas_visualization.py +0 -8
  62. re_common/baselibrary/tools/myparsel.py +0 -104
  63. re_common/baselibrary/tools/rename_dir_file.py +0 -37
  64. re_common/baselibrary/tools/sequoiadb_utils.py +0 -398
  65. re_common/baselibrary/tools/split_line_to_many.py +0 -25
  66. re_common/baselibrary/tools/stringtodicts.py +0 -33
  67. re_common/baselibrary/tools/workwechant_bot.py +0 -84
  68. re_common/baselibrary/utils/__init__.py +0 -0
  69. re_common/baselibrary/utils/baseaiohttp.py +0 -296
  70. re_common/baselibrary/utils/baseaiomysql.py +0 -87
  71. re_common/baselibrary/utils/baseallstep.py +0 -191
  72. re_common/baselibrary/utils/baseavro.py +0 -19
  73. re_common/baselibrary/utils/baseboto3.py +0 -291
  74. re_common/baselibrary/utils/basecsv.py +0 -32
  75. re_common/baselibrary/utils/basedict.py +0 -133
  76. re_common/baselibrary/utils/basedir.py +0 -241
  77. re_common/baselibrary/utils/baseencode.py +0 -351
  78. re_common/baselibrary/utils/baseencoding.py +0 -29
  79. re_common/baselibrary/utils/baseesdsl.py +0 -86
  80. re_common/baselibrary/utils/baseexcel.py +0 -264
  81. re_common/baselibrary/utils/baseexcept.py +0 -109
  82. re_common/baselibrary/utils/basefile.py +0 -654
  83. re_common/baselibrary/utils/baseftp.py +0 -214
  84. re_common/baselibrary/utils/basegzip.py +0 -60
  85. re_common/baselibrary/utils/basehdfs.py +0 -135
  86. re_common/baselibrary/utils/basehttpx.py +0 -268
  87. re_common/baselibrary/utils/baseip.py +0 -87
  88. re_common/baselibrary/utils/basejson.py +0 -2
  89. re_common/baselibrary/utils/baselist.py +0 -32
  90. re_common/baselibrary/utils/basemotor.py +0 -190
  91. re_common/baselibrary/utils/basemssql.py +0 -98
  92. re_common/baselibrary/utils/baseodbc.py +0 -113
  93. re_common/baselibrary/utils/basepandas.py +0 -302
  94. re_common/baselibrary/utils/basepeewee.py +0 -11
  95. re_common/baselibrary/utils/basepika.py +0 -180
  96. re_common/baselibrary/utils/basepydash.py +0 -143
  97. re_common/baselibrary/utils/basepymongo.py +0 -230
  98. re_common/baselibrary/utils/basequeue.py +0 -22
  99. re_common/baselibrary/utils/baserar.py +0 -57
  100. re_common/baselibrary/utils/baserequest.py +0 -279
  101. re_common/baselibrary/utils/baseset.py +0 -8
  102. re_common/baselibrary/utils/basesmb.py +0 -403
  103. re_common/baselibrary/utils/basestring.py +0 -382
  104. re_common/baselibrary/utils/basetime.py +0 -320
  105. re_common/baselibrary/utils/basetuple.py +0 -0
  106. re_common/baselibrary/utils/baseurl.py +0 -121
  107. re_common/baselibrary/utils/basezip.py +0 -57
  108. re_common/baselibrary/utils/core/__init__.py +0 -8
  109. re_common/baselibrary/utils/core/bottomutils.py +0 -18
  110. re_common/baselibrary/utils/core/mdeprecated.py +0 -327
  111. re_common/baselibrary/utils/core/mlamada.py +0 -16
  112. re_common/baselibrary/utils/core/msginfo.py +0 -25
  113. re_common/baselibrary/utils/core/requests_core.py +0 -103
  114. re_common/baselibrary/utils/fateadm.py +0 -429
  115. re_common/baselibrary/utils/importfun.py +0 -123
  116. re_common/baselibrary/utils/mfaker.py +0 -57
  117. re_common/baselibrary/utils/my_abc/__init__.py +0 -3
  118. re_common/baselibrary/utils/my_abc/better_abc.py +0 -32
  119. re_common/baselibrary/utils/mylogger.py +0 -414
  120. re_common/baselibrary/utils/myredisclient.py +0 -861
  121. re_common/baselibrary/utils/pipupgrade.py +0 -21
  122. re_common/baselibrary/utils/ringlist.py +0 -85
  123. re_common/baselibrary/utils/version_compare.py +0 -36
  124. re_common/baselibrary/utils/ydmhttp.py +0 -126
  125. re_common/facade/__init__.py +0 -1
  126. re_common/facade/lazy_import.py +0 -11
  127. re_common/facade/loggerfacade.py +0 -25
  128. re_common/facade/mysqlfacade.py +0 -467
  129. re_common/facade/now.py +0 -31
  130. re_common/facade/sqlite3facade.py +0 -257
  131. re_common/facade/use/__init__.py +0 -0
  132. re_common/facade/use/mq_use_facade.py +0 -83
  133. re_common/facade/use/proxy_use_facade.py +0 -20
  134. re_common/libtest/__init__.py +0 -0
  135. re_common/libtest/base_dict_test.py +0 -19
  136. re_common/libtest/baseavro_test.py +0 -13
  137. re_common/libtest/basefile_test.py +0 -14
  138. re_common/libtest/basemssql_test.py +0 -77
  139. re_common/libtest/baseodbc_test.py +0 -8
  140. re_common/libtest/basepandas_test.py +0 -38
  141. re_common/libtest/get_attr_test/__init__.py +0 -0
  142. re_common/libtest/get_attr_test/get_attr_test_settings.py +0 -14
  143. re_common/libtest/get_attr_test/settings.py +0 -55
  144. re_common/libtest/idencode_test.py +0 -54
  145. re_common/libtest/iniconfig_test.py +0 -35
  146. re_common/libtest/ip_test.py +0 -35
  147. re_common/libtest/merge_file_test.py +0 -20
  148. re_common/libtest/mfaker_test.py +0 -9
  149. re_common/libtest/mm3_test.py +0 -32
  150. re_common/libtest/mylogger_test.py +0 -89
  151. re_common/libtest/myparsel_test.py +0 -28
  152. re_common/libtest/mysql_test.py +0 -151
  153. re_common/libtest/pymongo_test.py +0 -21
  154. re_common/libtest/split_test.py +0 -12
  155. re_common/libtest/sqlite3_merge_test.py +0 -6
  156. re_common/libtest/sqlite3_test.py +0 -34
  157. re_common/libtest/tomlconfig_test.py +0 -30
  158. re_common/libtest/use_tools_test/__init__.py +0 -3
  159. re_common/libtest/user/__init__.py +0 -5
  160. re_common/studio/__init__.py +0 -5
  161. re_common/studio/assignment_expressions.py +0 -37
  162. re_common/studio/mydash/__init__.py +0 -0
  163. re_common/studio/mydash/test1.py +0 -19
  164. re_common/studio/pydashstudio/__init__.py +0 -0
  165. re_common/studio/pydashstudio/first.py +0 -9
  166. re_common/studio/streamlitstudio/__init__.py +0 -0
  167. re_common/studio/streamlitstudio/first_app.py +0 -66
  168. re_common/studio/streamlitstudio/uber_pickups.py +0 -24
  169. re_common/studio/test.py +0 -19
  170. re_common/vip/__init__.py +0 -0
  171. re_common/vip/base_step_process.py +0 -11
  172. re_common/vip/baseencodeid.py +0 -91
  173. re_common/vip/changetaskname.py +0 -28
  174. re_common/vip/core_var.py +0 -24
  175. re_common/vip/mmh3Hash.py +0 -90
  176. re_common/vip/proxy/__init__.py +0 -0
  177. re_common/vip/proxy/allproxys.py +0 -127
  178. re_common/vip/proxy/allproxys_thread.py +0 -159
  179. re_common/vip/proxy/cnki_proxy.py +0 -153
  180. re_common/vip/proxy/kuaidaili.py +0 -87
  181. re_common/vip/proxy/proxy_all.py +0 -113
  182. re_common/vip/proxy/update_kuaidaili_0.py +0 -42
  183. re_common/vip/proxy/wanfang_proxy.py +0 -152
  184. re_common/vip/proxy/wp_proxy_all.py +0 -182
  185. re_common/vip/read_rawid_to_txt.py +0 -92
  186. re_common/vip/title/__init__.py +0 -5
  187. re_common/vip/title/transform/TransformBookTitleToZt.py +0 -125
  188. re_common/vip/title/transform/TransformConferenceTitleToZt.py +0 -139
  189. re_common/vip/title/transform/TransformCstadTitleToZt.py +0 -196
  190. re_common/vip/title/transform/TransformJournalTitleToZt.py +0 -203
  191. re_common/vip/title/transform/TransformPatentTitleToZt.py +0 -132
  192. re_common/vip/title/transform/TransformRegulationTitleToZt.py +0 -114
  193. re_common/vip/title/transform/TransformStandardTitleToZt.py +0 -135
  194. re_common/vip/title/transform/TransformThesisTitleToZt.py +0 -135
  195. re_common/vip/title/transform/__init__.py +0 -11
  196. re_common-2.0.0.dist-info/RECORD +0 -209
  197. /re_common/{baselibrary/database/__init__.py → v2/baselibrary/tools/list_tools.py} +0 -0
  198. {re_common-2.0.0.dist-info → re_common-2.0.1.dist-info}/LICENSE +0 -0
  199. {re_common-2.0.0.dist-info → re_common-2.0.1.dist-info}/WHEEL +0 -0
  200. {re_common-2.0.0.dist-info → re_common-2.0.1.dist-info}/top_level.txt +0 -0
@@ -1,429 +0,0 @@
1
- # coding=utf-8
2
- import hashlib
3
- import json
4
- import time
5
-
6
- import requests
7
-
8
- FATEA_PRED_URL = "http://pred.fateadm.com"
9
-
10
-
11
- def LOG(log):
12
- # 不需要测试时,注释掉日志就可以了
13
- print(log)
14
- log = None
15
-
16
-
17
- class TmpObj():
18
- def __init__(self):
19
- self.value = None
20
-
21
-
22
- class Rsp():
23
- def __init__(self):
24
- self.ret_code = -1
25
- self.cust_val = 0.0
26
- self.err_msg = "succ"
27
- self.pred_rsp = TmpObj()
28
-
29
- def ParseJsonRsp(self, rsp_data):
30
- if rsp_data is None:
31
- self.err_msg = "http request failed, get rsp Nil data"
32
- return
33
- jrsp = json.loads(rsp_data)
34
- self.ret_code = int(jrsp["RetCode"])
35
- self.err_msg = jrsp["ErrMsg"]
36
- self.request_id = jrsp["RequestId"]
37
- if self.ret_code == 0:
38
- rslt_data = jrsp["RspData"]
39
- if rslt_data is not None and rslt_data != "":
40
- jrsp_ext = json.loads(rslt_data)
41
- if "cust_val" in jrsp_ext:
42
- data = jrsp_ext["cust_val"]
43
- self.cust_val = float(data)
44
- if "result" in jrsp_ext:
45
- data = jrsp_ext["result"]
46
- self.pred_rsp.value = data
47
-
48
-
49
- def CalcSign(pd_id, passwd, timestamp):
50
- md5 = hashlib.md5()
51
- md5.update((timestamp + passwd).encode())
52
- csign = md5.hexdigest()
53
-
54
- md5 = hashlib.md5()
55
- md5.update((pd_id + timestamp + csign).encode())
56
- csign = md5.hexdigest()
57
- return csign
58
-
59
-
60
- def CalcCardSign(cardid, cardkey, timestamp, passwd):
61
- md5 = hashlib.md5()
62
- md5.update(passwd + timestamp + cardid + cardkey)
63
- return md5.hexdigest()
64
-
65
-
66
- def HttpRequest(url, body_data, img_data=""):
67
- rsp = Rsp()
68
- post_data = body_data
69
- files = {
70
- 'img_data': ('img_data', img_data)
71
- }
72
- header = {
73
- 'User-Agent': 'Mozilla/5.0',
74
- }
75
- rsp_data = requests.post(url, post_data, files=files, headers=header)
76
- rsp.ParseJsonRsp(rsp_data.text)
77
- return rsp
78
-
79
-
80
- class FateadmApi():
81
- # API接口调用类
82
- # 参数(appID,appKey,pdID,pdKey)
83
- def __init__(self, app_id, app_key, pd_id, pd_key):
84
- self.app_id = app_id
85
- if app_id is None:
86
- self.app_id = ""
87
- self.app_key = app_key
88
- self.pd_id = pd_id
89
- self.pd_key = pd_key
90
- self.host = FATEA_PRED_URL
91
-
92
- def SetHost(self, url):
93
- self.host = url
94
-
95
- #
96
- # 查询余额
97
- # 参数:无
98
- # 返回值:
99
- # rsp.ret_code:正常返回0
100
- # rsp.cust_val:用户余额
101
- # rsp.err_msg:异常时返回异常详情
102
- #
103
- def QueryBalc(self):
104
- tm = str(int(time.time()))
105
- sign = CalcSign(self.pd_id, self.pd_key, tm)
106
- param = {
107
- "user_id": self.pd_id,
108
- "timestamp": tm,
109
- "sign": sign
110
- }
111
- url = self.host + "/api/custval"
112
- rsp = HttpRequest(url, param)
113
- if rsp.ret_code == 0:
114
- LOG("query succ ret: {} cust_val: {} rsp: {} pred: {}".format(rsp.ret_code, rsp.cust_val, rsp.err_msg,
115
- rsp.pred_rsp.value))
116
- else:
117
- LOG("query failed ret: {} err: {}".format(rsp.ret_code, rsp.err_msg.encode('utf-8')))
118
- return rsp
119
-
120
- #
121
- # 查询网络延迟
122
- # 参数:pred_type:识别类型
123
- # 返回值:
124
- # rsp.ret_code:正常返回0
125
- # rsp.err_msg: 异常时返回异常详情
126
- #
127
- def QueryTTS(self, pred_type):
128
- tm = str(int(time.time()))
129
- sign = CalcSign(self.pd_id, self.pd_key, tm)
130
- param = {
131
- "user_id": self.pd_id,
132
- "timestamp": tm,
133
- "sign": sign,
134
- "predict_type": pred_type,
135
- }
136
- if self.app_id != "":
137
- #
138
- asign = CalcSign(self.app_id, self.app_key, tm)
139
- param["appid"] = self.app_id
140
- param["asign"] = asign
141
- url = self.host + "/api/qcrtt"
142
- rsp = HttpRequest(url, param)
143
- if rsp.ret_code == 0:
144
- LOG("query rtt succ ret: {} request_id: {} err: {}".format(rsp.ret_code, rsp.request_id, rsp.err_msg))
145
- else:
146
- LOG("predict failed ret: {} err: {}".format(rsp.ret_code, rsp.err_msg.encode('utf-8')))
147
- return rsp
148
-
149
- #
150
- # 识别验证码
151
- # 参数:pred_type:识别类型 img_data:图片的数据
152
- # 返回值:
153
- # rsp.ret_code:正常返回0
154
- # rsp.request_id:唯一订单号
155
- # rsp.pred_rsp.value:识别结果
156
- # rsp.err_msg:异常时返回异常详情
157
- #
158
- def Predict(self, pred_type, img_data, head_info=""):
159
- tm = str(int(time.time()))
160
- sign = CalcSign(self.pd_id, self.pd_key, tm)
161
- param = {
162
- "user_id": self.pd_id,
163
- "timestamp": tm,
164
- "sign": sign,
165
- "predict_type": pred_type,
166
- "up_type": "mt"
167
- }
168
- if head_info is not None or head_info != "":
169
- param["head_info"] = head_info
170
- if self.app_id != "":
171
- #
172
- asign = CalcSign(self.app_id, self.app_key, tm)
173
- param["appid"] = self.app_id
174
- param["asign"] = asign
175
- url = self.host + "/api/capreg"
176
- files = img_data
177
- rsp = HttpRequest(url, param, files)
178
- if rsp.ret_code == 0:
179
- LOG("predict succ ret: {} request_id: {} pred: {} err: {}".format(rsp.ret_code, rsp.request_id,
180
- rsp.pred_rsp.value, rsp.err_msg))
181
- else:
182
- LOG("predict failed ret: {} err: {}".format(rsp.ret_code, rsp.err_msg))
183
- if rsp.ret_code == 4003:
184
- # lack of money
185
- LOG("cust_val <= 0 lack of money, please charge immediately")
186
- return rsp
187
-
188
- #
189
- # 从文件进行验证码识别
190
- # 参数:pred_type;识别类型 file_name:文件名
191
- # 返回值:
192
- # rsp.ret_code:正常返回0
193
- # rsp.request_id:唯一订单号
194
- # rsp.pred_rsp.value:识别结果
195
- # rsp.err_msg:异常时返回异常详情
196
- #
197
- def PredictFromFile(self, pred_type, file_name, head_info=""):
198
- with open(file_name, "rb") as f:
199
- data = f.read()
200
- return self.Predict(pred_type, data, head_info=head_info)
201
-
202
- #
203
- # 识别失败,进行退款请求
204
- # 参数:request_id:需要退款的订单号
205
- # 返回值:
206
- # rsp.ret_code:正常返回0
207
- # rsp.err_msg:异常时返回异常详情
208
- #
209
- # 注意:
210
- # Predict识别接口,仅在ret_code == 0时才会进行扣款,才需要进行退款请求,否则无需进行退款操作
211
- # 注意2:
212
- # 退款仅在正常识别出结果后,无法通过网站验证的情况,请勿非法或者滥用,否则可能进行封号处理
213
- #
214
- def Justice(self, request_id):
215
- if request_id == "":
216
- #
217
- return
218
- tm = str(int(time.time()))
219
- sign = CalcSign(self.pd_id, self.pd_key, tm)
220
- param = {
221
- "user_id": self.pd_id,
222
- "timestamp": tm,
223
- "sign": sign,
224
- "request_id": request_id
225
- }
226
- url = self.host + "/api/capjust"
227
- rsp = HttpRequest(url, param)
228
- if rsp.ret_code == 0:
229
- LOG("justice succ ret: {} request_id: {} pred: {} err: {}".format(rsp.ret_code, rsp.request_id,
230
- rsp.pred_rsp.value, rsp.err_msg))
231
- else:
232
- LOG("justice failed ret: {} err: {}".format(rsp.ret_code, rsp.err_msg.encode('utf-8')))
233
- return rsp
234
-
235
- #
236
- # 充值接口
237
- # 参数:cardid:充值卡号 cardkey:充值卡签名串
238
- # 返回值:
239
- # rsp.ret_code:正常返回0
240
- # rsp.err_msg:异常时返回异常详情
241
- #
242
- def Charge(self, cardid, cardkey):
243
- tm = str(int(time.time()))
244
- sign = CalcSign(self.pd_id, self.pd_key, tm)
245
- csign = CalcCardSign(cardid, cardkey, tm, self.pd_key)
246
- param = {
247
- "user_id": self.pd_id,
248
- "timestamp": tm,
249
- "sign": sign,
250
- 'cardid': cardid,
251
- 'csign': csign
252
- }
253
- url = self.host + "/api/charge"
254
- rsp = HttpRequest(url, param)
255
- if rsp.ret_code == 0:
256
- LOG("charge succ ret: {} request_id: {} pred: {} err: {}".format(rsp.ret_code, rsp.request_id,
257
- rsp.pred_rsp.value, rsp.err_msg))
258
- else:
259
- LOG("charge failed ret: {} err: {}".format(rsp.ret_code, rsp.err_msg.encode('utf-8')))
260
- return rsp
261
-
262
- ##
263
- # 充值,只返回是否成功
264
- # 参数:cardid:充值卡号 cardkey:充值卡签名串
265
- # 返回值: 充值成功时返回0
266
- ##
267
- def ExtendCharge(self, cardid, cardkey):
268
- return self.Charge(cardid, cardkey).ret_code
269
-
270
- ##
271
- # 调用退款,只返回是否成功
272
- # 参数: request_id:需要退款的订单号
273
- # 返回值: 退款成功时返回0
274
- #
275
- # 注意:
276
- # Predict识别接口,仅在ret_code == 0时才会进行扣款,才需要进行退款请求,否则无需进行退款操作
277
- # 注意2:
278
- # 退款仅在正常识别出结果后,无法通过网站验证的情况,请勿非法或者滥用,否则可能进行封号处理
279
- ##
280
- def JusticeExtend(self, request_id):
281
- return self.Justice(request_id).ret_code
282
-
283
- ##
284
- # 查询余额,只返回余额
285
- # 参数:无
286
- # 返回值:rsp.cust_val:余额
287
- ##
288
- def QueryBalcExtend(self):
289
- rsp = self.QueryBalc()
290
- return rsp.cust_val
291
-
292
- ##
293
- # 从文件识别验证码,只返回识别结果
294
- # 参数:pred_type;识别类型 file_name:文件名
295
- # 返回值: rsp.pred_rsp.value:识别的结果
296
- ##
297
- def PredictFromFileExtend(self, pred_type, file_name, head_info=""):
298
- rsp = self.PredictFromFile(pred_type, file_name, head_info)
299
- return rsp.pred_rsp.value
300
-
301
- ##
302
- # 识别接口,只返回识别结果
303
- # 参数:pred_type:识别类型 img_data:图片的数据
304
- # 返回值: rsp.pred_rsp.value:识别的结果
305
- ##
306
- def PredictExtend(self, pred_type, img_data, head_info=""):
307
- rsp = self.Predict(pred_type, img_data, head_info)
308
- return rsp.pred_rsp.value
309
-
310
-
311
- #
312
- # def TestFunc():
313
- # pd_id = "120292" # 用户中心页可以查询到pd信息
314
- # pd_key = "i3M9C5vG7nWqAyP9xW2aZke9utdZsJRC"
315
- # app_id = "320292" # 开发者分成用的账号,在开发者中心可以查询到
316
- # app_key = "c7Op85NwodVYZjZ80pPp/2QTkEAPouGT"
317
- # # 识别类型,
318
- # # 具体类型可以查看官方网站的价格页选择具体的类型,不清楚类型的,可以咨询客服
319
- # pred_type = "30400"
320
- # api = FateadmApi(app_id, app_key, pd_id, pd_key)
321
- # # 查询余额
322
- # balance = api.QueryBalcExtend() # 直接返余额
323
- # # api.QueryBalc()
324
- #
325
- # # 通过文件形式识别:
326
- # file_name = "img.jpg"
327
- # # 多网站类型时,需要增加src_url参数,具体请参考api文档: http://docs.fateadm.com/web/#/1?page_id=6
328
- # # result = api.PredictFromFileExtend(pred_type,file_name) # 直接返回识别结果
329
- # rsp = api.PredictFromFile(pred_type, file_name) # 返回详细识别结果
330
- #
331
- # '''
332
- # # 如果不是通过文件识别,则调用Predict接口:
333
- # # result = api.PredictExtend(pred_type,data) # 直接返回识别结果
334
- # rsp = api.Predict(pred_type,data) # 返回详细的识别结果
335
- # '''
336
- #
337
- # just_flag = False
338
- # if just_flag:
339
- # if rsp.ret_code == 0:
340
- # # 识别的结果如果与预期不符,可以调用这个接口将预期不符的订单退款
341
- # # 退款仅在正常识别出结果后,无法通过网站验证的情况,请勿非法或者滥用,否则可能进行封号处理
342
- # api.Justice(rsp.request_id)
343
- #
344
- # # card_id = "123"
345
- # # card_key = "123"
346
- # # 充值
347
- # # api.Charge(card_id, card_key)
348
- # LOG("print in testfunc")
349
- #
350
- #
351
- # if __name__ == "__main__":
352
- # TestFunc()
353
-
354
- class UseFateadm(object):
355
- def __init__(self, pd_id="120292", pd_key="i3M9C5vG7nWqAyP9xW2aZke9utdZsJRC", app_id="320292",
356
- app_key="c7Op85NwodVYZjZ80pPp/2QTkEAPouGT"):
357
- self.pd_id = pd_id # 用户中心页可以查询到pd信息
358
- self.pd_key = pd_key
359
- self.app_id = app_id # 开发者分成用的账号,在开发者中心可以查询到
360
- self.app_key = app_key
361
- # 具体类型可以查看官方网站的价格页选择具体的类型,不清楚类型的,可以咨询客服
362
- self.pred_type = "30400"
363
- self.api = FateadmApi(self.app_id, self.app_key, self.pd_id, self.pd_key)
364
-
365
- def set_pred_type(self, pred_type):
366
- self.pred_type = pred_type
367
-
368
- def get_balance(self):
369
- # 查询余额
370
- balance = self.api.QueryBalcExtend() # 直接返余额
371
- return balance
372
-
373
- def get_queryBalc(self):
374
- """
375
- # 查询余额
376
- # 参数:无
377
- # 返回值:
378
- # rsp.ret_code:正常返回0
379
- # rsp.cust_val:用户余额
380
- # rsp.err_msg:异常时返回异常详情
381
- #
382
- :return:
383
- """
384
- self.api.QueryBalc()
385
-
386
- def PredictFromFileExtend(self, file_name, pred_type=None):
387
- if pred_type == None:
388
- pred_type = self.pred_type
389
- # 多网站类型时,需要增加src_url参数,具体请参考api文档: http://docs.fateadm.com/web/#/1?page_id=6
390
- result = self.api.PredictFromFileExtend(pred_type, file_name) # 直接返回识别结果
391
- return result
392
-
393
- def PredictFromFile(self, file_name, pred_type=None): # 返回详细识别结果
394
- if pred_type == None:
395
- pred_type = self.pred_type
396
- rsp = self.api.PredictFromFile(pred_type, file_name) # 返回详细识别结果
397
- return rsp
398
-
399
- def PredictExtend(self, data, pred_type=None):
400
- if pred_type == None:
401
- pred_type = self.pred_type
402
- # 多网站类型时,需要增加src_url参数,具体请参考api文档: http://docs.fateadm.com/web/#/1?page_id=6
403
- result = self.api.PredictExtend(pred_type, data) # 直接返回识别结果
404
- return result
405
-
406
- def Predict(self, data, pred_type=None): # 返回详细识别结果
407
- if pred_type == None:
408
- pred_type = self.pred_type
409
- rsp = self.api.Predict(pred_type, data) # 返回详细的识别结果
410
- return rsp
411
-
412
- def Justice(self, rsp):
413
- if rsp.ret_code == 0:
414
- # 识别的结果如果与预期不符,可以调用这个接口将预期不符的订单退款
415
- # 退款仅在正常识别出结果后,无法通过网站验证的情况,请勿非法或者滥用,否则可能进行封号处理
416
- self.api.Justice(rsp.request_id)
417
-
418
- def Charge(self, card_id, card_key):
419
- """
420
- # 充值接口
421
- # 参数:cardid:充值卡号 cardkey:充值卡签名串
422
- # 返回值:
423
- # rsp.ret_code:正常返回0
424
- # rsp.err_msg:异常时返回异常详情
425
- :param card_id:
426
- :param card_key:
427
- :return:
428
- """
429
- self.api.Charge(card_id, card_key)
@@ -1,123 +0,0 @@
1
- import os
2
- import sys
3
- import importlib
4
-
5
-
6
- def import_fun(obj, mod, m=[], modename=""):
7
- """
8
- 这个方法只能在类里面设置属性
9
- :param obj:
10
- :param mod:
11
- :param m:
12
- :return:
13
- """
14
- if m:
15
- for item in m:
16
- module = getattr(mod, item)
17
- setattr(obj, item, module)
18
- elif modename:
19
- setattr(obj, modename, mod)
20
- else:
21
- raise ValueError("m 和 modename必须存在一个")
22
-
23
-
24
- def import_to_val(mod, m=[], globals=None, locals=None):
25
- """
26
- 设置到变量,在你调用的文件中使用
27
- :param mod: 一个模块对象
28
- :param m: 一个列表 mod 里面的变量类和函数
29
- :param globals: 传入 globals()
30
- :param locals: 传入 locals()
31
- :return:
32
- """
33
- dicts = {}
34
- for item in m:
35
- # module = getattr(mod, item)
36
- exec("{}=getattr(mod, '{}')".format(item, item))
37
- dicts[item] = eval(item)
38
- if globals:
39
- globals.update({item: eval(item)})
40
- if locals:
41
- locals.update({item: eval(item)})
42
- return dicts
43
-
44
-
45
- def import_model(name):
46
- """
47
- import 模块
48
- """
49
- return importlib.import_module(name)
50
-
51
-
52
- def symbol_by_name(name, aliases=None, imp=None, package=None,
53
- sep='.', default=None, **kwargs):
54
- """Get symbol by qualified name.
55
-
56
- The name should be the full dot-separated path to the class::
57
-
58
- modulename.ClassName
59
-
60
- Example::
61
-
62
- celery.concurrency.processes.TaskPool
63
- ^- class name
64
-
65
- or using ':' to separate module and symbol::
66
-
67
- celery.concurrency.processes:TaskPool
68
-
69
- If `aliases` is provided, a dict containing short name/long name
70
- mappings, the name is looked up in the aliases first.
71
-
72
- Examples:
73
- >>> symbol_by_name('celery.concurrency.processes.TaskPool')
74
- <class 'celery.concurrency.processes.TaskPool'>
75
-
76
- >>> symbol_by_name('default', {
77
- ... 'default': 'celery.concurrency.processes.TaskPool'})
78
- <class 'celery.concurrency.processes.TaskPool'>
79
-
80
- # Does not try to look up non-string names.
81
- from celery.concurrency.processes import TaskPool
82
- symbol_by_name(TaskPool) is TaskPool
83
- True
84
- """
85
- from re_common.baselibrary.utils.baseexcept import reraise
86
- aliases = {} if not aliases else aliases
87
- if imp is None:
88
- imp = importlib.import_module
89
-
90
- if not isinstance(name, str):
91
- return name # already a class
92
-
93
- name = aliases.get(name) or name
94
- sep = ':' if ':' in name else sep
95
- module_name, _, cls_name = name.rpartition(sep)
96
- if not module_name:
97
- cls_name, module_name = None, package if package else cls_name
98
- try:
99
- try:
100
- # 这里的 **kwargs 是为了兼容 传入的 imp
101
- module = imp(module_name, package=package, **kwargs)
102
- except ValueError as exc:
103
- reraise(ValueError,
104
- ValueError(f"Couldn't import {name!r}: {exc}"),
105
- sys.exc_info()[2])
106
- return getattr(module, cls_name) if cls_name else module
107
- except (ImportError, AttributeError):
108
- if default is None:
109
- raise
110
- return default
111
-
112
-
113
- def set_topdir_to_path(file, top_name):
114
- """
115
-
116
- :param file: 请传入 __file__
117
- :param top_name: 顶层目录的名字如 本项目为re-common
118
- :return:
119
- """
120
- pathlist = os.path.dirname(os.path.abspath(file)).split(os.sep)
121
- root_path = os.sep.join(pathlist[:pathlist.index(top_name) + 1])
122
- sys.path.insert(0, root_path)
123
- sys.path = list(set(sys.path))
@@ -1,57 +0,0 @@
1
- import random
2
-
3
- from faker import Faker
4
-
5
-
6
- # https://www.jianshu.com/p/20e41fc65dc8
7
-
8
- class MFaker(Faker):
9
- # 生成名字
10
- m_name = "name"
11
- # 生成地址
12
- m_address = "address"
13
- # 生成国家
14
- m_country = "country"
15
- # 生成省份
16
- m_province = "province"
17
- # 生成市 县
18
- m_city_suffix = "city_suffix"
19
-
20
- # 以下结构都可以用 py_para 结构的参数
21
- # 生成dict
22
- m_pydict = "pydict"
23
- # 生成list
24
- m_pylist = "pylist"
25
- # 生成iterable
26
- m_pyiterable = "pyiterable"
27
- # 生成set
28
- m_pyset = "pyset"
29
- # 生成tuple
30
- m_pytuple = "pytuple"
31
-
32
- def create_data(self, types, **kwargs):
33
- """
34
- :param types: 是上面的类型
35
- :param kwargs: 类型的参数
36
- :return:
37
- """
38
- if kwargs:
39
- print(kwargs)
40
- return getattr(self, types)(**kwargs)
41
- return getattr(self, types)()
42
-
43
- def py_para(self, num=10):
44
- """
45
- python 集合参数 适用于python 原生集合
46
- pydict pylist 的参数
47
- :return:
48
- """
49
- return {"nb_elements": num, "variable_nb_elements": True}
50
-
51
- def get_page(self):
52
- return random.randint(1, 150)
53
-
54
-
55
-
56
-
57
-
@@ -1,3 +0,0 @@
1
- # 该库来自于 my_abc 由于代码量太小 不想为此安装一个库,故将代码引入到基础库
2
- # 如果该库后面有更新,可以选择继续引入或者直接使用第三方库
3
-
@@ -1,32 +0,0 @@
1
- from abc import ABCMeta as NativeABCMeta
2
-
3
-
4
- class DummyAttribute:
5
- pass
6
-
7
-
8
- def abstract_attribute(obj=None):
9
- if obj is None:
10
- obj = DummyAttribute()
11
- obj.__is_abstract_attribute__ = True
12
- return obj
13
-
14
-
15
- class ABCMeta(NativeABCMeta):
16
-
17
- def __call__(cls, *args, **kwargs):
18
- instance = NativeABCMeta.__call__(cls, *args, **kwargs)
19
- abstract_attributes = {
20
- name
21
- for name in dir(instance)
22
- if getattr(getattr(instance, name), '__is_abstract_attribute__', False)
23
- }
24
- if abstract_attributes:
25
- raise NotImplementedError(
26
- "Can't instantiate abstract class {} with"
27
- " abstract attributes: {}".format(
28
- cls.__name__,
29
- ', '.join(abstract_attributes)
30
- )
31
- )
32
- return instance