reykit 1.1.84__py3-none-any.whl → 1.1.86__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/rbase.py +4 -8
- reykit/rdata.py +62 -9
- reykit/rlog.py +4 -4
- reykit/rmonkey.py +4 -4
- reykit/rschedule.py +1 -1
- {reykit-1.1.84.dist-info → reykit-1.1.86.dist-info}/METADATA +1 -1
- {reykit-1.1.84.dist-info → reykit-1.1.86.dist-info}/RECORD +9 -9
- {reykit-1.1.84.dist-info → reykit-1.1.86.dist-info}/WHEEL +0 -0
- {reykit-1.1.84.dist-info → reykit-1.1.86.dist-info}/licenses/LICENSE +0 -0
reykit/rbase.py
CHANGED
@@ -35,7 +35,6 @@ __all__ = (
|
|
35
35
|
'ConfigMeta',
|
36
36
|
'Singleton',
|
37
37
|
'Null',
|
38
|
-
'null',
|
39
38
|
'ErrorBase',
|
40
39
|
'Exit',
|
41
40
|
'Error',
|
@@ -205,15 +204,12 @@ class Singleton(Base):
|
|
205
204
|
return self._instance
|
206
205
|
|
207
206
|
|
208
|
-
class Null(
|
207
|
+
class Null(Base, metaclass=StaticMeta):
|
209
208
|
"""
|
210
209
|
Null type.
|
211
210
|
"""
|
212
211
|
|
213
212
|
|
214
|
-
null = Null()
|
215
|
-
|
216
|
-
|
217
213
|
class ErrorBase(Base, BaseException):
|
218
214
|
"""
|
219
215
|
Base error type.
|
@@ -591,7 +587,7 @@ def get_first_notnone(*values: None) -> NoReturn: ...
|
|
591
587
|
@overload
|
592
588
|
def get_first_notnone(*values: T) -> T: ...
|
593
589
|
|
594
|
-
def get_first_notnone(*values: T, default: U =
|
590
|
+
def get_first_notnone(*values: T, default: U | Null = Null) -> T | U:
|
595
591
|
"""
|
596
592
|
Get the first value that is not `None`.
|
597
593
|
|
@@ -600,7 +596,7 @@ def get_first_notnone(*values: T, default: U = null) -> T | U:
|
|
600
596
|
values : Check values.
|
601
597
|
default : When all are `None`, then return this is value, or throw exception.
|
602
598
|
- `Any`: Return this is value.
|
603
|
-
- `
|
599
|
+
- `Null`: Throw exception.
|
604
600
|
|
605
601
|
Returns
|
606
602
|
-------
|
@@ -613,7 +609,7 @@ def get_first_notnone(*values: T, default: U = null) -> T | U:
|
|
613
609
|
return value
|
614
610
|
|
615
611
|
# Throw exception.
|
616
|
-
if default ==
|
612
|
+
if default == Null:
|
617
613
|
vars_name: list[str] = get_varname('values')
|
618
614
|
if vars_name is not None:
|
619
615
|
vars_name_de_dup = list(set(vars_name))
|
reykit/rdata.py
CHANGED
@@ -11,12 +11,12 @@
|
|
11
11
|
|
12
12
|
from typing import Any, TypedDict, Literal, overload
|
13
13
|
from collections import Counter, defaultdict as Defaultdict, ChainMap
|
14
|
-
from collections.abc import Callable, Iterable, Generator
|
14
|
+
from collections.abc import Callable, Iterable, Generator, AsyncGenerator
|
15
15
|
from itertools import chain as IChain
|
16
16
|
from decimal import Decimal
|
17
17
|
from json import dumps as json_dumps
|
18
18
|
|
19
|
-
from .rbase import T, KT, VT, Base,
|
19
|
+
from .rbase import T, KT, VT, Base, Null, check_least_one, check_most_one, is_iterable
|
20
20
|
|
21
21
|
|
22
22
|
__all__ = (
|
@@ -337,14 +337,14 @@ def chain(*iterables: dict[KT, VT] | Iterable[T]) -> ChainMap[KT, VT] | IChain[T
|
|
337
337
|
return data
|
338
338
|
|
339
339
|
|
340
|
-
def default_dict(default: T =
|
340
|
+
def default_dict(default: T | Null = Null, data: dict[KT, VT] | None = None) -> Defaultdict[KT, VT | T]:
|
341
341
|
"""
|
342
342
|
Set `dict` instance, default value when key does not exist.
|
343
343
|
|
344
344
|
Parameters
|
345
345
|
----------
|
346
346
|
default : Default value.
|
347
|
-
- `
|
347
|
+
- `Null`: Nest function self.
|
348
348
|
- `Callable`: Use call return value.
|
349
349
|
data : `dict` instance.
|
350
350
|
- `None`: Empty `dict`.
|
@@ -353,7 +353,7 @@ def default_dict(default: T = null, data: dict[KT, VT] | None = None) -> Default
|
|
353
353
|
# Handle parameter.
|
354
354
|
|
355
355
|
## Null.
|
356
|
-
if default ==
|
356
|
+
if default == Null:
|
357
357
|
default_factory = default_dict
|
358
358
|
|
359
359
|
## Callable.
|
@@ -408,10 +408,9 @@ class FunctionGenerator(Base):
|
|
408
408
|
self.args = args
|
409
409
|
self.kwargs = kwargs
|
410
410
|
self.params: list[tuple[tuple, dict]] = []
|
411
|
-
self.generator = self.__generator()
|
412
411
|
|
413
412
|
|
414
|
-
def
|
413
|
+
def generator(self) -> Generator[Any, Any, None]:
|
415
414
|
"""
|
416
415
|
Create generator.
|
417
416
|
|
@@ -435,6 +434,30 @@ class FunctionGenerator(Base):
|
|
435
434
|
yield result
|
436
435
|
|
437
436
|
|
437
|
+
async def agenerator(self) -> AsyncGenerator[Any, Any]:
|
438
|
+
"""
|
439
|
+
Asynchronous create generator.
|
440
|
+
|
441
|
+
Parameters
|
442
|
+
----------
|
443
|
+
Generator.
|
444
|
+
"""
|
445
|
+
|
446
|
+
# Loop.
|
447
|
+
while True:
|
448
|
+
|
449
|
+
# Break.
|
450
|
+
if self.params == []:
|
451
|
+
break
|
452
|
+
|
453
|
+
# Generate.
|
454
|
+
args, kwargs = self.params.pop(0)
|
455
|
+
result = self.func(*args, **kwargs)
|
456
|
+
|
457
|
+
# Return.
|
458
|
+
yield result
|
459
|
+
|
460
|
+
|
438
461
|
def add(
|
439
462
|
self,
|
440
463
|
*args: Any,
|
@@ -480,7 +503,8 @@ class FunctionGenerator(Base):
|
|
480
503
|
"""
|
481
504
|
|
482
505
|
# Generate.
|
483
|
-
|
506
|
+
generator = self.generator()
|
507
|
+
result = next(generator)
|
484
508
|
|
485
509
|
return result
|
486
510
|
|
@@ -491,4 +515,33 @@ class FunctionGenerator(Base):
|
|
491
515
|
"""
|
492
516
|
|
493
517
|
# Iterating.
|
494
|
-
|
518
|
+
generator = self.generator()
|
519
|
+
|
520
|
+
return generator
|
521
|
+
|
522
|
+
|
523
|
+
async def __anext__(self) -> Any:
|
524
|
+
"""
|
525
|
+
Asynchronous generate once from generator.
|
526
|
+
|
527
|
+
Returns
|
528
|
+
-------
|
529
|
+
Generate value.
|
530
|
+
"""
|
531
|
+
|
532
|
+
# Generate.
|
533
|
+
agenerator = await self.agenerator()
|
534
|
+
result = anext(agenerator)
|
535
|
+
|
536
|
+
return result
|
537
|
+
|
538
|
+
|
539
|
+
async def __aiter__(self) -> AsyncGenerator[Any, Any]:
|
540
|
+
"""
|
541
|
+
Asynchronous iterating generator.
|
542
|
+
"""
|
543
|
+
|
544
|
+
# Iterating.
|
545
|
+
agenerator = await self.agenerator()
|
546
|
+
|
547
|
+
return agenerator
|
reykit/rlog.py
CHANGED
@@ -29,7 +29,7 @@ from logging import (
|
|
29
29
|
from logging.handlers import QueueHandler
|
30
30
|
from concurrent_log_handler import ConcurrentRotatingFileHandler, ConcurrentTimedRotatingFileHandler
|
31
31
|
|
32
|
-
from .rbase import Base, ConfigMeta,
|
32
|
+
from .rbase import Base, ConfigMeta, Null, throw, catch_exc, get_first_notnone, get_stack_param
|
33
33
|
from .rre import search, sub
|
34
34
|
from .rstdout import ConfigStdout, modify_print, reset_print
|
35
35
|
from .rtext import to_text
|
@@ -954,7 +954,7 @@ class Mark(Base):
|
|
954
954
|
self.data: dict[Hashable, set[int]] = {}
|
955
955
|
|
956
956
|
|
957
|
-
def mark(self, obj: Any, group: Hashable =
|
957
|
+
def mark(self, obj: Any, group: Hashable | Null = Null) -> int:
|
958
958
|
"""
|
959
959
|
Mark object.
|
960
960
|
|
@@ -978,7 +978,7 @@ class Mark(Base):
|
|
978
978
|
return obj_id
|
979
979
|
|
980
980
|
|
981
|
-
def remove(self, obj: Any, group: Hashable =
|
981
|
+
def remove(self, obj: Any, group: Hashable | Null = Null) -> None:
|
982
982
|
"""
|
983
983
|
Whether marked.
|
984
984
|
|
@@ -1017,7 +1017,7 @@ class Mark(Base):
|
|
1017
1017
|
del self.data[group]
|
1018
1018
|
|
1019
1019
|
|
1020
|
-
def is_marked(self, obj: Any, group: Hashable =
|
1020
|
+
def is_marked(self, obj: Any, group: Hashable | Null = Null) -> bool:
|
1021
1021
|
"""
|
1022
1022
|
Whether marked.
|
1023
1023
|
|
reykit/rmonkey.py
CHANGED
@@ -54,7 +54,7 @@ def monkey_sqlalchemy_result_more_fetch():
|
|
54
54
|
|
55
55
|
# Add.
|
56
56
|
@property
|
57
|
-
def method_data(self: Result) -> Self:
|
57
|
+
def method_data(self: 'Result') -> Self:
|
58
58
|
"""
|
59
59
|
Get Data.
|
60
60
|
|
@@ -79,7 +79,7 @@ def monkey_sqlalchemy_result_more_fetch():
|
|
79
79
|
CursorResult.to_excel = Table.to_excel
|
80
80
|
|
81
81
|
|
82
|
-
def method_show(self: Result, limit: int | None = None) -> None:
|
82
|
+
def method_show(self: 'Result', limit: int | None = None) -> None:
|
83
83
|
"""
|
84
84
|
Print result.
|
85
85
|
|
@@ -131,7 +131,7 @@ def monkey_sqlalchemy_result_more_fetch():
|
|
131
131
|
|
132
132
|
|
133
133
|
@property
|
134
|
-
def method_exist(self: Result) -> bool:
|
134
|
+
def method_exist(self: 'Result') -> bool:
|
135
135
|
"""
|
136
136
|
Judge whether is exist row.
|
137
137
|
|
@@ -150,7 +150,7 @@ def monkey_sqlalchemy_result_more_fetch():
|
|
150
150
|
|
151
151
|
|
152
152
|
@property
|
153
|
-
def method_empty(self: Result) -> bool:
|
153
|
+
def method_empty(self: 'Result') -> bool:
|
154
154
|
"""
|
155
155
|
Judge whether is empty row.
|
156
156
|
|
reykit/rschedule.py
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
reykit/__init__.py,sha256=V86CHqPAAVkooVx3_QIOKpDIFVneQCTTSwfJ-uWgBno,788
|
2
2
|
reykit/rall.py,sha256=7Hip02YOkIDm3_xkoSDjvvYV2LhdBV2r4UKzWWnIfIo,628
|
3
|
-
reykit/rbase.py,sha256=
|
4
|
-
reykit/rdata.py,sha256=
|
3
|
+
reykit/rbase.py,sha256=PL0IngbmGm7luNTQh22hdV-TlVjH9EtXEzeRVGOYnAU,21758
|
4
|
+
reykit/rdata.py,sha256=iOU2_9RCihxrdXswZKvonVMIM-X5-L89WhawGDLHt4w,11361
|
5
5
|
reykit/remail.py,sha256=l4HGKXdfHNBxyBT3YxeZyQhfecbElqTqSAGInwWhap8,6723
|
6
6
|
reykit/rimage.py,sha256=lNN2iMpvSMqh-nPTpxrA9yHy43EA5WoYdxKYhqPwMgk,6154
|
7
|
-
reykit/rlog.py,sha256=
|
8
|
-
reykit/rmonkey.py,sha256=
|
7
|
+
reykit/rlog.py,sha256=M4UgS2gxYJOWv66ItyOv7AUJHJc1CsSDVYr9J0y2MwU,25768
|
8
|
+
reykit/rmonkey.py,sha256=MJ_levUBl_oqkx8UoWbNwrRBGPWGwpfAh0B25tESFUk,7863
|
9
9
|
reykit/rnet.py,sha256=McW4fX-omkD4_2BpLISHt2hpwIxK7EfDA5c6j3gn3E4,16874
|
10
10
|
reykit/rnum.py,sha256=VKICD64mEfiStAGWaxg3kzQjf7TTqiSBNe9LCpM9MLo,3623
|
11
11
|
reykit/ros.py,sha256=J6YxNbOceMhHwVKDugx5Wd-KFliRtlhFEVVcCAaE_So,47847
|
12
12
|
reykit/rrand.py,sha256=fiwxyUMaLtFjPanVwTOiwvEEucmf0t2WiZF9ul9o6pU,8572
|
13
13
|
reykit/rre.py,sha256=1qva7xatKVE9qC2j7IujjXSM59qxHWwTYpiizFFQ8Xo,6024
|
14
|
-
reykit/rschedule.py,sha256=
|
14
|
+
reykit/rschedule.py,sha256=jy6hxaIugyjSpUdQhPgCuubAZmRzKxHu4Nz3xM8Gid8,14696
|
15
15
|
reykit/rstdout.py,sha256=yesWo7wIGablpyAu-2J2Gw11Qp3GdQjGICTyIcvLyt4,8200
|
16
16
|
reykit/rsys.py,sha256=AP62KyN40flCeQJBclfJq8shachSAFT0LkVjiKsXkrw,24946
|
17
17
|
reykit/rtable.py,sha256=UQ-JlwjssMR3gY1iY-VGQEKQ5_BZabpJy6TL7Fx19c4,12200
|
@@ -22,7 +22,7 @@ reykit/rwrap.py,sha256=G4TL2GWUaW9DrCFRcsnDE1CwgdWeP2PnjQckheRx4p0,15095
|
|
22
22
|
reykit/rzip.py,sha256=BGEONswuBZxQ-zcgd_xp2fcvYesC9AmKaaXWvnT3bTI,3456
|
23
23
|
reykit/rdll/__init__.py,sha256=nLSb8onBm2ilyoxzpDzUeGfSCKwkLEesIhzK3LiJ8mk,701
|
24
24
|
reykit/rdll/rdll_core.py,sha256=o6-rKcTQgxZQe0kD3GnwyNb3KL9IogzgCQNOmYLMm7A,5086
|
25
|
-
reykit-1.1.
|
26
|
-
reykit-1.1.
|
27
|
-
reykit-1.1.
|
28
|
-
reykit-1.1.
|
25
|
+
reykit-1.1.86.dist-info/METADATA,sha256=ySyPHRKNXeVMRKVlPWBYBTtpmJdqfhOa4QiH0CHCZO0,1872
|
26
|
+
reykit-1.1.86.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
27
|
+
reykit-1.1.86.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
|
28
|
+
reykit-1.1.86.dist-info/RECORD,,
|
File without changes
|
File without changes
|