reykit 1.1.48__py3-none-any.whl → 1.1.50__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 = os_abspath(path)
326
+ self.path = get_path(path)
302
327
 
303
328
 
304
329
  @overload
@@ -824,14 +849,11 @@ class Folder(Base):
824
849
  Parameters
825
850
  ----------
826
851
  path : Folder path.
827
- - `None`: Work folder path.
828
- - `str`: Use this folder path.
852
+ - `None`: Use working directory.
829
853
  """
830
854
 
831
855
  # Set attribute.
832
- if path is None:
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, pattern: str) -> bool:
1226
+ def __contains__(self, relpath: str) -> bool:
1205
1227
  """
1206
- Search file by name, recursion directory.
1228
+ whether exist relative path object.
1207
1229
 
1208
1230
  Parameters
1209
1231
  ----------
1210
- pattern : Match file name pattern.
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
- result = self.search(pattern)
1219
- judge = result is not None
1240
+ path = self.join(relpath)
1241
+ judge = os_exists(path)
1220
1242
 
1221
1243
  return judge
1222
1244
 
@@ -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 = os_abspath(self.folder.name)
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, pattern: str) -> bool:
1873
+ def __contains__(self, relpath: str) -> bool:
1852
1874
  """
1853
- Search file by name, recursion directory.
1875
+ whether exist relative path object.
1854
1876
 
1855
1877
  Parameters
1856
1878
  ----------
1857
- pattern : Match file name pattern.
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
- result = self.search(pattern)
1866
- judge = result is not None
1887
+ path = self.join(relpath)
1888
+ judge = os_exists(path)
1867
1889
 
1868
1890
  return judge
1869
1891
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: reykit
3
- Version: 1.1.48
3
+ Version: 1.1.50
4
4
  Summary: Kit method set.
5
5
  Project-URL: homepage, https://github.com/reyxbo/reykit/
6
6
  Author-email: Rey <reyxbo@163.com>
@@ -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=0eQ0gshMsYuK_w4hP5A3aa2y6ftlEf0buHrOCR5EBjk,42594
11
+ reykit/ros.py,sha256=XdsXS5iWyLXENWnsZXwobX3RHT1xFCF2K5itfbvY8O8,42913
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.48.dist-info/METADATA,sha256=bpJw4erCKgErra1iE0A6N_0cENGwYle4NSFua5wrBgE,1872
26
- reykit-1.1.48.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
27
- reykit-1.1.48.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
28
- reykit-1.1.48.dist-info/RECORD,,
25
+ reykit-1.1.50.dist-info/METADATA,sha256=_fMPpRdHrTR6QMGtwyoOUF-Df4mrufB6SfyyYSAiu8s,1872
26
+ reykit-1.1.50.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
27
+ reykit-1.1.50.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
28
+ reykit-1.1.50.dist-info/RECORD,,