reykit 1.1.48__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(
|
@@ -1201,13 +1223,13 @@ class Folder(Base):
|
|
1201
1223
|
return folder_size
|
1202
1224
|
|
1203
1225
|
|
1204
|
-
def __contains__(self,
|
1226
|
+
def __contains__(self, relpath: str) -> bool:
|
1205
1227
|
"""
|
1206
|
-
|
1228
|
+
whether exist relative path object.
|
1207
1229
|
|
1208
1230
|
Parameters
|
1209
1231
|
----------
|
1210
|
-
|
1232
|
+
relpath : Relative path.
|
1211
1233
|
|
1212
1234
|
Returns
|
1213
1235
|
-------
|
@@ -1215,8 +1237,8 @@ class Folder(Base):
|
|
1215
1237
|
"""
|
1216
1238
|
|
1217
1239
|
# Judge.
|
1218
|
-
|
1219
|
-
judge =
|
1240
|
+
path = self.join(relpath)
|
1241
|
+
judge = os_exists(path)
|
1220
1242
|
|
1221
1243
|
return judge
|
1222
1244
|
|
@@ -1227,7 +1249,7 @@ class Folder(Base):
|
|
1227
1249
|
__add__ = __radd__ = join
|
1228
1250
|
|
1229
1251
|
|
1230
|
-
class TempFile(
|
1252
|
+
class TempFile(File):
|
1231
1253
|
"""
|
1232
1254
|
Temporary file type.
|
1233
1255
|
"""
|
@@ -1263,7 +1285,7 @@ class TempFile(Base):
|
|
1263
1285
|
suffix=suffix,
|
1264
1286
|
dir=dir_
|
1265
1287
|
)
|
1266
|
-
self.path = self.file.name
|
1288
|
+
self.path = get_path(self.file.name)
|
1267
1289
|
|
1268
1290
|
|
1269
1291
|
def read(self) -> bytes | str:
|
@@ -1540,7 +1562,7 @@ class TempFolder(Base):
|
|
1540
1562
|
|
1541
1563
|
# Set attribute.
|
1542
1564
|
self.folder = TemporaryDirectory(dir=dir_)
|
1543
|
-
self.path =
|
1565
|
+
self.path = get_path(self.folder.name)
|
1544
1566
|
|
1545
1567
|
|
1546
1568
|
def paths(
|
@@ -1848,13 +1870,13 @@ class TempFolder(Base):
|
|
1848
1870
|
return folder_size
|
1849
1871
|
|
1850
1872
|
|
1851
|
-
def __contains__(self,
|
1873
|
+
def __contains__(self, relpath: str) -> bool:
|
1852
1874
|
"""
|
1853
|
-
|
1875
|
+
whether exist relative path object.
|
1854
1876
|
|
1855
1877
|
Parameters
|
1856
1878
|
----------
|
1857
|
-
|
1879
|
+
relpath : Relative path.
|
1858
1880
|
|
1859
1881
|
Returns
|
1860
1882
|
-------
|
@@ -1862,8 +1884,8 @@ class TempFolder(Base):
|
|
1862
1884
|
"""
|
1863
1885
|
|
1864
1886
|
# Judge.
|
1865
|
-
|
1866
|
-
judge =
|
1887
|
+
path = self.join(relpath)
|
1888
|
+
judge = os_exists(path)
|
1867
1889
|
|
1868
1890
|
return judge
|
1869
1891
|
|
@@ -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
|