ezKit 1.8.2__py3-none-any.whl → 1.8.3__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.
- ezKit/cipher.py +5 -6
- ezKit/cls.py +80 -0
- ezKit/database.py +7 -8
- ezKit/http.py +1 -0
- ezKit/qywx.py +21 -18
- ezKit/stock.py +0 -1
- ezKit/xftp.py +2 -3
- {ezKit-1.8.2.dist-info → ezKit-1.8.3.dist-info}/METADATA +1 -1
- ezKit-1.8.3.dist-info/RECORD +20 -0
- ezKit-1.8.2.dist-info/RECORD +0 -20
- {ezKit-1.8.2.dist-info → ezKit-1.8.3.dist-info}/LICENSE +0 -0
- {ezKit-1.8.2.dist-info → ezKit-1.8.3.dist-info}/WHEEL +0 -0
- {ezKit-1.8.2.dist-info → ezKit-1.8.3.dist-info}/top_level.txt +0 -0
ezKit/cipher.py
CHANGED
@@ -1,9 +1,8 @@
|
|
1
|
-
"""
|
2
|
-
https://docs.python.org/3.10/library/hashlib.html
|
3
|
-
https://www.pycrypto.org/
|
4
|
-
https://stackoverflow.com/a/21928790
|
5
|
-
pip install pycryptodome
|
6
|
-
"""
|
1
|
+
"""Cipher"""
|
2
|
+
# https://docs.python.org/3.10/library/hashlib.html
|
3
|
+
# https://www.pycrypto.org/
|
4
|
+
# https://stackoverflow.com/a/21928790
|
5
|
+
# pip install pycryptodome
|
7
6
|
import base64
|
8
7
|
import hashlib
|
9
8
|
|
ezKit/cls.py
CHANGED
@@ -88,3 +88,83 @@ def up_down_analysis(
|
|
88
88
|
logger.error(f"{info} [失败]")
|
89
89
|
logger.exception(e)
|
90
90
|
return None
|
91
|
+
|
92
|
+
|
93
|
+
# --------------------------------------------------------------------------------------------------
|
94
|
+
|
95
|
+
|
96
|
+
def latest_data(
|
97
|
+
payload: dict,
|
98
|
+
end: str = "basic",
|
99
|
+
data_type: str = "stock",
|
100
|
+
df: bool = False
|
101
|
+
) -> dict | pd.DataFrame | None:
|
102
|
+
"""股票或板块的最新数据"""
|
103
|
+
|
104
|
+
match True:
|
105
|
+
case True if isinstance(payload, dict) is False:
|
106
|
+
logger.error("Incorrect function argument type: payload")
|
107
|
+
return None
|
108
|
+
case True if isinstance(end, str) is False:
|
109
|
+
logger.error("Incorrect function argument type: end")
|
110
|
+
return None
|
111
|
+
case True if isinstance(data_type, str) is False:
|
112
|
+
logger.error("Incorrect function argument type: data_type")
|
113
|
+
return None
|
114
|
+
case _:
|
115
|
+
pass
|
116
|
+
|
117
|
+
info: str = "获取股票最新数据"
|
118
|
+
|
119
|
+
if utils.v_true(data_type, str) is True and data_type == "plate":
|
120
|
+
info = "获取板块最新数据"
|
121
|
+
|
122
|
+
try:
|
123
|
+
|
124
|
+
logger.info(f"{info} ......")
|
125
|
+
|
126
|
+
user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
|
127
|
+
headers = {"User-Agent": user_agent}
|
128
|
+
|
129
|
+
# https://x-quote.cls.cn/quote/stock/basic?secu_code={code}
|
130
|
+
api = f"https://x-quote.cls.cn/quote/stock/{end}"
|
131
|
+
|
132
|
+
if data_type == "plate":
|
133
|
+
# https://x-quote.cls.cn/web_quote/plate/stocks?secu_code=cls80382
|
134
|
+
# https://x-quote.cls.cn/web_quote/plate/stocks?secu_code={code}
|
135
|
+
# https://x-quote.cls.cn/web_quote/plate/industry?secu_code={code}
|
136
|
+
api = f"https://x-quote.cls.cn/web_quote/plate/{end}"
|
137
|
+
|
138
|
+
# response = requests.get(api, headers=headers, timeout=10)
|
139
|
+
response = requests.get(api, headers=headers, params=payload, timeout=10)
|
140
|
+
|
141
|
+
response_dict: dict = response.json()
|
142
|
+
|
143
|
+
if utils.v_true(df, bool) is False:
|
144
|
+
logger.success(f"{info} [成功]")
|
145
|
+
return response_dict
|
146
|
+
|
147
|
+
if data_type == "plate" and utils.v_true(df, bool) is True:
|
148
|
+
logger.error(f"{info} [错误]")
|
149
|
+
return None
|
150
|
+
|
151
|
+
if response_dict["data"]["trade_status"] == "STOPT":
|
152
|
+
logger.error(f"{info} [停牌]")
|
153
|
+
return None
|
154
|
+
|
155
|
+
data_object = {
|
156
|
+
# "date": [pd.to_datetime(date_today)],
|
157
|
+
"open": [float(response_dict["data"]["open_px"])],
|
158
|
+
"close": [float(response_dict["data"]["last_px"])],
|
159
|
+
"high": [float(response_dict["data"]["high_px"])],
|
160
|
+
"low": [float(response_dict["data"]["low_px"])],
|
161
|
+
"volume": [int(response_dict["data"]["business_amount"])],
|
162
|
+
"turnover": [float(response_dict["data"]["tr"])]
|
163
|
+
}
|
164
|
+
logger.success(f"{info} [成功]")
|
165
|
+
return pd.DataFrame(data=data_object)
|
166
|
+
|
167
|
+
except Exception as e:
|
168
|
+
logger.error(f"{info} [失败]")
|
169
|
+
logger.exception(e)
|
170
|
+
return None
|
ezKit/database.py
CHANGED
@@ -1,11 +1,10 @@
|
|
1
|
-
"""
|
2
|
-
Column, Table, MetaData API
|
3
|
-
|
4
|
-
CursorResult
|
5
|
-
|
6
|
-
PostgreSQL 14 Data Types
|
7
|
-
|
8
|
-
"""
|
1
|
+
"""Database"""
|
2
|
+
# Column, Table, MetaData API
|
3
|
+
# https://docs.sqlalchemy.org/en/14/core/metadata.html#column-table-metadata-api
|
4
|
+
# CursorResult
|
5
|
+
# https://docs.sqlalchemy.org/en/20/core/connections.html#sqlalchemy.engine.CursorResult
|
6
|
+
# PostgreSQL 14 Data Types
|
7
|
+
# https://www.postgresql.org/docs/14/datatype.html
|
9
8
|
import csv
|
10
9
|
from typing import Any
|
11
10
|
|
ezKit/http.py
CHANGED
ezKit/qywx.py
CHANGED
@@ -1,14 +1,10 @@
|
|
1
|
-
"""
|
2
|
-
企业微信开发者中心
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
https://www.gaoyuanqi.cn/python-yingyong-qiyewx/
|
10
|
-
https://www.jianshu.com/p/020709b130d3
|
11
|
-
"""
|
1
|
+
"""企业微信"""
|
2
|
+
# 企业微信开发者中心
|
3
|
+
# https://developer.work.weixin.qq.com/
|
4
|
+
# https://developer.work.weixin.qq.com/document/path/90313 (全局错误码)
|
5
|
+
# 参考文档:
|
6
|
+
# https://www.gaoyuanqi.cn/python-yingyong-qiyewx/
|
7
|
+
# https://www.jianshu.com/p/020709b130d3
|
12
8
|
import json
|
13
9
|
import time
|
14
10
|
|
@@ -39,12 +35,15 @@ class QYWX:
|
|
39
35
|
def getaccess_token(self) -> str | None:
|
40
36
|
try:
|
41
37
|
response = requests.get(f"{self.url_prefix}/cgi-bin/gettoken?corpid={self.work_id}&corpsecret={self.agent_secret}", timeout=10)
|
42
|
-
|
43
|
-
|
44
|
-
self.access_token = result.get('access_token')
|
45
|
-
else:
|
38
|
+
|
39
|
+
if response.status_code != 200:
|
46
40
|
self.access_token = None
|
41
|
+
return None
|
42
|
+
|
43
|
+
result: dict = response.json()
|
44
|
+
self.access_token = result.get('access_token')
|
47
45
|
return result.get('access_token')
|
46
|
+
|
48
47
|
except Exception as e:
|
49
48
|
logger.exception(e)
|
50
49
|
return None
|
@@ -151,15 +150,19 @@ class QYWX:
|
|
151
150
|
users: list = []
|
152
151
|
|
153
152
|
match True:
|
154
|
-
case True if utils.v_true(mobile, list):
|
153
|
+
case True if isinstance(mobile, list) and utils.v_true(mobile, list):
|
155
154
|
users = mobile
|
156
|
-
case True if utils.v_true(mobile, str):
|
155
|
+
case True if isinstance(mobile, str) and utils.v_true(mobile, str):
|
157
156
|
users.append(mobile)
|
158
157
|
case _:
|
159
|
-
return
|
158
|
+
return False
|
160
159
|
|
161
160
|
for user in users:
|
162
161
|
user_object = self.get_user_id_by_mobile(user)
|
162
|
+
|
163
|
+
if not isinstance(user_object, dict):
|
164
|
+
continue
|
165
|
+
|
163
166
|
json_dict = {
|
164
167
|
'touser': user_object.get('userid'),
|
165
168
|
'msgtype': 'text',
|
ezKit/stock.py
CHANGED
ezKit/xftp.py
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
ezKit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
+
ezKit/bottle.py,sha256=usKK1wVaZw4_D-4VwMYmOIc8jtz4TrpM30nck59HMFw,180178
|
3
|
+
ezKit/bottle_extensions.py,sha256=LQikCbbYZBAa4AcihvrTvixWHHMY7OjCBsT02PqWMMM,1129
|
4
|
+
ezKit/cipher.py,sha256=0T_StbjiNI4zgrjVgcfU-ffKgu1waBA9UDudAnqFcNM,2896
|
5
|
+
ezKit/cls.py,sha256=RM0w2DFWTOtqBnrMUhi-Qx0mecgdKntjo7LxjFRxT2k,6176
|
6
|
+
ezKit/database.py,sha256=kYb0ybACxrdFZnwJ40bTbG8Obh2oEF3GQWmCbPVgH-c,6878
|
7
|
+
ezKit/http.py,sha256=N2x86HCmJ5ejwA3-gHowEgSpaFTFT9nCWFjPuQ1T_do,1801
|
8
|
+
ezKit/mongo.py,sha256=P6WTwFRxaaHixJK_PyKlOfPHkeJRxxrNLV77xy5LVBQ,2048
|
9
|
+
ezKit/qywx.py,sha256=rdhusXl6YZUbsYm4HJUzWqGPFFlGqwKA4ygzwxiiBl4,7171
|
10
|
+
ezKit/redis.py,sha256=HVofsLdSBbBHAR-veumsrjTwZQspRDy2FXNR6MDCCXs,1972
|
11
|
+
ezKit/sendemail.py,sha256=Qxu4XQkHRPeX6FSJdzj-MXND9NyKcgHljbafNmy34H0,8243
|
12
|
+
ezKit/stock.py,sha256=p-l6Tv0oZdJ3juxkddScphm7BW4vH-mBozBgSH1Qu0w,1730
|
13
|
+
ezKit/token.py,sha256=9CAZhPdXiRiWoOIeWmP0q6L3j1zQAv4YcVWH95Tjefs,1755
|
14
|
+
ezKit/utils.py,sha256=an7joZy_EEpYfN8zBtEWAnhP0YXYfPieabsK_HAxXl4,48921
|
15
|
+
ezKit/xftp.py,sha256=XyIdr_2rxRVLqPofG6fIYWhAMVsFwTyp46dg5P9FLW4,7774
|
16
|
+
ezKit-1.8.3.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
17
|
+
ezKit-1.8.3.dist-info/METADATA,sha256=zBWEfYeVzFBpNoj8Cgqwdo1xJANBqF5O_yLGX1S-KTQ,190
|
18
|
+
ezKit-1.8.3.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
19
|
+
ezKit-1.8.3.dist-info/top_level.txt,sha256=aYLB_1WODsqNTsTFWcKP-BN0KCTKcV-HZJ4zlHkCFw8,6
|
20
|
+
ezKit-1.8.3.dist-info/RECORD,,
|
ezKit-1.8.2.dist-info/RECORD
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
ezKit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
-
ezKit/bottle.py,sha256=usKK1wVaZw4_D-4VwMYmOIc8jtz4TrpM30nck59HMFw,180178
|
3
|
-
ezKit/bottle_extensions.py,sha256=LQikCbbYZBAa4AcihvrTvixWHHMY7OjCBsT02PqWMMM,1129
|
4
|
-
ezKit/cipher.py,sha256=uVUzeoYg5ZPJLpqg2wLst-7vfdDGmqWKka9Oyi0WrCA,2883
|
5
|
-
ezKit/cls.py,sha256=mkNSguUNocP8aKh1GEpkUMgL9xRXfMKdGs6tEeeV5X8,3266
|
6
|
-
ezKit/database.py,sha256=awTEdD4aqevyJg5LPBHmUPrOKweqzJ2Ezqqx0_xgUDA,6859
|
7
|
-
ezKit/http.py,sha256=cyS18-TW9f7p1OaiJ4nnVsKZT8Ghy-8OewkfYm8yesw,1790
|
8
|
-
ezKit/mongo.py,sha256=P6WTwFRxaaHixJK_PyKlOfPHkeJRxxrNLV77xy5LVBQ,2048
|
9
|
-
ezKit/qywx.py,sha256=ra2e3u8IJmNZXr569u1mik3KArAiMdC9x0SgXGXEJes,7003
|
10
|
-
ezKit/redis.py,sha256=HVofsLdSBbBHAR-veumsrjTwZQspRDy2FXNR6MDCCXs,1972
|
11
|
-
ezKit/sendemail.py,sha256=Qxu4XQkHRPeX6FSJdzj-MXND9NyKcgHljbafNmy34H0,8243
|
12
|
-
ezKit/stock.py,sha256=gEy4N7S0GsZCdfEdYHfaUHMEHMFmNGfHm198hG5n5eI,1754
|
13
|
-
ezKit/token.py,sha256=9CAZhPdXiRiWoOIeWmP0q6L3j1zQAv4YcVWH95Tjefs,1755
|
14
|
-
ezKit/utils.py,sha256=an7joZy_EEpYfN8zBtEWAnhP0YXYfPieabsK_HAxXl4,48921
|
15
|
-
ezKit/xftp.py,sha256=7BABr-gjxZxK2UXoW9XxN76i1HdubeaomYlYMqRurHE,7770
|
16
|
-
ezKit-1.8.2.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
17
|
-
ezKit-1.8.2.dist-info/METADATA,sha256=Vnx7icBFnyUYYAHZz3jh5hhDS11d3hHngGlBz-DkWwU,190
|
18
|
-
ezKit-1.8.2.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
19
|
-
ezKit-1.8.2.dist-info/top_level.txt,sha256=aYLB_1WODsqNTsTFWcKP-BN0KCTKcV-HZJ4zlHkCFw8,6
|
20
|
-
ezKit-1.8.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|