reykit 1.1.47__py3-none-any.whl → 1.1.49__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/ros.py
CHANGED
@@ -22,7 +22,6 @@ from os import (
|
|
22
22
|
remove as os_remove
|
23
23
|
)
|
24
24
|
from os.path import (
|
25
|
-
abspath as os_abspath,
|
26
25
|
join as os_join,
|
27
26
|
isfile as os_isfile,
|
28
27
|
isdir as os_isdir,
|
@@ -38,6 +37,7 @@ from os.path import (
|
|
38
37
|
splitdrive as os_splitdrive
|
39
38
|
)
|
40
39
|
from shutil import copy as shutil_copy
|
40
|
+
from pathlib import Path
|
41
41
|
from json import JSONDecodeError
|
42
42
|
from tomllib import loads as tomllib_loads
|
43
43
|
from hashlib import md5 as hashlib_md5
|
@@ -74,6 +74,31 @@ type FileStr = FilePath | FileText | TextIOBase
|
|
74
74
|
type FileBytes = FilePath | FileData | BufferedIOBase
|
75
75
|
|
76
76
|
|
77
|
+
def get_path(path: str | None = None) -> str:
|
78
|
+
"""
|
79
|
+
resolve relative path and replace to forward slash `/`.
|
80
|
+
|
81
|
+
Parameters
|
82
|
+
----------
|
83
|
+
path : Path.
|
84
|
+
- `None`: Use working directory.
|
85
|
+
|
86
|
+
Returns
|
87
|
+
-------
|
88
|
+
Handled path.
|
89
|
+
"""
|
90
|
+
|
91
|
+
# Handle parameter.
|
92
|
+
path = path or ''
|
93
|
+
|
94
|
+
# Handle.
|
95
|
+
path_obj = Path(path)
|
96
|
+
path_obj = path_obj.resolve()
|
97
|
+
path = path_obj.as_posix()
|
98
|
+
|
99
|
+
return path
|
100
|
+
|
101
|
+
|
77
102
|
def get_md5(data: str | bytes) -> str:
|
78
103
|
"""
|
79
104
|
Get MD5 value.
|
@@ -298,7 +323,7 @@ class File(Base):
|
|
298
323
|
"""
|
299
324
|
|
300
325
|
# Set attribute.
|
301
|
-
self.path =
|
326
|
+
self.path = get_path(path)
|
302
327
|
|
303
328
|
|
304
329
|
@overload
|
@@ -542,68 +567,68 @@ class File(Base):
|
|
542
567
|
return file_bytes
|
543
568
|
|
544
569
|
|
545
|
-
@property
|
546
|
-
def name_suffix(self) -> str:
|
547
|
-
|
548
|
-
|
570
|
+
# @property
|
571
|
+
# def name_suffix(self) -> str:
|
572
|
+
# """
|
573
|
+
# Return file name with suffix.
|
549
574
|
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
575
|
+
# Returns
|
576
|
+
# -------
|
577
|
+
# File name with suffix.
|
578
|
+
# """
|
554
579
|
|
555
|
-
|
556
|
-
|
580
|
+
# # Get.
|
581
|
+
# file_name_suffix = os_basename(self.path)
|
557
582
|
|
558
|
-
|
583
|
+
# return file_name_suffix
|
559
584
|
|
560
585
|
|
561
|
-
@property
|
562
|
-
def name(self) -> str:
|
563
|
-
|
564
|
-
|
586
|
+
# @property
|
587
|
+
# def name(self) -> str:
|
588
|
+
# """
|
589
|
+
# Return file name not with suffix.
|
565
590
|
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
591
|
+
# Returns
|
592
|
+
# -------
|
593
|
+
# File name not with suffix.
|
594
|
+
# """
|
570
595
|
|
571
|
-
|
572
|
-
|
596
|
+
# # Get.
|
597
|
+
# file_name, _ = os_splitext(self.name_suffix)
|
573
598
|
|
574
|
-
|
599
|
+
# return file_name
|
575
600
|
|
576
601
|
|
577
|
-
@property
|
578
|
-
def suffix(self) -> str:
|
579
|
-
|
580
|
-
|
602
|
+
# @property
|
603
|
+
# def suffix(self) -> str:
|
604
|
+
# """
|
605
|
+
# Return file suffix.
|
581
606
|
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
607
|
+
# Returns
|
608
|
+
# -------
|
609
|
+
# File suffix.
|
610
|
+
# """
|
586
611
|
|
587
|
-
|
588
|
-
|
612
|
+
# # Get.
|
613
|
+
# _, file_suffix = os_splitext(self.path)
|
589
614
|
|
590
|
-
|
615
|
+
# return file_suffix
|
591
616
|
|
592
617
|
|
593
|
-
@property
|
594
|
-
def dir(self) -> str:
|
595
|
-
|
596
|
-
|
618
|
+
# @property
|
619
|
+
# def dir(self) -> str:
|
620
|
+
# """
|
621
|
+
# Return file directory.
|
597
622
|
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
623
|
+
# Returns
|
624
|
+
# -------
|
625
|
+
# File directory.
|
626
|
+
# """
|
602
627
|
|
603
|
-
|
604
|
-
|
628
|
+
# # Get.
|
629
|
+
# file_dir = os_dirname(self.path)
|
605
630
|
|
606
|
-
|
631
|
+
# return file_dir
|
607
632
|
|
608
633
|
|
609
634
|
@property
|
@@ -824,14 +849,11 @@ class Folder(Base):
|
|
824
849
|
Parameters
|
825
850
|
----------
|
826
851
|
path : Folder path.
|
827
|
-
- `None`:
|
828
|
-
- `str`: Use this folder path.
|
852
|
+
- `None`: Use working directory.
|
829
853
|
"""
|
830
854
|
|
831
855
|
# Set attribute.
|
832
|
-
|
833
|
-
path = ''
|
834
|
-
self.path = os_abspath(path)
|
856
|
+
self.path = get_path(path)
|
835
857
|
|
836
858
|
|
837
859
|
def paths(
|
@@ -973,6 +995,25 @@ class Folder(Base):
|
|
973
995
|
return match_paths
|
974
996
|
|
975
997
|
|
998
|
+
def join(self, path: str) -> str:
|
999
|
+
"""
|
1000
|
+
Join folder path and relative path.
|
1001
|
+
|
1002
|
+
Parameters
|
1003
|
+
----------
|
1004
|
+
path : Relative path.
|
1005
|
+
|
1006
|
+
Returns
|
1007
|
+
-------
|
1008
|
+
Joined path.
|
1009
|
+
"""
|
1010
|
+
|
1011
|
+
# Join.
|
1012
|
+
join_path = os_join(self.path, path)
|
1013
|
+
|
1014
|
+
return join_path
|
1015
|
+
|
1016
|
+
|
976
1017
|
def create(self, report: bool = False) -> None:
|
977
1018
|
"""
|
978
1019
|
Create folders.
|
@@ -1182,13 +1223,13 @@ class Folder(Base):
|
|
1182
1223
|
return folder_size
|
1183
1224
|
|
1184
1225
|
|
1185
|
-
def __contains__(self,
|
1226
|
+
def __contains__(self, relpath: str) -> bool:
|
1186
1227
|
"""
|
1187
|
-
|
1228
|
+
whether exist relative path object.
|
1188
1229
|
|
1189
1230
|
Parameters
|
1190
1231
|
----------
|
1191
|
-
|
1232
|
+
relpath : Relative path.
|
1192
1233
|
|
1193
1234
|
Returns
|
1194
1235
|
-------
|
@@ -1196,8 +1237,8 @@ class Folder(Base):
|
|
1196
1237
|
"""
|
1197
1238
|
|
1198
1239
|
# Judge.
|
1199
|
-
|
1200
|
-
judge =
|
1240
|
+
path = self.join(relpath)
|
1241
|
+
judge = os_exists(path)
|
1201
1242
|
|
1202
1243
|
return judge
|
1203
1244
|
|
@@ -1205,7 +1246,10 @@ class Folder(Base):
|
|
1205
1246
|
__call__ = paths
|
1206
1247
|
|
1207
1248
|
|
1208
|
-
|
1249
|
+
__add__ = __radd__ = join
|
1250
|
+
|
1251
|
+
|
1252
|
+
class TempFile(File):
|
1209
1253
|
"""
|
1210
1254
|
Temporary file type.
|
1211
1255
|
"""
|
@@ -1241,7 +1285,7 @@ class TempFile(Base):
|
|
1241
1285
|
suffix=suffix,
|
1242
1286
|
dir=dir_
|
1243
1287
|
)
|
1244
|
-
self.path = self.file.name
|
1288
|
+
self.path = get_path(self.file.name)
|
1245
1289
|
|
1246
1290
|
|
1247
1291
|
def read(self) -> bytes | str:
|
@@ -1518,7 +1562,7 @@ class TempFolder(Base):
|
|
1518
1562
|
|
1519
1563
|
# Set attribute.
|
1520
1564
|
self.folder = TemporaryDirectory(dir=dir_)
|
1521
|
-
self.path =
|
1565
|
+
self.path = get_path(self.folder.name)
|
1522
1566
|
|
1523
1567
|
|
1524
1568
|
def paths(
|
@@ -1660,6 +1704,25 @@ class TempFolder(Base):
|
|
1660
1704
|
return match_paths
|
1661
1705
|
|
1662
1706
|
|
1707
|
+
def join(self, path: str) -> str:
|
1708
|
+
"""
|
1709
|
+
Join folder path and relative path.
|
1710
|
+
|
1711
|
+
Parameters
|
1712
|
+
----------
|
1713
|
+
path : Relative path.
|
1714
|
+
|
1715
|
+
Returns
|
1716
|
+
-------
|
1717
|
+
Joined path.
|
1718
|
+
"""
|
1719
|
+
|
1720
|
+
# Join.
|
1721
|
+
join_path = os_join(self.path, path)
|
1722
|
+
|
1723
|
+
return join_path
|
1724
|
+
|
1725
|
+
|
1663
1726
|
@property
|
1664
1727
|
def name(self) -> str:
|
1665
1728
|
"""
|
@@ -1807,13 +1870,13 @@ class TempFolder(Base):
|
|
1807
1870
|
return folder_size
|
1808
1871
|
|
1809
1872
|
|
1810
|
-
def __contains__(self,
|
1873
|
+
def __contains__(self, relpath: str) -> bool:
|
1811
1874
|
"""
|
1812
|
-
|
1875
|
+
whether exist relative path object.
|
1813
1876
|
|
1814
1877
|
Parameters
|
1815
1878
|
----------
|
1816
|
-
|
1879
|
+
relpath : Relative path.
|
1817
1880
|
|
1818
1881
|
Returns
|
1819
1882
|
-------
|
@@ -1821,8 +1884,8 @@ class TempFolder(Base):
|
|
1821
1884
|
"""
|
1822
1885
|
|
1823
1886
|
# Judge.
|
1824
|
-
|
1825
|
-
judge =
|
1887
|
+
path = self.join(relpath)
|
1888
|
+
judge = os_exists(path)
|
1826
1889
|
|
1827
1890
|
return judge
|
1828
1891
|
|
@@ -1839,6 +1902,9 @@ class TempFolder(Base):
|
|
1839
1902
|
__call__ = paths
|
1840
1903
|
|
1841
1904
|
|
1905
|
+
__add__ = __radd__ = join
|
1906
|
+
|
1907
|
+
|
1842
1908
|
def doc_to_docx(path: str, save_path: str | None = None) -> str:
|
1843
1909
|
"""
|
1844
1910
|
Convert `DOC` file to `DOCX` file.
|
@@ -8,7 +8,7 @@ reykit/rlog.py,sha256=FpxIa24jyr806KVdIjhaqmiggOEwuwZ7ncros9YNNHA,25592
|
|
8
8
|
reykit/rmonkey.py,sha256=9-NvBM4phThKTHpqTSPlPGfJWcoDSp4EVl8x3xHJacg,7951
|
9
9
|
reykit/rnet.py,sha256=zvEWAM42jAdQT868FFDrm-OPn5f3SNfMZP-bU8Sbx0A,16934
|
10
10
|
reykit/rnum.py,sha256=PhG4V_BkVfCJUsbpMDN1umGZly1Hsus80TW8bpyBtyY,3653
|
11
|
-
reykit/ros.py,sha256=
|
11
|
+
reykit/ros.py,sha256=ksnr6oUn-i8XYXv3KTbxm375YLH4NqdioMJjnhqa84A,43001
|
12
12
|
reykit/rrand.py,sha256=9QPXCsREIu45g6WP-XN67X05kmW3cTmctn3InvqYxuY,8947
|
13
13
|
reykit/rre.py,sha256=4DVxy28dl5zn6_II8-cgr7E2nVPH5QJIJVB4o7Vsf1A,6078
|
14
14
|
reykit/rschedule.py,sha256=_nrfrXYxlFAKCDbM8ibTTb60zNDlHxyE310cv-A19Kw,5799
|
@@ -22,7 +22,7 @@ reykit/rwrap.py,sha256=3at29SGx5As9fmv1t9m_ibjHTvXpA6uPo-mroSsrX-I,15323
|
|
22
22
|
reykit/rzip.py,sha256=ABUDLwEHQIpcvZbJE_oV78H7dik6nC7kaRz660Ro9Os,3481
|
23
23
|
reykit/rdll/__init__.py,sha256=WrJ_8jp_hbn2nl1osrR3buZMsmAGRVY6HfQdhDoJpSM,698
|
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.49.dist-info/METADATA,sha256=x2fAYfK2Un5opWmyzCOXhbeHq1J9vJmcmG8ZiIgyFwE,1872
|
26
|
+
reykit-1.1.49.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
27
|
+
reykit-1.1.49.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
|
28
|
+
reykit-1.1.49.dist-info/RECORD,,
|
File without changes
|
File without changes
|