reykit 1.1.45__py3-none-any.whl → 1.1.46__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
@@ -838,7 +838,7 @@ class Folder(Base):
838
838
  self,
839
839
  target: Literal['all', 'file', 'folder'] = 'all',
840
840
  recursion: bool = False
841
- ) -> list:
841
+ ) -> list[str]:
842
842
  """
843
843
  Get the path of files and folders in the folder path.
844
844
 
@@ -856,7 +856,7 @@ class Folder(Base):
856
856
  """
857
857
 
858
858
  # Get paths.
859
- paths = []
859
+ paths: list[str] = []
860
860
 
861
861
  ## Recursive.
862
862
  if recursion:
@@ -912,59 +912,65 @@ class Folder(Base):
912
912
  def search(
913
913
  self,
914
914
  pattern: str,
915
- recursion: bool = False,
916
- all_ : Literal[False] = False
915
+ target: Literal['all', 'file', 'folder'] = 'all',
916
+ recursion: bool = False
917
917
  ) -> str | None: ...
918
918
 
919
919
  @overload
920
920
  def search(
921
921
  self,
922
922
  pattern: str,
923
+ target: Literal['all', 'file', 'folder'] = 'all',
923
924
  recursion: bool = False,
924
925
  *,
925
- all_ : Literal[True]
926
+ first: Literal[False]
926
927
  ) -> list[str]: ...
927
928
 
928
929
  def search(
929
930
  self,
930
931
  pattern: str,
932
+ target: Literal['all', 'file', 'folder'] = 'all',
931
933
  recursion: bool = False,
932
- all_ : bool = False
934
+ first: bool = True
933
935
  ) -> str | list[str] | None:
934
936
  """
935
- Search file by name.
937
+ Search file name by regular expression.
936
938
 
937
939
  Parameters
938
940
  ----------
939
- pattern : Match file name pattern.
941
+ pattern : Regular expression pattern.
942
+ target : Target data.
943
+ - `Literal['all']`: Return file and folder path.
944
+ - `Literal['file']`: Return file path.
945
+ - `Literal['folder']`: Return folder path.
940
946
  recursion : Is recursion directory.
941
- all\\_ : Whether return all match file path, otherwise return first match file path.
947
+ first : Whether return first search path, otherwise return all search path.
942
948
 
943
949
  Returns
944
950
  -------
945
- Match file path or null.
951
+ Searched path or null.
946
952
  """
947
953
 
948
954
  # Get paths.
949
- file_paths = self.paths('file', recursion)
955
+ file_paths = self.paths(target, recursion)
950
956
 
951
- # All.
952
- if all_:
953
- match_paths = []
957
+ # First.
958
+ if first:
954
959
  for path in file_paths:
955
- file_name = os_basename(path)
956
- result = search(pattern, file_name)
960
+ name = os_basename(path)
961
+ result = search(pattern, name)
957
962
  if result is not None:
958
- match_paths.append(path)
959
- return match_paths
963
+ return path
960
964
 
961
- # First.
965
+ # All.
962
966
  else:
967
+ match_paths: list[str] = []
963
968
  for path in file_paths:
964
- file_name = os_basename(path)
965
- result = search(pattern, file_name)
969
+ name = os_basename(path)
970
+ result = search(pattern, name)
966
971
  if result is not None:
967
- return path
972
+ match_paths.append(path)
973
+ return match_paths
968
974
 
969
975
 
970
976
  def create(self, report: bool = False) -> None:
@@ -1593,59 +1599,65 @@ class TempFolder(Base):
1593
1599
  def search(
1594
1600
  self,
1595
1601
  pattern: str,
1596
- recursion: bool = False,
1597
- all_ : Literal[False] = False
1602
+ target: Literal['all', 'file', 'folder'] = 'all',
1603
+ recursion: bool = False
1598
1604
  ) -> str | None: ...
1599
1605
 
1600
1606
  @overload
1601
1607
  def search(
1602
1608
  self,
1603
1609
  pattern: str,
1610
+ target: Literal['all', 'file', 'folder'] = 'all',
1604
1611
  recursion: bool = False,
1605
1612
  *,
1606
- all_ : Literal[True]
1613
+ first: Literal[False]
1607
1614
  ) -> list[str]: ...
1608
1615
 
1609
1616
  def search(
1610
1617
  self,
1611
1618
  pattern: str,
1619
+ target: Literal['all', 'file', 'folder'] = 'all',
1612
1620
  recursion: bool = False,
1613
- all_ : bool = False
1614
- ) -> str | None:
1621
+ first: bool = True
1622
+ ) -> str | list[str] | None:
1615
1623
  """
1616
- Search file by name.
1624
+ Search file name by regular expression.
1617
1625
 
1618
1626
  Parameters
1619
1627
  ----------
1620
- pattern : Match file name pattern.
1628
+ pattern : Regular expression pattern.
1629
+ target : Target data.
1630
+ - `Literal['all']`: Return file and folder path.
1631
+ - `Literal['file']`: Return file path.
1632
+ - `Literal['folder']`: Return folder path.
1621
1633
  recursion : Is recursion directory.
1622
- all\\_ : Whether return all match file path, otherwise return first match file path.
1634
+ first : Whether return first search path, otherwise return all search path.
1623
1635
 
1624
1636
  Returns
1625
1637
  -------
1626
- Match file path or null.
1638
+ Searched path or null.
1627
1639
  """
1628
1640
 
1629
1641
  # Get paths.
1630
- file_paths = self.paths('file', recursion)
1642
+ file_paths = self.paths(target, recursion)
1631
1643
 
1632
- # All.
1633
- if all_:
1634
- match_paths = []
1644
+ # First.
1645
+ if first:
1635
1646
  for path in file_paths:
1636
- file_name = os_basename(path)
1637
- result = search(pattern, file_name)
1647
+ name = os_basename(path)
1648
+ result = search(pattern, name)
1638
1649
  if result is not None:
1639
- match_paths.append(path)
1640
- return match_paths
1650
+ return path
1641
1651
 
1642
- # First.
1652
+ # All.
1643
1653
  else:
1654
+ match_paths: list[str] = []
1644
1655
  for path in file_paths:
1645
- file_name = os_basename(path)
1646
- result = search(pattern, file_name)
1656
+ name = os_basename(path)
1657
+ result = search(pattern, name)
1647
1658
  if result is not None:
1648
- return path
1659
+ match_paths.append(path)
1660
+ return match_paths
1649
1661
 
1650
1662
 
1651
1663
  @property
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: reykit
3
- Version: 1.1.45
3
+ Version: 1.1.46
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=BYqFWqktxRZsSzxPU0u-QnMnNKH90SY3anwoIuajzCI,41150
11
+ reykit/ros.py,sha256=ri7MtbvhfL20GHBiAEjyTCe6lMJqc5bRaRV5m8rSca4,41860
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.45.dist-info/METADATA,sha256=-eot345YciZjs3CkwiEwHq18-P-Pr8Pa6_eYTzGPP18,1872
26
- reykit-1.1.45.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
27
- reykit-1.1.45.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
28
- reykit-1.1.45.dist-info/RECORD,,
25
+ reykit-1.1.46.dist-info/METADATA,sha256=rSDs_msZ4jYEbCqkDHBV5dnm2_AsxH_AJihnZ0bkrUk,1872
26
+ reykit-1.1.46.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
27
+ reykit-1.1.46.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
28
+ reykit-1.1.46.dist-info/RECORD,,