reykit 1.1.53__py3-none-any.whl → 1.1.54__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
@@ -549,7 +549,7 @@ class File(Base):
549
549
  Remove file.
550
550
  """
551
551
 
552
- # Copy.
552
+ # Remove.
553
553
  try:
554
554
  os_remove(self.path)
555
555
 
@@ -2026,7 +2026,7 @@ class FileCache(Base):
2026
2026
  return file_path
2027
2027
 
2028
2028
 
2029
- def store(self, source: FileSourceBytes, name: str | None = None) -> str:
2029
+ def store(self, source: FileSourceBytes, name: str | None = None, delete: bool = False) -> str:
2030
2030
  """
2031
2031
  Store file to cache directory.
2032
2032
 
@@ -2035,6 +2035,7 @@ class FileCache(Base):
2035
2035
  source : Source file path or file data.
2036
2036
  name : File name.
2037
2037
  - `None`: Use md5 value.
2038
+ delete : When source is file path, whether delete original file.
2038
2039
 
2039
2040
  Returns
2040
2041
  -------
@@ -2046,10 +2047,17 @@ class FileCache(Base):
2046
2047
  file_md5 = get_md5(file_bytes)
2047
2048
  if name is None:
2048
2049
  name = file_md5
2050
+ delete = delete and type(source) == str
2049
2051
 
2050
2052
  # Exist.
2051
2053
  path = self.index(file_md5, name)
2052
2054
  if path is not None:
2055
+
2056
+ ## Delete.
2057
+ if delete:
2058
+ file = File(source)
2059
+ file.remove()
2060
+
2053
2061
  return path
2054
2062
 
2055
2063
  # Store.
@@ -2057,11 +2065,19 @@ class FileCache(Base):
2057
2065
  md5_path = self.folder + md5_relpath
2058
2066
  folder = Folder(md5_path)
2059
2067
  folder.make()
2060
- file_path = folder + name
2061
- file = File(file_path)
2062
- file(file_bytes)
2068
+ path = folder + name
2069
+
2070
+ ## Delete.
2071
+ if delete:
2072
+ file = File(source)
2073
+ file.move(path)
2063
2074
 
2064
- return file.path
2075
+ ## Make.
2076
+ else:
2077
+ file = File(path)
2078
+ file(file_bytes)
2079
+
2080
+ return path
2065
2081
 
2066
2082
 
2067
2083
  def doc_to_docx(path: str, save_path: str | None = None) -> str:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: reykit
3
- Version: 1.1.53
3
+ Version: 1.1.54
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=jgnI8jFSGw0WcD8SSVmUCkomLXY8uoXdwJMUyB2ED4U,25587
8
8
  reykit/rmonkey.py,sha256=9-NvBM4phThKTHpqTSPlPGfJWcoDSp4EVl8x3xHJacg,7951
9
9
  reykit/rnet.py,sha256=15yrZTMET4cdimbslMk9O8HO9ofMtvfo1dZgLd4Bafw,16938
10
10
  reykit/rnum.py,sha256=PhG4V_BkVfCJUsbpMDN1umGZly1Hsus80TW8bpyBtyY,3653
11
- reykit/ros.py,sha256=Suy_PeGnOISCOgrOC2SiqdIUXMmeRUtqmajrqepsLLw,46634
11
+ reykit/ros.py,sha256=mhlwA8fmVURNH5eJbSnE9AN_9c44nH04GQaVBMigp-U,47033
12
12
  reykit/rrand.py,sha256=imysGSoQH4O0yq45EILYYdow_280LDqYioE4Sm-L4_U,8938
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=x4CzSndSdSv_e8lLbLifvC_v2ogWHD42-tDhwsq_DzQ,15317
22
22
  reykit/rzip.py,sha256=cG1PbY5dlMRNEIBzOytxF2crjr1yWLMmswR_klh_4Ek,3453
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.53.dist-info/METADATA,sha256=EC5bu3puTjojHhELxHpPTfYgzGRp2LV4u8-C9KikFYg,1872
26
- reykit-1.1.53.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
27
- reykit-1.1.53.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
28
- reykit-1.1.53.dist-info/RECORD,,
25
+ reykit-1.1.54.dist-info/METADATA,sha256=KnsGv5u0b7ZUBwEkGsieQ6yTp6tkPukiX_rurAkxoVk,1872
26
+ reykit-1.1.54.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
27
+ reykit-1.1.54.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
28
+ reykit-1.1.54.dist-info/RECORD,,