reykit 1.0.1__py3-none-any.whl → 1.1.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.
- reydb/__init__.py +1 -1
- reydb/rbuild.py +44 -44
- reydb/rconnection.py +107 -107
- reydb/rexecute.py +9 -13
- reydb/rfile.py +8 -8
- reydb/rinformation.py +13 -25
- reydb/rparameter.py +10 -10
- reykit/__init__.py +1 -1
- reykit/rcomm.py +12 -12
- reykit/rdata.py +4 -4
- reykit/remail.py +12 -14
- reykit/rexception.py +4 -4
- reykit/rimage.py +9 -9
- reykit/rlog.py +30 -30
- reykit/rmonkey.py +4 -5
- reykit/rmultitask.py +14 -15
- reykit/rnumber.py +2 -2
- reykit/ros.py +21 -21
- reykit/rrandom.py +11 -11
- reykit/rregex.py +10 -13
- reykit/rschedule.py +10 -10
- reykit/rstdout.py +13 -13
- reykit/rsystem.py +224 -30
- reykit/rtable.py +31 -31
- reykit/rtext.py +3 -3
- reykit/rtime.py +11 -31
- reykit/rtype.py +2 -2
- reykit/rwrap.py +16 -16
- reykit/rzip.py +4 -5
- {reykit-1.0.1.dist-info → reykit-1.1.1.dist-info}/METADATA +1 -1
- reykit-1.1.1.dist-info/RECORD +38 -0
- reykit-1.0.1.dist-info/RECORD +0 -64
- reyweb/__init__.py +0 -19
- reyweb/rall.py +0 -12
- reyweb/rbaidu/__init__.py +0 -21
- reyweb/rbaidu/rbaidu_base.py +0 -186
- reyweb/rbaidu/rbaidu_chat.py +0 -299
- reyweb/rbaidu/rbaidu_image.py +0 -183
- reyweb/rbaidu/rbaidu_voice.py +0 -256
- reywechat/__init__.py +0 -32
- reywechat/data/client_api.dll +0 -0
- reywechat/rall.py +0 -20
- reywechat/rclient.py +0 -912
- reywechat/rdatabase.py +0 -1189
- reywechat/rexception.py +0 -65
- reywechat/rexecute.py +0 -201
- reywechat/rlog.py +0 -198
- reywechat/rreceive.py +0 -1232
- reywechat/rschedule.py +0 -136
- reywechat/rsend.py +0 -630
- reywechat/rwechat.py +0 -201
- reyworm/__init__.py +0 -24
- reyworm/rall.py +0 -16
- reyworm/rbrowser.py +0 -134
- reyworm/rcalendar.py +0 -159
- reyworm/rnews.py +0 -126
- reyworm/rsecurity.py +0 -239
- reyworm/rtranslate.py +0 -75
- {reykit-1.0.1.dist-info → reykit-1.1.1.dist-info}/WHEEL +0 -0
- {reykit-1.0.1.dist-info → reykit-1.1.1.dist-info}/top_level.txt +0 -0
reyworm/rsecurity.py
DELETED
@@ -1,239 +0,0 @@
|
|
1
|
-
# !/usr/bin/env python
|
2
|
-
# -*- coding: utf-8 -*-
|
3
|
-
|
4
|
-
"""
|
5
|
-
@Time : 2024-01-22 14:06:05
|
6
|
-
@Author : Rey
|
7
|
-
@Contact : reyxbo@163.com
|
8
|
-
@Explain : Security methods.
|
9
|
-
"""
|
10
|
-
|
11
|
-
|
12
|
-
from typing import Any, TypedDict, Literal, Union
|
13
|
-
from reykit.rcomm import request
|
14
|
-
from reykit.rexception import throw
|
15
|
-
from reykit.rregex import search, findall, sub
|
16
|
-
from reykit.rtime import now
|
17
|
-
|
18
|
-
|
19
|
-
__all__ = (
|
20
|
-
'search_sina_market',
|
21
|
-
'get_sina_stock_info'
|
22
|
-
)
|
23
|
-
|
24
|
-
|
25
|
-
SinaStockInfo = TypedDict(
|
26
|
-
'SinaStockInfo',
|
27
|
-
{
|
28
|
-
'code': str,
|
29
|
-
'name': str,
|
30
|
-
'price': float,
|
31
|
-
'open': float,
|
32
|
-
'pre_close': float,
|
33
|
-
'high': float,
|
34
|
-
'low': float,
|
35
|
-
'volume': int,
|
36
|
-
'amount': int,
|
37
|
-
'time': str,
|
38
|
-
'url': str,
|
39
|
-
'change': float,
|
40
|
-
'change_rate': float,
|
41
|
-
'swing': float
|
42
|
-
}
|
43
|
-
)
|
44
|
-
|
45
|
-
|
46
|
-
def search_sina_market(keyword: str) -> list[dict[Literal['code', 'name', 'type', 'url'], str]]:
|
47
|
-
"""
|
48
|
-
Search products from market from `sina` website.
|
49
|
-
|
50
|
-
Parameters
|
51
|
-
----------
|
52
|
-
keyword : Search keyword.
|
53
|
-
|
54
|
-
Returns
|
55
|
-
-------
|
56
|
-
Search result table.
|
57
|
-
"""
|
58
|
-
|
59
|
-
# Get parameter.
|
60
|
-
url = 'https://biz.finance.sina.com.cn/suggest/lookup_n.php'
|
61
|
-
params = {
|
62
|
-
'country': '',
|
63
|
-
'q': keyword
|
64
|
-
}
|
65
|
-
|
66
|
-
# Request.
|
67
|
-
response = request(
|
68
|
-
url,
|
69
|
-
params,
|
70
|
-
check=True
|
71
|
-
)
|
72
|
-
|
73
|
-
# Unique result.
|
74
|
-
if response.request.url.startswith("https://finance.sina.com.cn"):
|
75
|
-
pattern = "var papercode = '(.+?)'"
|
76
|
-
stock_code = search(pattern, response.text)
|
77
|
-
pattern = "var stockname = '(.+?)'"
|
78
|
-
stock_name = search(pattern, response.text)
|
79
|
-
row = {
|
80
|
-
'code': stock_code,
|
81
|
-
'name': stock_name,
|
82
|
-
'type': '沪深股市(个股)',
|
83
|
-
'url': response.request.url
|
84
|
-
}
|
85
|
-
table = [row]
|
86
|
-
return table
|
87
|
-
|
88
|
-
# Extract.
|
89
|
-
pattern = '<div class="(market|list)"(.+?)</div>'
|
90
|
-
labels_result: tuple[str, str] = findall(pattern, response.text)
|
91
|
-
table = []
|
92
|
-
for index, (label_class, div_text) in enumerate(labels_result):
|
93
|
-
if label_class != 'list':
|
94
|
-
continue
|
95
|
-
stock_type_div_text = labels_result[index - 1][1]
|
96
|
-
stock_type = stock_type_div_text.rsplit('<div>', 1)[1]
|
97
|
-
pattern = '<label><a href="([^"]+)" target="_blank">(.+?)</label>'
|
98
|
-
stocks_result = findall(pattern, div_text)
|
99
|
-
for stock_url, stock_text in stocks_result:
|
100
|
-
pattern = '<.+?>'
|
101
|
-
stock_info = sub(pattern, stock_text)
|
102
|
-
stock_info_split = stock_info.split(maxsplit=1)
|
103
|
-
if len(stock_info_split) != 2:
|
104
|
-
continue
|
105
|
-
stock_code, stock_name = stock_info_split
|
106
|
-
if stock_name.startswith('('):
|
107
|
-
stock_name = stock_name[1:-1]
|
108
|
-
row = {
|
109
|
-
'code': stock_code,
|
110
|
-
'name': stock_name,
|
111
|
-
'type': stock_type,
|
112
|
-
'url': stock_url
|
113
|
-
}
|
114
|
-
table.append(row)
|
115
|
-
|
116
|
-
return table
|
117
|
-
|
118
|
-
|
119
|
-
def get_sina_stock_info(code: Union[str, list[str]]) -> list[SinaStockInfo]:
|
120
|
-
"""
|
121
|
-
Get stock information table from `sina` website.
|
122
|
-
|
123
|
-
Parameters
|
124
|
-
----------
|
125
|
-
code : Stock code.
|
126
|
-
|
127
|
-
Returns
|
128
|
-
-------
|
129
|
-
Stock information table.
|
130
|
-
"""
|
131
|
-
|
132
|
-
# Get parameter.
|
133
|
-
if code.__class__ == str:
|
134
|
-
code = code.split(',')
|
135
|
-
code = [
|
136
|
-
(
|
137
|
-
i
|
138
|
-
if i[-1] in '0123456789'
|
139
|
-
else 'gb_' + i.replace('.', '$')
|
140
|
-
)
|
141
|
-
for i in code
|
142
|
-
]
|
143
|
-
code = ','.join(code)
|
144
|
-
code = code.lower()
|
145
|
-
url = 'https://hq.sinajs.cn/rn=%s&list=%s' % (
|
146
|
-
now('timestamp'),
|
147
|
-
code
|
148
|
-
)
|
149
|
-
headers = {'Referer': 'https://finance.sina.com.cn'}
|
150
|
-
|
151
|
-
# Request.
|
152
|
-
response = request(
|
153
|
-
url,
|
154
|
-
headers=headers,
|
155
|
-
check=True
|
156
|
-
)
|
157
|
-
|
158
|
-
# Extract.
|
159
|
-
pattern = '([^_]+?)="([^"]*)"'
|
160
|
-
result: list[tuple[str, str]] = findall(pattern, response.text)
|
161
|
-
table = []
|
162
|
-
for code, info in result:
|
163
|
-
info_list = info.split(',')
|
164
|
-
info_list_len = len(info_list)
|
165
|
-
match info_list_len:
|
166
|
-
|
167
|
-
## A.
|
168
|
-
case 34:
|
169
|
-
(
|
170
|
-
stock_name,
|
171
|
-
stock_open,
|
172
|
-
stock_pre_close,
|
173
|
-
stock_price,
|
174
|
-
stock_high,
|
175
|
-
stock_low,
|
176
|
-
_,
|
177
|
-
_,
|
178
|
-
stock_volume,
|
179
|
-
stock_amount,
|
180
|
-
*_,
|
181
|
-
stock_date,
|
182
|
-
stock_time,
|
183
|
-
_,
|
184
|
-
_
|
185
|
-
) = info_list
|
186
|
-
row = {
|
187
|
-
'code': code,
|
188
|
-
'name': stock_name,
|
189
|
-
'price': float(stock_price),
|
190
|
-
'open': float(stock_open),
|
191
|
-
'pre_close': float(stock_pre_close),
|
192
|
-
'high': float(stock_high),
|
193
|
-
'low': float(stock_low),
|
194
|
-
'volume': int(float(stock_volume)),
|
195
|
-
'amount': int(float(stock_amount)),
|
196
|
-
'time': '%s %s' % (stock_date, stock_time),
|
197
|
-
'url': 'https://finance.sina.com.cn/realstock/company/%s/nc.shtml' % code
|
198
|
-
}
|
199
|
-
|
200
|
-
# US.
|
201
|
-
case 36 | 30:
|
202
|
-
(
|
203
|
-
stock_name,
|
204
|
-
stock_price,
|
205
|
-
_,
|
206
|
-
stock_date_time,
|
207
|
-
_,
|
208
|
-
stock_open,
|
209
|
-
stock_high,
|
210
|
-
stock_low,
|
211
|
-
_, _,
|
212
|
-
stock_amount,
|
213
|
-
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
|
214
|
-
stock_pre_close,
|
215
|
-
*_
|
216
|
-
) = info_list
|
217
|
-
row = {
|
218
|
-
'code': code,
|
219
|
-
'name': stock_name,
|
220
|
-
'price': float(stock_price),
|
221
|
-
'open': float(stock_open),
|
222
|
-
'pre_close': float(stock_pre_close),
|
223
|
-
'high': float(stock_high),
|
224
|
-
'low': float(stock_low),
|
225
|
-
'amount': int(float(stock_amount)),
|
226
|
-
'time': stock_date_time,
|
227
|
-
'url': 'https://stock.finance.sina.com.cn/usstock/quotes/%s.html' % code.replace('$', '.')
|
228
|
-
}
|
229
|
-
|
230
|
-
## Throw exception.
|
231
|
-
case _:
|
232
|
-
throw(value=info)
|
233
|
-
|
234
|
-
row['change'] = round(row['price'] - row['pre_close'], 4)
|
235
|
-
row['change_rate'] = round(row['change'] / row['pre_close'] * 100, 4)
|
236
|
-
row['swing'] = round((row['high'] - row['low']) / row['high'] * 100, 4)
|
237
|
-
table.append(row)
|
238
|
-
|
239
|
-
return table
|
reyworm/rtranslate.py
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
# !/usr/bin/env python
|
2
|
-
# -*- coding: utf-8 -*-
|
3
|
-
|
4
|
-
"""
|
5
|
-
@Time : 2022-12-08 17:08:41
|
6
|
-
@Author : Rey
|
7
|
-
@Contact : reyxbo@163.com
|
8
|
-
@Explain : Translate methods.
|
9
|
-
"""
|
10
|
-
|
11
|
-
|
12
|
-
from reykit.rcomm import request
|
13
|
-
|
14
|
-
|
15
|
-
__all__ = (
|
16
|
-
'translate_baidu',
|
17
|
-
'translate'
|
18
|
-
)
|
19
|
-
|
20
|
-
|
21
|
-
def translate_baidu(text: str) -> str:
|
22
|
-
"""
|
23
|
-
Use `fanyi.baidu.com` translated text.
|
24
|
-
|
25
|
-
Parameters
|
26
|
-
----------
|
27
|
-
text : Text to be translated.
|
28
|
-
|
29
|
-
Retuens
|
30
|
-
-------
|
31
|
-
Translated text.
|
32
|
-
"""
|
33
|
-
|
34
|
-
# Set parameter.
|
35
|
-
url = 'https://fanyi.baidu.com/sug'
|
36
|
-
data = {
|
37
|
-
'kw': text
|
38
|
-
}
|
39
|
-
|
40
|
-
# Requests.
|
41
|
-
response = request(url, data)
|
42
|
-
response_data = response.json()['data']
|
43
|
-
|
44
|
-
# Handle result.
|
45
|
-
if not len(response_data):
|
46
|
-
return
|
47
|
-
translate_data = response_data[0]['v']
|
48
|
-
translate_text = translate_data.split(';')[0].split('. ')[-1]
|
49
|
-
|
50
|
-
return translate_text
|
51
|
-
|
52
|
-
|
53
|
-
def translate(text: str) -> str:
|
54
|
-
"""
|
55
|
-
Translate text.
|
56
|
-
|
57
|
-
Parameters
|
58
|
-
----------
|
59
|
-
text : Text to be translated.
|
60
|
-
|
61
|
-
Retuens
|
62
|
-
-------
|
63
|
-
Translated text.
|
64
|
-
"""
|
65
|
-
|
66
|
-
# Set parameter.
|
67
|
-
translate_func = [
|
68
|
-
translate_baidu
|
69
|
-
]
|
70
|
-
|
71
|
-
# Translate.
|
72
|
-
for func in translate_func:
|
73
|
-
translate_text = func(text)
|
74
|
-
if translate_text is not None:
|
75
|
-
return translate_text
|
File without changes
|
File without changes
|