reykit 1.1.23__py3-none-any.whl → 1.1.25__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.
reykit/__init__.py CHANGED
@@ -10,23 +10,23 @@
10
10
  Modules
11
11
  -------
12
12
  rall : All methods.
13
- rcomm : Network communication methods.
14
13
  rdata : Data methods.
15
14
  rdll : DLL file methods.
16
15
  remail : E-mail methods.
17
- rexception : Exception methods.
16
+ rexc : Exception methods.
18
17
  rimage : Image methods.
19
18
  rlog : Log methods.
20
19
  rmonkey : Monkey patch methods.
21
- rmultitask : Multi task methods.
22
- rnumber : Number methods.
20
+ rnet : Network methods.
21
+ rnum : Number methods.
23
22
  ros: Operation system methods.
24
- rrandom : Random methods.
25
- rregex : Regular expression methods.
23
+ rrand : Random methods.
24
+ rre : Regular expression methods.
26
25
  rschedule : Schedule methods.
27
- rstdout : Standard output methods.
28
- rsystem : Interpreter system methods.
26
+ rstdout : Standard output and input methods.
27
+ rsys : Interpreter system methods.
29
28
  rtable : Table methods.
29
+ rtask : Multi task methods.
30
30
  rtext : Text methods.
31
31
  rtime : Time methods.
32
32
  rtype : Type methods.
reykit/rall.py CHANGED
@@ -9,23 +9,23 @@
9
9
  """
10
10
 
11
11
 
12
- from .rcomm import *
13
12
  from .rdata import *
14
13
  from .rdll import *
15
14
  from .remail import *
16
- from .rexception import *
15
+ from .rexc import *
17
16
  from .rimage import *
18
17
  from .rlog import *
19
18
  from .rmonkey import *
20
- from .rmultitask import *
21
- from .rnumber import *
19
+ from .rnet import *
20
+ from .rnum import *
22
21
  from .ros import *
23
- from .rrandom import *
24
- from .rregex import *
22
+ from .rrand import *
23
+ from .rre import *
25
24
  from .rschedule import *
26
25
  from .rstdout import *
27
- from .rsystem import *
26
+ from .rsys import *
28
27
  from .rtable import *
28
+ from .rtask import *
29
29
  from .rtext import *
30
30
  from .rtime import *
31
31
  from .rtype import *
reykit/rdata.py CHANGED
@@ -14,8 +14,8 @@ from collections import defaultdict as Defaultdict, ChainMap
14
14
  from collections.abc import Callable, Iterable, Generator
15
15
  from itertools import chain as IChain
16
16
 
17
- from .rexception import check_least_one, check_most_one
18
- from .rsystem import is_iterable
17
+ from .rexc import check_least_one, check_most_one
18
+ from .rsys import is_iterable
19
19
  from .rtype import T, KT, VT, RBase, Null
20
20
 
21
21
 
@@ -111,7 +111,7 @@ def flatten(data: Any, *, _flattern_data: list | None = None) -> list:
111
111
  # Flatten.
112
112
 
113
113
  ## Recursion dict object.
114
- if data.__class__ == dict:
114
+ if type(data) == dict:
115
115
  for element in data.values():
116
116
  _flattern_data = flatten(
117
117
  element,
@@ -119,7 +119,7 @@ def flatten(data: Any, *, _flattern_data: list | None = None) -> list:
119
119
  )
120
120
 
121
121
  ## Recursion iterator.
122
- elif is_iterable(data):
122
+ elif is_iterable(data, (str, bytes)):
123
123
  for element in data:
124
124
  _flattern_data = flatten(
125
125
  element,
reykit/rdll/__init__.py CHANGED
@@ -9,9 +9,37 @@
9
9
 
10
10
  Modules
11
11
  -------
12
- rdll_inject_core : DLL file inject method code.
13
- rdll_inject : DLL file inject method.
12
+ rdll_core : DLL file code methods.
14
13
  """
15
14
 
16
15
 
17
- from .rdll_inject import *
16
+ from ctypes import create_string_buffer
17
+
18
+ from .rdll_core import InjectDLL
19
+
20
+
21
+ __all__ = (
22
+ 'inject_dll',
23
+ )
24
+
25
+
26
+ def inject_dll(
27
+ id_: int,
28
+ path: str
29
+ ) -> None:
30
+ """
31
+ Inject DLL file.
32
+
33
+ Parameters
34
+ ----------
35
+ id_ : Process ID.
36
+ path : DLL file path.
37
+ """
38
+
39
+
40
+ # Get parameter.
41
+ path_bytes = path.encode()
42
+ buffer = create_string_buffer(path_bytes)
43
+
44
+ # Inject.
45
+ InjectDLL(id_, buffer)
@@ -5,7 +5,7 @@
5
5
  @Time : 2023-12-06 16:17:04
6
6
  @Author : Rey
7
7
  @Contact : reyxbo@163.com
8
- @Explain : DLL file inject method code.
8
+ @Explain : DLL file code methods.
9
9
  """
10
10
 
11
11
 
reykit/remail.py CHANGED
@@ -15,7 +15,7 @@ from email.mime.text import MIMEText
15
15
  from email.mime.application import MIMEApplication
16
16
 
17
17
  from .rdata import unique
18
- from .rexception import throw
18
+ from .rexc import throw
19
19
  from .ros import FileBytes, get_file_bytes
20
20
  from .rtype import RBase
21
21
 
@@ -123,9 +123,9 @@ class REmail(RBase):
123
123
  """
124
124
 
125
125
  # Handle parameter.
126
- if show_to.__class__ == list:
126
+ if type(show_to) == list:
127
127
  show_to = ','.join(show_to)
128
- if show_cc.__class__ == list:
128
+ if type(show_cc) == list:
129
129
  show_cc = ','.join(show_cc)
130
130
 
131
131
  # Instance.
@@ -212,7 +212,7 @@ class REmail(RBase):
212
212
  # Handle parameter.
213
213
 
214
214
  ## To.
215
- if to.__class__ == str:
215
+ if type(to) == str:
216
216
  to = to.split(',')
217
217
 
218
218
  ## Cc.
@@ -227,12 +227,12 @@ class REmail(RBase):
227
227
 
228
228
  ## Show to.
229
229
  show_to = show_to or to
230
- if show_to.__class__ == str:
230
+ if type(show_to) == str:
231
231
  show_to = show_to.split(',')
232
232
 
233
233
  ## Show cc.
234
234
  show_cc = show_cc or cc
235
- if show_cc.__class__ == str:
235
+ if type(show_cc) == str:
236
236
  show_cc = show_cc.split(',')
237
237
 
238
238
  ## Attachment.
@@ -9,17 +9,6 @@
9
9
  """
10
10
 
11
11
 
12
- # !/usr/bin/env python
13
- # -*- coding: utf-8 -*-
14
-
15
- """
16
- @Time : 2022-12-05 14:09:42
17
- @Author : Rey
18
- @Contact : reyxbo@163.com
19
- @Explain : Interpreter system methods.
20
- """
21
-
22
-
23
12
  from typing import Any, NoReturn, overload
24
13
  from types import TracebackType
25
14
  from collections.abc import Iterable
@@ -93,7 +82,7 @@ def throw(
93
82
  values = (value,) + values
94
83
 
95
84
  ### Name.
96
- from .rsystem import get_name
85
+ from .rsys import get_name
97
86
  name = get_name(value, frame)
98
87
  names = (name,)
99
88
  if values != ():
@@ -105,7 +94,7 @@ def throw(
105
94
  match exception:
106
95
  case TypeError():
107
96
  values = [
108
- value.__class__
97
+ type(value)
109
98
  for value in values
110
99
  if value is not None
111
100
  ]
@@ -115,7 +104,7 @@ def throw(
115
104
  if value % 1 == 0
116
105
  else round(value, 3)
117
106
  for value in values
118
- if value.__class__ == float
107
+ if type(value) == float
119
108
  ]
120
109
  values = [
121
110
  repr(value)
@@ -164,7 +153,7 @@ def warn(
164
153
  if infos == ():
165
154
  infos = 'Warning!'
166
155
  elif len(infos) == 1:
167
- if infos[0].__class__ == str:
156
+ if type(infos[0]) == str:
168
157
  infos = infos[0]
169
158
  else:
170
159
  infos = str(infos[0])
@@ -234,7 +223,7 @@ def check_least_one(*values: Any) -> None:
234
223
  return
235
224
 
236
225
  # Throw exception.
237
- from .rsystem import get_name
226
+ from .rsys import get_name
238
227
  vars_name = get_name(values)
239
228
  if vars_name is not None:
240
229
  vars_name_de_dup = list(set(vars_name))
@@ -261,7 +250,7 @@ def check_most_one(*values: Any) -> None:
261
250
  if exist is True:
262
251
 
263
252
  # Throw exception.
264
- from .rsystem import get_name
253
+ from .rsys import get_name
265
254
  vars_name = get_name(values)
266
255
  if vars_name is not None:
267
256
  vars_name_de_dup = list(set(vars_name))
reykit/rimage.py CHANGED
@@ -16,15 +16,9 @@ from qrcode.image.pil import PilImage
16
16
  from PIL.Image import open as pil_open, LANCZOS
17
17
  from captcha.image import ImageCaptcha
18
18
 
19
- from .rexception import catch_exc
20
19
  from .rmonkey import monkey_path_pil_image_get_bytes
21
20
  from .ros import RFile
22
- from .rrandom import randchar
23
-
24
- try:
25
- from pyzbar.pyzbar import decode as pyzbar_decode
26
- except:
27
- *_, pyzbar_decode, _ = catch_exc()
21
+ from .rrand import randchar
28
22
 
29
23
 
30
24
  __all__ = (
@@ -86,12 +80,15 @@ def decode_qrcode(image: str | bytes) -> list[str]:
86
80
  QR code or bar code text list.
87
81
  """
88
82
 
83
+ # Import.
84
+ from pyzbar.pyzbar import decode as pyzbar_decode
85
+
89
86
  # Check.
90
87
  if isinstance(pyzbar_decode, BaseException):
91
88
  raise pyzbar_decode
92
89
 
93
90
  # Handle parameter.
94
- if image.__class__ in (bytes, bytearray):
91
+ if type(image) in (bytes, bytearray):
95
92
  image = BytesIO(image)
96
93
 
97
94
  # Decode.
@@ -141,7 +138,7 @@ def compress_image(
141
138
  """
142
139
 
143
140
  # Handle parameter.
144
- if input_image.__class__ == str:
141
+ if type(input_image) == str:
145
142
  rfile = RFile(input_image)
146
143
  input_image = rfile.str
147
144
  now_size = len(input_image)
@@ -203,11 +200,11 @@ def to_pil_image(source: str | bytes) -> RImage:
203
200
  """
204
201
 
205
202
  # File path.
206
- if source.__class__ == str:
203
+ if type(source) == str:
207
204
  pil_image = pil_open(source)
208
205
 
209
206
  # Bytes data.
210
- if source.__class__ in (bytes, bytearray):
207
+ if type(source) in (bytes, bytearray):
211
208
  bytes_io = BytesIO(source)
212
209
  pil_image = pil_open(bytes_io)
213
210
 
@@ -239,7 +236,7 @@ def generate_captcha_image(
239
236
 
240
237
  # Get parameter.
241
238
  text = text or 5
242
- if text.__class__ == int:
239
+ if type(text) == int:
243
240
  text = randchar(text, False)
244
241
 
245
242
  # Generate.
reykit/rlog.py CHANGED
@@ -9,7 +9,6 @@
9
9
  """
10
10
 
11
11
 
12
- from __future__ import annotations
13
12
  from typing import Any, Literal, Final, overload
14
13
  from collections.abc import Callable
15
14
  from queue import Queue
@@ -30,11 +29,11 @@ from logging import (
30
29
  from logging.handlers import QueueHandler
31
30
  from concurrent_log_handler import ConcurrentRotatingFileHandler, ConcurrentTimedRotatingFileHandler
32
31
 
33
- from .rexception import throw, catch_exc
32
+ from .rexc import throw, catch_exc
34
33
  from .ros import RFile
35
- from .rregex import search, sub
34
+ from .rre import search, sub
36
35
  from .rstdout import RConfigStdout, modify_print, reset_print
37
- from .rsystem import get_first_notnull, get_stack_param
36
+ from .rsys import get_first_notnull, get_stack_param
38
37
  from .rtext import to_text
39
38
  from .rtime import now, time_to
40
39
  from .rtype import RBase, RConfigMeta
@@ -986,7 +985,7 @@ class RRecord(object):
986
985
  rfile = RFile(self.path)
987
986
 
988
987
  ## Convert.
989
- if value.__class__ != str:
988
+ if type(value) != str:
990
989
  value = str(value)
991
990
  if rfile:
992
991
  value += ':'
@@ -1022,7 +1021,7 @@ class RRecord(object):
1022
1021
  rfile = RFile(self.path)
1023
1022
 
1024
1023
  ## Convert.
1025
- if value.__class__ != str:
1024
+ if type(value) != str:
1026
1025
  value = str(value)
1027
1026
  value = ':%s:' % value
1028
1027
 
reykit/rmonkey.py CHANGED
@@ -45,10 +45,9 @@ def monkey_patch_sqlalchemy_result_more_fetch():
45
45
  >>> result.empty
46
46
  """
47
47
 
48
-
48
+ # Import.
49
49
  from sqlalchemy.engine.cursor import CursorResult
50
50
  from pandas import DataFrame, NA, concat
51
-
52
51
  from .rstdout import echo
53
52
  from .rtable import (
54
53
  to_table,
@@ -64,7 +63,6 @@ def monkey_patch_sqlalchemy_result_more_fetch():
64
63
  )
65
64
  from .rtime import time_to
66
65
 
67
-
68
66
  # Fetch result as table in 'list[dict]' format.
69
67
  CursorResult.fetch_table = to_table
70
68
 
@@ -114,7 +112,7 @@ def monkey_patch_sqlalchemy_result_more_fetch():
114
112
 
115
113
  # Convert.
116
114
  df: DataFrame = self.fetch_df()
117
- df = df.applymap(time_to, raising=False)
115
+ df = df.map(time_to, raising=False)
118
116
  df = df.astype(str)
119
117
  df.replace(['NaT', '<NA>'], 'None', inplace=True)
120
118
  row_len, column_len = df.shape
@@ -228,11 +226,10 @@ def monkey_patch_sqlalchemy_row_index_field():
228
226
  ... row['field']
229
227
  """
230
228
 
231
-
229
+ # Import.
232
230
  from typing import Any, overload
233
231
  from sqlalchemy.engine.row import Row
234
232
 
235
-
236
233
  # Define.
237
234
  @overload
238
235
  def __getitem__(self, index: str | int) -> Any: ...
@@ -254,7 +251,7 @@ def monkey_patch_sqlalchemy_row_index_field():
254
251
  """
255
252
 
256
253
  # Index.
257
- if index.__class__ == str:
254
+ if type(index) == str:
258
255
  value = self._mapping[index]
259
256
  else:
260
257
  value = self._data[index]
@@ -271,17 +268,15 @@ def monkey_patch_pprint_modify_width_judgment() -> None:
271
268
  Monkey patch of package `pprint`, modify the chinese width judgment.
272
269
  """
273
270
 
274
-
271
+ # Import.
275
272
  from pprint import PrettyPrinter, _recursion
276
273
 
277
274
 
278
- # New method.
275
+ # Define.
279
276
  def _format(_self, obj, stream, indent, allowance, context, level):
280
277
 
281
-
282
278
  from .rtext import get_width
283
279
 
284
-
285
280
  objid = id(obj)
286
281
  if objid in context:
287
282
  stream.write(_recursion(obj))
@@ -325,7 +320,6 @@ def monkey_path_pil_image_get_bytes():
325
320
  >>> image.get_bytes()
326
321
  """
327
322
 
328
-
329
323
  from PIL.Image import Image
330
324
  from io import BytesIO
331
325
 
@@ -5,7 +5,7 @@
5
5
  @Time : 2022-12-08 11:07:25
6
6
  @Author : Rey
7
7
  @Contact : reyxbo@163.com
8
- @Explain : Network communication methods.
8
+ @Explain : Network methods.
9
9
  """
10
10
 
11
11
 
@@ -30,9 +30,9 @@ from mimetypes import guess_type
30
30
  from filetype import guess as filetype_guess
31
31
  from datetime import datetime
32
32
 
33
- from .rexception import throw, check_response_code
33
+ from .rexc import throw, check_response_code
34
34
  from .ros import RFile
35
- from .rregex import search
35
+ from .rre import search
36
36
  from .rtype import RBase
37
37
 
38
38
 
@@ -44,7 +44,7 @@ __all__ = (
44
44
  'get_content_type',
45
45
  'request',
46
46
  'download',
47
- 'get_file_stream_time',
47
+ 'compute_stream_time',
48
48
  'listen_socket',
49
49
  'RRequestCache'
50
50
  )
@@ -190,16 +190,16 @@ def get_content_type(file: str | bytes) -> str | None:
190
190
  # Guess.
191
191
  if (
192
192
  (
193
- file.__class__ == str
193
+ type(file) == str
194
194
  and os_isfile(file)
195
- ) or file.__class__ == bytes
195
+ ) or type(file) == bytes
196
196
  ):
197
197
  file_type_obj = filetype_guess(file)
198
198
  else:
199
199
  file_type_obj = None
200
200
  if file_type_obj is not None:
201
201
  file_type = file_type_obj.MIME
202
- elif file.__class__ == str:
202
+ elif type(file) == str:
203
203
  file_type, _ = guess_type(file)
204
204
  else:
205
205
  file_type = None
@@ -275,26 +275,26 @@ def request(
275
275
  else:
276
276
  method = 'post'
277
277
  if files is None:
278
- if data.__class__ == str:
278
+ if type(data) == str:
279
279
  rfile = RFile(data)
280
280
  data = rfile.bytes
281
281
  if 'Content-Disposition' not in headers:
282
282
  file_name = rfile.name_suffix
283
283
  headers['Content-Disposition'] = f'attachment; filename={file_name}'
284
- if data.__class__ == bytes:
284
+ if type(data) == bytes:
285
285
  if 'Content-Type' not in headers:
286
286
  headers['Content-Type'] = get_content_type(data)
287
287
  else:
288
288
  for key, value in files.items():
289
- if value.__class__ == tuple:
289
+ if type(value) == tuple:
290
290
  item_data, item_headers = value
291
291
  else:
292
292
  item_data, item_headers = value, {}
293
- if item_data.__class__ == str:
293
+ if type(item_data) == str:
294
294
  rfile = RFile(item_data)
295
295
  data = rfile.bytes
296
296
  item_headers.setdefault('filename', rfile.name_suffix)
297
- if item_data.__class__ == bytes:
297
+ if type(item_data) == bytes:
298
298
  if 'Content-Type' not in item_headers:
299
299
  item_headers['Content-Type'] = get_content_type(item_data)
300
300
  files[key] = (
@@ -387,12 +387,12 @@ def download(url: str, path: str | None = None) -> str:
387
387
  return path
388
388
 
389
389
 
390
- def get_file_stream_time(
390
+ def compute_stream_time(
391
391
  file: str | bytes | int,
392
392
  bandwidth: float
393
393
  ) -> float:
394
394
  """
395
- Get file stream transfer time, unit second.
395
+ Compute file stream transfer time, unit second.
396
396
 
397
397
  Parameters
398
398
  ----------
@@ -11,7 +11,7 @@
11
11
 
12
12
  from typing import Any
13
13
 
14
- from .rexception import throw
14
+ from .rexc import throw
15
15
 
16
16
 
17
17
  __all__ = (
@@ -119,7 +119,7 @@ def number_ch(number: int) -> str:
119
119
  """
120
120
 
121
121
  # Import.
122
- from .rregex import sub_batch
122
+ from .rre import sub_batch
123
123
 
124
124
  # Set parameter.
125
125
  map_digit = {
reykit/ros.py CHANGED
@@ -51,9 +51,9 @@ from docx.oxml.table import CT_Tbl
51
51
  from lxml.etree import ElementChildIterator
52
52
  from pdfplumber import open as pdfplumber_open
53
53
 
54
- from .rexception import throw
55
- from .rregex import search, sub
56
- from .rsystem import dos_command
54
+ from .rexc import throw
55
+ from .rre import search, sub
56
+ from .rsys import dos_command
57
57
  from .rtext import to_json
58
58
  from .rtype import RBase
59
59
 
@@ -472,11 +472,11 @@ class RFile(RBase):
472
472
  mode = 'a'
473
473
  else:
474
474
  mode = 'w'
475
- if data.__class__ in (bytes, bytearray):
475
+ if type(data) in (bytes, bytearray):
476
476
  mode += 'b'
477
477
 
478
478
  ## Convert data to string.
479
- if data.__class__ not in (str, bytes, bytearray):
479
+ if type(data) not in (str, bytes, bytearray):
480
480
  try:
481
481
  data = to_json(data)
482
482
  except (JSONDecodeError, TypeError):
@@ -1857,10 +1857,9 @@ def doc_to_docx(
1857
1857
  DOCX file path.
1858
1858
  """
1859
1859
 
1860
-
1860
+ # Import.
1861
1861
  from win32com.client import Dispatch, CDispatch
1862
1862
 
1863
-
1864
1863
  # Handle parameter.
1865
1864
  if save_path is None:
1866
1865
  pattern = '.[dD][oO][cC]'
@@ -19,8 +19,8 @@ from random import Random
19
19
  from secrets import randbelow as secrets_randbelow
20
20
  from threading import get_ident as threading_get_ident
21
21
 
22
- from .rexception import throw
23
- from .rnumber import digits
22
+ from .rexc import throw
23
+ from .rnum import digits
24
24
  from .rtype import T, RBase, RConfigMeta
25
25
 
26
26
 
@@ -253,7 +253,7 @@ def sub_batch(text: str, *patterns: str | tuple[str, str | Callable[[RMatch], st
253
253
 
254
254
  # Replace.
255
255
  for pattern in patterns:
256
- if pattern.__class__ == str:
256
+ if type(pattern) == str:
257
257
  replace = None
258
258
  else:
259
259
  pattern, replace = pattern
reykit/rschedule.py CHANGED
@@ -219,7 +219,7 @@ class RSchedule(RBase):
219
219
  """
220
220
 
221
221
  # Get parameter.
222
- if task.__class__ == Job:
222
+ if type(task) == Job:
223
223
  id_ = task.id
224
224
  else:
225
225
  id_ = task
@@ -241,7 +241,7 @@ class RSchedule(RBase):
241
241
  """
242
242
 
243
243
  # Get parameter.
244
- if task.__class__ == Job:
244
+ if type(task) == Job:
245
245
  id_ = task.id
246
246
  else:
247
247
  id_ = task
@@ -263,7 +263,7 @@ class RSchedule(RBase):
263
263
  """
264
264
 
265
265
  # Get parameter.
266
- if task.__class__ == Job:
266
+ if type(task) == Job:
267
267
  id_ = task.id
268
268
  else:
269
269
  id_ = task
reykit/rstdout.py CHANGED
@@ -5,18 +5,18 @@
5
5
  @Time : 2023-10-01 14:47:47
6
6
  @Author : Rey
7
7
  @Contact : reyxbo@163.com
8
- @Explain : Standard output methods.
8
+ @Explain : Standard output and input methods.
9
9
  """
10
10
 
11
11
 
12
- from typing import Any, Literal, Final, Self
12
+ from typing import Any, Literal, Final
13
13
  from collections.abc import Callable
14
14
  import sys
15
15
  from io import TextIOWrapper
16
16
  from os import devnull as os_devnull
17
17
  from os.path import abspath as os_abspath
18
18
 
19
- from .rsystem import get_first_notnull, get_name, get_stack_param
19
+ from .rsys import get_first_notnull, get_name, get_stack_param
20
20
  from .rtext import to_text, add_text_frame
21
21
  from .rtype import RBase, RConfigMeta
22
22
 
@@ -108,7 +108,7 @@ def beautify_text(
108
108
  titles = [title if not title.startswith('`') else '' for title in titles]
109
109
  if set(titles) != {''}:
110
110
  title = ' │ '.join(titles)
111
- if title.__class__ != str:
111
+ if type(title) != str:
112
112
  title = None
113
113
 
114
114
  ## Width.
@@ -287,7 +287,7 @@ def modify_print(preprocess: Callable[[str], str] | None) -> None:
287
287
  __s = preprocess(__s)
288
288
 
289
289
  # Write.
290
- if __s.__class__ == str:
290
+ if type(__s) == str:
291
291
  write_len = RConfigStdout._io_stdout_write(__s)
292
292
  return write_len
293
293
 
@@ -56,7 +56,7 @@ from tkinter.filedialog import (
56
56
  askdirectory as tkinter_askdirectory
57
57
  )
58
58
 
59
- from .rexception import throw
59
+ from .rexc import throw
60
60
  from .rtype import RBase, RConfigMeta
61
61
 
62
62
 
@@ -184,7 +184,7 @@ def del_modules(path: str) -> list[str]:
184
184
  """
185
185
 
186
186
  # Import.
187
- from .rregex import search
187
+ from .rre import search
188
188
 
189
189
  # Set parameter.
190
190
  deleted_dict = {}
@@ -284,8 +284,8 @@ def dos_command_var(*vars: Any) -> list[Any]:
284
284
  var_type = str
285
285
  var_help = None
286
286
  else:
287
- var_type = value.__class__
288
- var_help = str(value.__class__)
287
+ var_type = type(value)
288
+ var_help = str(type(value))
289
289
 
290
290
  ## Position argument.
291
291
  parser.add_argument(
@@ -320,7 +320,7 @@ def dos_command_var(*vars: Any) -> list[Any]:
320
320
 
321
321
  ## Keyword argument.
322
322
  dos_value = getattr(namespace, kw_name)
323
- if dos_value.__class__ == list:
323
+ if type(dos_value) == list:
324
324
  value_len = len(dos_value)
325
325
  match value_len:
326
326
  case 0:
@@ -382,11 +382,11 @@ def at_exit(*contents: str | Callable | tuple[Callable, Iterable, Mapping]) -> l
382
382
  for content in reversed(contents):
383
383
  args = ()
384
384
  kwargs = {}
385
- if content.__class__ == str:
385
+ if type(content) == str:
386
386
  func = lambda : print(content)
387
387
  elif callable(content):
388
388
  func = content
389
- elif content.__class__ == tuple:
389
+ elif type(content) == tuple:
390
390
  func, args, kwargs = content
391
391
  funcs.append(func)
392
392
  atexit_register(func, *args, **kwargs)
@@ -435,7 +435,7 @@ def is_instance(obj: Any) -> bool:
435
435
 
436
436
  def is_iterable(
437
437
  obj: Any,
438
- exclude_types: Iterable[type] = [str, bytes]
438
+ exclude_types: Iterable[type] | None = None
439
439
  ) -> bool:
440
440
  """
441
441
  Judge whether it is iterable.
@@ -450,15 +450,17 @@ def is_iterable(
450
450
  Judgment result.
451
451
  """
452
452
 
453
- # Exclude types.
454
- if obj.__class__ in exclude_types:
455
- return False
456
-
457
453
  # Judge.
458
- if hasattr(obj, '__iter__'):
454
+ if (
455
+ hasattr(obj, '__iter__')
456
+ and not (
457
+ exclude_types is not None
458
+ and type(obj) in exclude_types
459
+ )
460
+ ):
459
461
  return True
460
- else:
461
- return False
462
+
463
+ return False
462
464
 
463
465
 
464
466
  def is_table(
@@ -479,10 +481,10 @@ def is_table(
479
481
  """
480
482
 
481
483
  # Judge.
482
- if obj.__class__ != list:
484
+ if type(obj) != list:
483
485
  return False
484
486
  for element in obj:
485
- if element.__class__ != dict:
487
+ if type(element) != dict:
486
488
  return False
487
489
 
488
490
  ## Check fields of table.
@@ -591,15 +593,15 @@ def get_name(obj: Any, frame: int = 2) -> str | tuple[str, ...] | None:
591
593
  # Get name using module method.
592
594
  name = 'obj'
593
595
  for frame_ in range(1, frame + 1):
594
- if name.__class__ != str:
596
+ if type(name) != str:
595
597
  return
596
598
  try:
597
599
  name = argname(name, frame=frame_)
598
600
  except VarnameRetrievingError:
599
601
  return
600
- if name.__class__ == tuple:
602
+ if type(name) == tuple:
601
603
  for element in name:
602
- if element.__class__ != str:
604
+ if type(element) != str:
603
605
  return
604
606
 
605
607
  return name
reykit/rtable.py CHANGED
@@ -77,7 +77,7 @@ def to_table(
77
77
  fields,
78
78
  [
79
79
  None
80
- if (value.__class__ != list and isnull(value))
80
+ if (type(value) != list and isnull(value))
81
81
  else value
82
82
  for value in row
83
83
  ]
@@ -140,9 +140,9 @@ def to_dict(
140
140
 
141
141
  # Get fields.
142
142
  fields = list(data[0].keys())
143
- if key_field.__class__ == int:
143
+ if type(key_field) == int:
144
144
  key_field = fields[key_field]
145
- if val_field.__class__ == int:
145
+ if type(val_field) == int:
146
146
  val_field = fields[val_field]
147
147
 
148
148
  # Convert.
@@ -196,7 +196,7 @@ def to_list(
196
196
 
197
197
  # Get fields.
198
198
  fields = list(data[0].keys())
199
- if field.__class__ == int:
199
+ if type(field) == int:
200
200
  field = fields[field]
201
201
 
202
202
  # Convert.
@@ -244,7 +244,7 @@ def to_df(
244
244
 
245
245
  ## From other object.
246
246
  case _:
247
- if data.__class__ == dict:
247
+ if type(data) == dict:
248
248
  data = [data]
249
249
  data_df = DataFrame(data, columns=fields)
250
250
  data_df = data_df.convert_dtypes()
@@ -468,7 +468,7 @@ def to_excel(
468
468
  """
469
469
 
470
470
  # Handle parameter.
471
- if data.__class__ != DataFrame:
471
+ if type(data) != DataFrame:
472
472
  data = to_df(data)
473
473
  path = os_abspath(path)
474
474
 
@@ -9,7 +9,6 @@
9
9
  """
10
10
 
11
11
 
12
- from __future__ import annotations
13
12
  from typing import Any, Literal, overload
14
13
  from collections.abc import Callable, Iterable, Generator, Coroutine
15
14
  from threading import RLock as TRLock, get_ident as threading_get_ident
@@ -31,7 +30,7 @@ from asyncio import (
31
30
  )
32
31
  from aiohttp import ClientSession, ClientResponse
33
32
 
34
- from .rexception import throw, check_most_one, check_response_code
33
+ from .rexc import throw, check_most_one, check_response_code
35
34
  from .rtime import randn, RTimeMark
36
35
  from .rtype import T, RBase
37
36
  from .rwrap import wrap_thread
reykit/rtext.py CHANGED
@@ -15,9 +15,9 @@ from decimal import Decimal
15
15
  from pprint import pformat as pprint_pformat
16
16
  from json import dumps as json_dumps
17
17
 
18
- from .rexception import throw
18
+ from .rexc import throw
19
19
  from .rmonkey import monkey_patch_pprint_modify_width_judgment
20
- from .rrandom import randi
20
+ from .rrand import randi
21
21
 
22
22
 
23
23
  __all__ = (
@@ -221,7 +221,7 @@ def join_data_text(data: Iterable) -> str:
221
221
  # Join.
222
222
 
223
223
  ## dict type.
224
- if data.__class__ == dict:
224
+ if type(data) == dict:
225
225
  texts = []
226
226
  for key, value in data.items():
227
227
  key_str = str(key)
@@ -409,7 +409,7 @@ def to_json(
409
409
  # Convert.
410
410
  default = lambda value: (
411
411
  value.__float__()
412
- if value.__class__ == Decimal
412
+ if type(value) == Decimal
413
413
  else repr(value)
414
414
  )
415
415
  string = json_dumps(
reykit/rtime.py CHANGED
@@ -29,10 +29,10 @@ from pandas import (
29
29
  Timedelta as PTimedelta
30
30
  )
31
31
 
32
- from .rexception import throw
33
- from .rnumber import digits, to_number
34
- from .rrandom import randn
35
- from .rregex import search
32
+ from .rexc import throw
33
+ from .rnum import digits, to_number
34
+ from .rrand import randn
35
+ from .rre import search
36
36
  from .rstdout import echo
37
37
  from .rtype import T
38
38
 
reykit/rwrap.py CHANGED
@@ -18,9 +18,9 @@ from threading import Thread
18
18
  from argparse import ArgumentParser
19
19
  from contextlib import redirect_stdout
20
20
 
21
- from .rexception import catch_exc
21
+ from .rexc import catch_exc
22
22
  from .rstdout import echo
23
- from .rsystem import get_arg_info
23
+ from .rsys import get_arg_info
24
24
  from .rtime import now, time_to, RTimeMark
25
25
 
26
26
 
@@ -479,7 +479,7 @@ def wrap_dos_command(
479
479
  ## Position argument.
480
480
  value = getattr(namespace, info['name'])
481
481
  if value is not None:
482
- if value.__class__ == list:
482
+ if type(value) == list:
483
483
  command_args.extend(value)
484
484
  else:
485
485
  command_args.append(value)
@@ -488,7 +488,7 @@ def wrap_dos_command(
488
488
  if info['type'] not in ('var_position', 'var_position'):
489
489
  kw_name = '--' + info['name']
490
490
  kw_value = getattr(namespace, kw_name)
491
- if kw_value.__class__ == list:
491
+ if type(kw_value) == list:
492
492
  kw_value_len = len(kw_value)
493
493
  match kw_value_len:
494
494
  case 0:
@@ -622,7 +622,7 @@ def wrap_redirect_stdout(
622
622
  result = func(*args, **kwargs)
623
623
 
624
624
  # Save.
625
- if _redirect.__class__ == list:
625
+ if type(_redirect) == list:
626
626
  value = str_io.getvalue()
627
627
  _redirect.append(value)
628
628
 
reykit/rzip.py CHANGED
@@ -9,7 +9,6 @@
9
9
  """
10
10
 
11
11
 
12
- from __future__ import annotations
13
12
  from zipfile import ZipFile, is_zipfile, ZIP_DEFLATED
14
13
  from os import getcwd as os_getcwd, walk as os_walk
15
14
  from os.path import join as os_join, isfile as os_isfile
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: reykit
3
- Version: 1.1.23
3
+ Version: 1.1.25
4
4
  Summary: Rey's kit method set.
5
5
  Project-URL: homepage, https://github.com/reyxbo/reykit/
6
6
  Author-email: Rey <reyxbo@163.com>
@@ -0,0 +1,29 @@
1
+ reykit/__init__.py,sha256=LdwdCXLzzPyteyYerrwfJH0LGj5jp_j-tamv2JEghTg,821
2
+ reykit/rall.py,sha256=AEHa1iUCopuM5sPzO0vmSLWTmKeSjilUtzQ8f-jULHk,649
3
+ reykit/rdata.py,sha256=a7aauSEjLiqDr-Adg3Aipri0gJrW-Mn-9hMQxRqKq9M,10006
4
+ reykit/remail.py,sha256=PBY2lCCkJr8BZbeD944sXjOompW1F1-ihbOXNJX-Lak,6744
5
+ reykit/rexc.py,sha256=yy4VGc7r0GC3ZBp6KMT99hpZ4-AbV1D-wgKuU0Blih4,8136
6
+ reykit/rimage.py,sha256=fSPNxwfdN9_dMbbPn-LagNSIo_Z-ISLcXaOZgisUc24,6190
7
+ reykit/rlog.py,sha256=7fGg9XldIntUFrcYVZWC2ChlJlnmbaaU1rB7yZw-IDM,25704
8
+ reykit/rmonkey.py,sha256=pDXhfX0kyHWptM3OPLL6x3_hQqFd-n6H3TaQafgdXcs,8246
9
+ reykit/rnet.py,sha256=Je-43L5-ELpy-mWe02jyj9bfcllVifM9KusBP4tkjME,15085
10
+ reykit/rnum.py,sha256=9J6unM11dDTg9A8XigHzfut8VFHWaNRKu59vGQ-ISXo,3637
11
+ reykit/ros.py,sha256=ORdUP72dPYWlRyOfcNw5FibxXMPk_Kv9im8h30MoGXc,40731
12
+ reykit/rrand.py,sha256=5vjQ4wsHUZ84dUs1Arp54QG8ghZYlkusEXgpht19iVw,9237
13
+ reykit/rre.py,sha256=0yYRiHhGg2OmuEVNf3zT92AcqQTdrvIJUltiFpjlYdM,6085
14
+ reykit/rschedule.py,sha256=tWqsEiXgNo5zcJtf4-MR5ZMs0fbn3ymU4M8_X1sELEc,5822
15
+ reykit/rstdout.py,sha256=zyGDk07X9WMTx06MBrg0Ki2tb_QsYLsd0ypU1fa1MVw,9920
16
+ reykit/rsys.py,sha256=qtmmw_GDIx0KbLHAADLDjXuSd_tYCyFoG7evW0K6564,36402
17
+ reykit/rtable.py,sha256=M0OOoxFlMJH91lhSGauzwEP7JA0q5-Odwzpff_X-b5g,12031
18
+ reykit/rtask.py,sha256=gwerLHFnrju695JukYpwCITq0SrblVaSktSLYYpkcLs,23114
19
+ reykit/rtext.py,sha256=KtK9d1y4NCsfydZTxrq5lnnyWvJfPi79ywy2qnauNew,11073
20
+ reykit/rtime.py,sha256=YXUN-EQYsgDbZk636gyeXa9NifU2hYoUNvbkX6jmsN4,17096
21
+ reykit/rtype.py,sha256=O7iI_sJ1Bfl_ZiP29IHqEE3v3PfJRpeA5M6ukEdZSMk,2317
22
+ reykit/rwrap.py,sha256=r5FBxbgiRMRLdaK6L7Uls5c6E_yfzM9xvWRY2O85KbA,15339
23
+ reykit/rzip.py,sha256=OEpRB2meW5copstZjeuKmarLD_co8I05WHBaKcLg0O8,3486
24
+ reykit/rdll/__init__.py,sha256=tdKb-BOKLFn-diCvXjSLg9x71VuRKzkg2KtpOLGLTR4,679
25
+ reykit/rdll/rdll_core.py,sha256=o6-rKcTQgxZQe0kD3GnwyNb3KL9IogzgCQNOmYLMm7A,5086
26
+ reykit-1.1.25.dist-info/METADATA,sha256=PJdqvyQoLCx553RFzQLB1KHEvr-yIn9lHEePxUoBagE,1919
27
+ reykit-1.1.25.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
28
+ reykit-1.1.25.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
29
+ reykit-1.1.25.dist-info/RECORD,,
@@ -1,41 +0,0 @@
1
- # !/usr/bin/env python
2
- # -*- coding: utf-8 -*-
3
-
4
- """
5
- @Time : 2023-12-06 16:09:59
6
- @Author : Rey
7
- @Contact : reyxbo@163.com
8
- @Explain : Inject DLL file methods.
9
- """
10
-
11
-
12
- __all__ = (
13
- 'inject_dll',
14
- )
15
-
16
-
17
- def inject_dll(
18
- id_: int,
19
- path: str
20
- ) -> None:
21
- """
22
- Inject DLL file.
23
-
24
- Parameters
25
- ----------
26
- id_ : Process ID.
27
- path : DLL file path.
28
- """
29
-
30
-
31
- from ctypes import create_string_buffer
32
-
33
- from .rdll_inject_core import InjectDLL
34
-
35
-
36
- # Get parameter.
37
- path_bytes = path.encode()
38
- buffer = create_string_buffer(path_bytes)
39
-
40
- # Inject.
41
- InjectDLL(id_, buffer)
@@ -1,30 +0,0 @@
1
- reykit/__init__.py,sha256=QwnhdUDSXgjXJQ4ClaeP9oKXUXyQOPj5sApwGCDrILc,848
2
- reykit/rall.py,sha256=mOFwHXZ4-BOkJ5Ptbm6lQc2zwNf_VqcqM6AYYnYPfoo,672
3
- reykit/rcomm.py,sha256=nFe9YKVB8BeR9PWOdjZfRX6KTSN6rp90OmS_YoUXcwM,15138
4
- reykit/rdata.py,sha256=Kn_YoH3Rv6yBUmnIRmyZzjwChRvUIgeyKF8hGRo2pas,10005
5
- reykit/remail.py,sha256=K8ueN0oP9iBJuFHYbFwyTn4AKoQm2Sf1lvmLpQYXoBQ,6770
6
- reykit/rexception.py,sha256=X56Ma9PtywVYAc38PmmMTlIxORYFy8Sz9e2bmm3j32M,8337
7
- reykit/rimage.py,sha256=VXlQFCZBjx1Mu18Au0Qmth9-u8dlIz0h8u_X100ImxA,6287
8
- reykit/rlog.py,sha256=rIl3UBf6Zgs4JCQXYErDhaZsAe5O6nYEFaztIw3RhRE,25760
9
- reykit/rmonkey.py,sha256=OAlLVvMszMDzersroVC9NjbD2GPnoPgWF4AHZ3v3-fk,8232
10
- reykit/rmultitask.py,sha256=IMQGP_sDquptigjdEpzf2P-wfXSESsF2yjbEEo_2NN4,23156
11
- reykit/rnumber.py,sha256=6x4FuRB-MTJheo6wbTUEaBarnew15jomlrneo3_Q2wg,3646
12
- reykit/ros.py,sha256=udTroOHAQ0cNu7Ksepyj3iPCSj8lE42RMq02qqTzbbg,40740
13
- reykit/rrandom.py,sha256=4lTBL3IMhcurFeMOXaML_W7Q4xU4_HOW-si-13IrV3A,9246
14
- reykit/rregex.py,sha256=XTlnDLior8yyncFdrTr9FsVlBcqMXvsWRfpmvQS-BR8,6089
15
- reykit/rschedule.py,sha256=XkQ6xNxcJQjomNvbfTTMyo0KIbk0y3Dp0xq_HOCScJQ,5834
16
- reykit/rstdout.py,sha256=E6wyze9fGcR1wEatD5gIcsPF_qsJ1SG5VkKWKSns944,9927
17
- reykit/rsystem.py,sha256=bVcK-b5jqOi9zXPnjCu98xGmjPENFg5e4k7w44fPLdU,36420
18
- reykit/rtable.py,sha256=gXszf_9DE_5SMdNcxMX-xd4IpHGQVjGsN3NQIm7wVGY,12055
19
- reykit/rtext.py,sha256=whaKpVkd36yYVtCmZ1ptp_TVRL1v3f7Jab0vPXC8wXY,11089
20
- reykit/rtime.py,sha256=1FC7JU-9t9dORUBUEzeVEvS73h7LDL9W8qTm9PZDscU,17110
21
- reykit/rtype.py,sha256=O7iI_sJ1Bfl_ZiP29IHqEE3v3PfJRpeA5M6ukEdZSMk,2317
22
- reykit/rwrap.py,sha256=N4rBDNW_PRGWbHqPB2cOWQFNAHpIBN-6MtmOEtupu4c,15360
23
- reykit/rzip.py,sha256=i6KkmeSWCnq025d-O1mbuCYezNRUhyY9OGVK0CRlNAM,3522
24
- reykit/rdll/__init__.py,sha256=vM9V7wSNno-WH9RrxgHTIgCkQm8LmBFoLFO8z7qovNo,306
25
- reykit/rdll/rdll_inject.py,sha256=bETl8tywtN1OiQudbA21u6GwBM_bqVX7jbiisNj_JBg,645
26
- reykit/rdll/rdll_inject_core.py,sha256=Trgh_pdJs_Lw-Y-0Kkn8kHr4BnilM9dBKnHnX25T_pM,5092
27
- reykit-1.1.23.dist-info/METADATA,sha256=J5FWicMIrPgVwqiUCtYxOCECUCtEf5TpxgJP8T89N2M,1919
28
- reykit-1.1.23.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
29
- reykit-1.1.23.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
30
- reykit-1.1.23.dist-info/RECORD,,