reykit 1.1.56__py3-none-any.whl → 1.1.58__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/rlog.py +71 -62
- reykit/ros.py +0 -2
- reykit/rtask.py +0 -2
- reykit/rtext.py +26 -1
- reykit/rtime.py +51 -14
- reykit/rwrap.py +3 -3
- {reykit-1.1.56.dist-info → reykit-1.1.58.dist-info}/METADATA +1 -1
- {reykit-1.1.56.dist-info → reykit-1.1.58.dist-info}/RECORD +10 -10
- {reykit-1.1.56.dist-info → reykit-1.1.58.dist-info}/WHEEL +0 -0
- {reykit-1.1.56.dist-info → reykit-1.1.58.dist-info}/licenses/LICENSE +0 -0
reykit/rlog.py
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
|
11
11
|
|
12
12
|
from typing import Any, Literal, Final, overload
|
13
|
-
from collections.abc import Callable
|
13
|
+
from collections.abc import Hashable, Callable
|
14
14
|
from queue import Queue
|
15
15
|
from os.path import abspath as os_abspath
|
16
16
|
from logging import (
|
@@ -29,8 +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, throw, catch_exc, get_first_notnone, get_stack_param
|
33
|
-
from .ros import File
|
32
|
+
from .rbase import Base, ConfigMeta, null, throw, catch_exc, get_first_notnone, get_stack_param
|
34
33
|
from .rre import search, sub
|
35
34
|
from .rstdout import ConfigStdout, modify_print, reset_print
|
36
35
|
from .rtext import to_text
|
@@ -41,7 +40,7 @@ from .rwrap import wrap_thread
|
|
41
40
|
__all__ = (
|
42
41
|
'ConfigLog',
|
43
42
|
'Log',
|
44
|
-
'
|
43
|
+
'Mark'
|
45
44
|
)
|
46
45
|
|
47
46
|
|
@@ -939,100 +938,110 @@ class Log(Base):
|
|
939
938
|
__call__ = log
|
940
939
|
|
941
940
|
|
942
|
-
class
|
941
|
+
class Mark(Base):
|
943
942
|
"""
|
944
|
-
|
943
|
+
Mark object type.
|
944
|
+
Based on memory ID.
|
945
945
|
"""
|
946
946
|
|
947
947
|
|
948
|
-
def __init__(
|
949
|
-
self,
|
950
|
-
path: str | None = '_rrecord'
|
951
|
-
) -> None:
|
948
|
+
def __init__(self) -> None:
|
952
949
|
"""
|
953
950
|
Build instance attributes.
|
951
|
+
"""
|
952
|
+
|
953
|
+
# Build.
|
954
|
+
self.default_set: set[int] = set()
|
955
|
+
self.data: dict[Hashable, set[int]] = {null: self.default_set}
|
956
|
+
|
957
|
+
|
958
|
+
def mark(self, obj: Any, group: Hashable = null) -> int:
|
959
|
+
"""
|
960
|
+
Mark object.
|
954
961
|
|
955
962
|
Parameters
|
956
963
|
----------
|
957
|
-
|
958
|
-
|
959
|
-
|
964
|
+
obj : Object.
|
965
|
+
group : Group index.
|
966
|
+
|
967
|
+
Returns
|
968
|
+
-------
|
969
|
+
Object memory ID.
|
960
970
|
"""
|
961
971
|
|
962
|
-
#
|
963
|
-
|
964
|
-
|
965
|
-
self.records = []
|
972
|
+
# Handle parameter.
|
973
|
+
obj_id = id(obj)
|
974
|
+
group_set = self.data.setdefault(group, set())
|
966
975
|
|
976
|
+
# Mark.
|
977
|
+
group_set.add(obj_id)
|
967
978
|
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
) -> None:
|
979
|
+
return obj_id
|
980
|
+
|
981
|
+
|
982
|
+
def remove(self, obj: Any, group: Hashable = null) -> None:
|
972
983
|
"""
|
973
|
-
|
984
|
+
Whether marked.
|
974
985
|
|
975
986
|
Parameters
|
976
987
|
----------
|
977
|
-
|
978
|
-
|
988
|
+
obj : Object.
|
989
|
+
group : Group index.
|
979
990
|
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
# To file.
|
985
|
-
else:
|
986
|
-
file = File(self.path)
|
991
|
+
Returns
|
992
|
+
-------
|
993
|
+
Judgment result.
|
994
|
+
"""
|
987
995
|
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
if file:
|
992
|
-
value += ':'
|
993
|
-
else:
|
994
|
-
value = ':%s:' % value
|
996
|
+
# Handle parameter.
|
997
|
+
obj_id = id(obj)
|
998
|
+
group_set = self.data.setdefault(group, set())
|
995
999
|
|
996
|
-
|
997
|
-
|
1000
|
+
# Remove.
|
1001
|
+
group_set.remove(obj_id)
|
998
1002
|
|
999
1003
|
|
1000
|
-
def
|
1001
|
-
self,
|
1002
|
-
value: Any
|
1003
|
-
) -> bool:
|
1004
|
+
def remove_group(self, group: Hashable) -> None:
|
1004
1005
|
"""
|
1005
|
-
|
1006
|
+
Whether marked.
|
1006
1007
|
|
1007
1008
|
Parameters
|
1008
1009
|
----------
|
1009
|
-
|
1010
|
+
group : Group index.
|
1010
1011
|
|
1011
1012
|
Returns
|
1012
1013
|
-------
|
1013
|
-
|
1014
|
+
Judgment result.
|
1014
1015
|
"""
|
1015
1016
|
|
1016
|
-
#
|
1017
|
-
|
1018
|
-
judge = value in self.records
|
1017
|
+
# Remove.
|
1018
|
+
del self.data[group]
|
1019
1019
|
|
1020
|
-
# To file.
|
1021
|
-
else:
|
1022
|
-
file = File(self.path)
|
1023
1020
|
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
value = ':%s:' % value
|
1021
|
+
def is_marked(self, obj: Any, group: Hashable = null) -> bool:
|
1022
|
+
"""
|
1023
|
+
Whether marked.
|
1028
1024
|
|
1029
|
-
|
1030
|
-
|
1025
|
+
Parameters
|
1026
|
+
----------
|
1027
|
+
obj : Object.
|
1028
|
+
group : Group index.
|
1029
|
+
|
1030
|
+
Returns
|
1031
|
+
-------
|
1032
|
+
Judgment result.
|
1033
|
+
"""
|
1034
|
+
|
1035
|
+
# Handle parameter.
|
1036
|
+
obj_id = id(obj)
|
1037
|
+
group_set = self.data.setdefault(group, set())
|
1031
1038
|
|
1032
|
-
|
1039
|
+
# Judge.
|
1040
|
+
result = obj_id in group_set
|
1033
1041
|
|
1042
|
+
return result
|
1034
1043
|
|
1035
|
-
__call__ = record
|
1036
1044
|
|
1045
|
+
__call__ = mark
|
1037
1046
|
|
1038
|
-
__contains__ =
|
1047
|
+
__contains__ = is_marked
|
reykit/ros.py
CHANGED
@@ -1270,7 +1270,6 @@ class Folder(Base):
|
|
1270
1270
|
|
1271
1271
|
__call__ = paths
|
1272
1272
|
|
1273
|
-
|
1274
1273
|
__add__ = __radd__ = join
|
1275
1274
|
|
1276
1275
|
|
@@ -1926,7 +1925,6 @@ class TempFolder(Base):
|
|
1926
1925
|
|
1927
1926
|
__call__ = paths
|
1928
1927
|
|
1929
|
-
|
1930
1928
|
__add__ = __radd__ = join
|
1931
1929
|
|
1932
1930
|
|
reykit/rtask.py
CHANGED
reykit/rtext.py
CHANGED
@@ -26,7 +26,8 @@ __all__ = (
|
|
26
26
|
'frame_text',
|
27
27
|
'frame_data',
|
28
28
|
'join_data_text',
|
29
|
-
'join_filter_text'
|
29
|
+
'join_filter_text',
|
30
|
+
'is_zh'
|
30
31
|
)
|
31
32
|
|
32
33
|
|
@@ -516,3 +517,27 @@ def join_filter_text(data: Iterable, char: str = ',', filter_: tuple = (None, ''
|
|
516
517
|
text = char.join(data)
|
517
518
|
|
518
519
|
return text
|
520
|
+
|
521
|
+
|
522
|
+
def is_zh(char: str) -> bool:
|
523
|
+
"""
|
524
|
+
whther is Chinese character.
|
525
|
+
Only includes basic Chinese character.
|
526
|
+
|
527
|
+
Parameters
|
528
|
+
----------
|
529
|
+
char : One character.
|
530
|
+
|
531
|
+
Returns
|
532
|
+
-------
|
533
|
+
Judged result.
|
534
|
+
"""
|
535
|
+
|
536
|
+
# Check.
|
537
|
+
if len(char) != 1:
|
538
|
+
throw(ValueError, char)
|
539
|
+
|
540
|
+
# Judge.
|
541
|
+
judge = '\u4e00' <= char <= '\u9fa5'
|
542
|
+
|
543
|
+
return judge
|
reykit/rtime.py
CHANGED
@@ -516,7 +516,7 @@ class TimeMark(Base):
|
|
516
516
|
"""
|
517
517
|
|
518
518
|
# Record table.
|
519
|
-
self.
|
519
|
+
self.records: dict[int, RecordData] = {}
|
520
520
|
|
521
521
|
|
522
522
|
def mark(self, note: str | None = None) -> int:
|
@@ -535,7 +535,7 @@ class TimeMark(Base):
|
|
535
535
|
# Get parametes.
|
536
536
|
|
537
537
|
# Mark.
|
538
|
-
index = len(self.
|
538
|
+
index = len(self.records)
|
539
539
|
now_timestamp = now('timestamp')
|
540
540
|
now_datetime = now('datetime')
|
541
541
|
record = {
|
@@ -548,11 +548,11 @@ class TimeMark(Base):
|
|
548
548
|
## Not first.
|
549
549
|
if index != 0:
|
550
550
|
last_index = index - 1
|
551
|
-
last_datetime = self.
|
551
|
+
last_datetime = self.records[last_index]['datetime']
|
552
552
|
record['timedelta'] = now_datetime - last_datetime
|
553
553
|
|
554
554
|
## Record.
|
555
|
-
self.
|
555
|
+
self.records[index] = record
|
556
556
|
|
557
557
|
return index
|
558
558
|
|
@@ -576,14 +576,14 @@ class TimeMark(Base):
|
|
576
576
|
from pandas import DataFrame
|
577
577
|
|
578
578
|
# Handle parameter.
|
579
|
-
record_len = len(self.
|
579
|
+
record_len = len(self.records)
|
580
580
|
data = [
|
581
581
|
info.copy()
|
582
|
-
for info in self.
|
582
|
+
for info in self.records.values()
|
583
583
|
]
|
584
584
|
indexes = [
|
585
585
|
index
|
586
|
-
for index in self.
|
586
|
+
for index in self.records
|
587
587
|
]
|
588
588
|
|
589
589
|
# Generate report.
|
@@ -598,7 +598,7 @@ class TimeMark(Base):
|
|
598
598
|
if record_len > 2:
|
599
599
|
row: RecordData = dict.fromkeys(('timestamp', 'datetime', 'timedelta', 'note'))
|
600
600
|
max_index = record_len - 1
|
601
|
-
total_timedelta = self.
|
601
|
+
total_timedelta = self.records[max_index]['datetime'] - self.records[0]['datetime']
|
602
602
|
row['timedelta'] = total_timedelta
|
603
603
|
data.append(row)
|
604
604
|
indexes.append('total')
|
@@ -640,13 +640,13 @@ class TimeMark(Base):
|
|
640
640
|
"""
|
641
641
|
|
642
642
|
# Break.
|
643
|
-
if len(self.
|
643
|
+
if len(self.records) <= 1:
|
644
644
|
return 0.0
|
645
645
|
|
646
646
|
# Handle parameter.
|
647
|
-
first_timestamp = self.
|
648
|
-
max_index = max(self.
|
649
|
-
last_timestamp = self.
|
647
|
+
first_timestamp = self.records[0]['timestamp']
|
648
|
+
max_index = max(self.records)
|
649
|
+
last_timestamp = self.records[max_index]['timestamp']
|
650
650
|
|
651
651
|
# Calculate.
|
652
652
|
seconds = round((last_timestamp - first_timestamp) / 1000, 3)
|
@@ -654,6 +654,15 @@ class TimeMark(Base):
|
|
654
654
|
return seconds
|
655
655
|
|
656
656
|
|
657
|
+
def clear(self) -> None:
|
658
|
+
"""
|
659
|
+
Clear records.
|
660
|
+
"""
|
661
|
+
|
662
|
+
# Clear.
|
663
|
+
self.records.clear()
|
664
|
+
|
665
|
+
|
657
666
|
def __str__(self) -> str:
|
658
667
|
"""
|
659
668
|
Convert to string.
|
@@ -672,6 +681,34 @@ class TimeMark(Base):
|
|
672
681
|
return string
|
673
682
|
|
674
683
|
|
675
|
-
|
684
|
+
def __int__(self) -> int:
|
685
|
+
"""
|
686
|
+
Get total spend seconds, truncate the decimal part.
|
687
|
+
|
688
|
+
Returns
|
689
|
+
-------
|
690
|
+
Total spend seconds.
|
691
|
+
"""
|
692
|
+
|
693
|
+
# Get
|
694
|
+
total_speend = int(self.total_spend)
|
695
|
+
|
696
|
+
return total_speend
|
676
697
|
|
677
|
-
|
698
|
+
|
699
|
+
def __float__(self) -> float:
|
700
|
+
"""
|
701
|
+
Get total spend seconds.
|
702
|
+
|
703
|
+
Returns
|
704
|
+
-------
|
705
|
+
Total spend seconds.
|
706
|
+
"""
|
707
|
+
|
708
|
+
# Get
|
709
|
+
total_speend = self.total_spend
|
710
|
+
|
711
|
+
return total_speend
|
712
|
+
|
713
|
+
|
714
|
+
__call__ = __getitem__ = mark
|
reykit/rwrap.py
CHANGED
@@ -197,9 +197,9 @@ def wrap_runtime(
|
|
197
197
|
tm()
|
198
198
|
|
199
199
|
# Generate report.
|
200
|
-
start_time = tm.
|
201
|
-
spend_time: Timedelta = tm.
|
202
|
-
end_time = tm.
|
200
|
+
start_time = tm.records[0]['datetime']
|
201
|
+
spend_time: Timedelta = tm.records[1]['timedelta']
|
202
|
+
end_time = tm.records[1]['datetime']
|
203
203
|
start_str = time_to(start_time, True)[:-3]
|
204
204
|
spend_str = time_to(spend_time, True)[:-3]
|
205
205
|
end_str = time_to(end_time, True)[:-3]
|
@@ -4,25 +4,25 @@ reykit/rbase.py,sha256=EfTMt6cRTfHlVXLX9D87lI8x6NEMfyX9IJP0WxBRkQg,22098
|
|
4
4
|
reykit/rdata.py,sha256=NmOY_h4w2PY5xBbYNmOnb55w7PGsvvCzOBnxPjQ08qw,10293
|
5
5
|
reykit/remail.py,sha256=l4HGKXdfHNBxyBT3YxeZyQhfecbElqTqSAGInwWhap8,6723
|
6
6
|
reykit/rimage.py,sha256=lNN2iMpvSMqh-nPTpxrA9yHy43EA5WoYdxKYhqPwMgk,6154
|
7
|
-
reykit/rlog.py,sha256=
|
7
|
+
reykit/rlog.py,sha256=ggQz8f4RcLOjw8p1VGRb-uqPqpMiOUAWzo48alk9sAg,25817
|
8
8
|
reykit/rmonkey.py,sha256=Dj2GBzBDFXbo0Z-5f8Zep4dfbaIw1bo1FUmC31xvDuk,7929
|
9
9
|
reykit/rnet.py,sha256=6uULgoPk8DTKWg9yNQco7gdw4A59F9ygcZR6rgO4eoY,16897
|
10
10
|
reykit/rnum.py,sha256=PhG4V_BkVfCJUsbpMDN1umGZly1Hsus80TW8bpyBtyY,3653
|
11
|
-
reykit/ros.py,sha256=
|
11
|
+
reykit/ros.py,sha256=8bLvjt0WkUPF6bkwQnm4xeoZTeKqcwM3a0EFt51WNaU,47006
|
12
12
|
reykit/rrand.py,sha256=bYYmuKNqn4un1i-SdA9jb9l1iYaeLfS-tWJRzD3gLDs,8941
|
13
13
|
reykit/rre.py,sha256=1qva7xatKVE9qC2j7IujjXSM59qxHWwTYpiizFFQ8Xo,6024
|
14
14
|
reykit/rschedule.py,sha256=E2gRLrCwrAo2CV1sOHrWoaVP99Wq7QjAqeYv04hWsYo,5767
|
15
15
|
reykit/rstdout.py,sha256=yesWo7wIGablpyAu-2J2Gw11Qp3GdQjGICTyIcvLyt4,8200
|
16
16
|
reykit/rsys.py,sha256=cafnGGerxR0kg5GHNJojmvsMDNsjgsJ3CtIGH5mAJa8,24953
|
17
17
|
reykit/rtable.py,sha256=YuDH2GL9Lwr5LljRDm5hzHrsvaXOs4-X89XVwFD-b0g,12221
|
18
|
-
reykit/rtask.py,sha256=
|
19
|
-
reykit/rtext.py,sha256=
|
20
|
-
reykit/rtime.py,sha256=
|
21
|
-
reykit/rwrap.py,sha256=
|
18
|
+
reykit/rtask.py,sha256=NUTngUUDUZy3TqEHiuiKy17FcE0F1zS118KnKTsBjng,22838
|
19
|
+
reykit/rtext.py,sha256=cWHy19lDcJvpX7LU95kmRVsDimpAUaz5TbKC1h83gB4,13254
|
20
|
+
reykit/rtime.py,sha256=8QJ6YNiC0JUDiW1xc1tkzQUMPYOFT7d7dKCYRuYt9co,17635
|
21
|
+
reykit/rwrap.py,sha256=UaMkBx3tTtFlqCGe7no6VmOIFnnuxNKcmIsAAThZUVs,15326
|
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.58.dist-info/METADATA,sha256=v9QtYZ6KbmyXXve74_nUf7ErqiXLaO-Unsgg0f_5yf0,1872
|
26
|
+
reykit-1.1.58.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
27
|
+
reykit-1.1.58.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
|
28
|
+
reykit-1.1.58.dist-info/RECORD,,
|
File without changes
|
File without changes
|