megfile 4.2.0__py3-none-any.whl → 4.2.1__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.
megfile/s3_path.py CHANGED
@@ -1676,15 +1676,18 @@ class S3Path(URIPath):
1676
1676
  :returns: True if path is s3 file, else False
1677
1677
  """
1678
1678
  s3_url = self.path_with_protocol
1679
+ bucket, key = parse_s3_url(s3_url)
1680
+ if not bucket or not key or key.endswith("/"):
1681
+ # s3://, s3:///key, s3://bucket, s3://bucket/prefix/
1682
+ return False
1683
+
1679
1684
  if followlinks:
1680
1685
  try:
1681
1686
  s3_url = self.readlink().path_with_protocol
1687
+ bucket, key = parse_s3_url(s3_url)
1682
1688
  except S3NotALinkError:
1683
1689
  pass
1684
- bucket, key = parse_s3_url(s3_url)
1685
- if not bucket or not key or key.endswith("/"):
1686
- # s3://, s3:///key, s3://bucket, s3://bucket/prefix/
1687
- return False
1690
+
1688
1691
  try:
1689
1692
  self._client.head_object(Bucket=bucket, Key=key)
1690
1693
  except Exception as error:
@@ -1829,18 +1832,18 @@ class S3Path(URIPath):
1829
1832
  )
1830
1833
  if not key:
1831
1834
  raise UnsupportedError("Remove bucket", self.path_with_protocol)
1832
- if not self.exists():
1833
- if missing_ok:
1834
- return
1835
- raise S3FileNotFoundError(
1836
- "No such file or directory: %r" % self.path_with_protocol
1837
- )
1838
1835
 
1839
1836
  client = self._client
1837
+ if self.is_file():
1838
+ try:
1839
+ with raise_s3_error(self.path_with_protocol):
1840
+ client.delete_object(Bucket=bucket, Key=key)
1841
+ except S3FileNotFoundError:
1842
+ if not missing_ok:
1843
+ raise
1844
+ return
1845
+
1840
1846
  with raise_s3_error(self.path_with_protocol):
1841
- if self.is_file():
1842
- client.delete_object(Bucket=bucket, Key=key)
1843
- return
1844
1847
  prefix = _become_prefix(key)
1845
1848
  total_count, error_count = 0, 0
1846
1849
  for resp in _list_objects_recursive(client, bucket, prefix):
@@ -1891,6 +1894,10 @@ class S3Path(URIPath):
1891
1894
  % (self.path_with_protocol, total_count, error_count)
1892
1895
  )
1893
1896
  raise S3UnknownError(Exception(error_msg), self.path_with_protocol)
1897
+ if total_count == 0 and not missing_ok:
1898
+ raise S3FileNotFoundError(
1899
+ "No such file or directory: %r" % self.path_with_protocol
1900
+ )
1894
1901
 
1895
1902
  def rename(self, dst_path: PathLike, overwrite: bool = True) -> "S3Path":
1896
1903
  """
megfile/version.py CHANGED
@@ -1 +1 @@
1
- VERSION = "4.2.0"
1
+ VERSION = "4.2.1"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: megfile
3
- Version: 4.2.0
3
+ Version: 4.2.1
4
4
  Summary: Megvii file operation library
5
5
  Author-email: megvii <megfile@megvii.com>
6
6
  Project-URL: Homepage, https://github.com/megvii-research/megfile
@@ -11,14 +11,14 @@ megfile/http_path.py,sha256=08OmzmRMyLSyq1Yr1K2HbzexesURJrIoA6AibwYzUiA,13844
11
11
  megfile/interfaces.py,sha256=p4UvVZpeLx5djd6bqqDaygIx_s-_AxIVj-gudTch4JE,8467
12
12
  megfile/pathlike.py,sha256=3Hnw-fn6RcIe9iPrJt00QdHSA--UfDyxnVBuZ_ymYYQ,31278
13
13
  megfile/s3.py,sha256=abBxnI7RIyn7n7qjGszP1VruYd6Gi9I8QnUOvsHkx1Y,16325
14
- megfile/s3_path.py,sha256=nA1FXFwfhSvZN8W0mF2PKGbnaTDouZfp6anUZkxvOBc,93449
14
+ megfile/s3_path.py,sha256=NKOJLxy1gxdOc-jdEvxNl45tham5un8YWmZC-CZXHuU,93663
15
15
  megfile/sftp.py,sha256=uBcLQs-j6Q-q-sWAdd-pgi5Qmb_kq7boJM-0sCfcNO0,26540
16
16
  megfile/sftp_path.py,sha256=CgirHWmNdXdqyIL9ufmlaMpwFhlkQVZhqmfvjUaj7qU,43845
17
17
  megfile/smart.py,sha256=Miz3jyLKmwWBja-8GrSzrumpTarPrFPqXaFQJKwrK1Y,36627
18
18
  megfile/smart_path.py,sha256=Up_6xNZ2019iSzMn_JAU_1H--z-AP6O7SxdXGdeTG0c,7659
19
19
  megfile/stdio.py,sha256=ZwxsnJNJYIT7Iyg5pIw4qiyH8bszG6oAhEJuR-hXGG4,658
20
20
  megfile/stdio_path.py,sha256=cxaDr8rtisTPnN-rjtaEpqQnshwiqwXFUJBM9xWY7Cg,2711
21
- megfile/version.py,sha256=nmN7kc0bNHgtVq4jv4MJKEo-L3X7QgGHAv_z6zkMVSQ,19
21
+ megfile/version.py,sha256=e0k-2Nn8dpoGmVJ3Wg03fcRMzM9q9jfKeY7f3OkI7LE,19
22
22
  megfile/lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
23
  megfile/lib/base_prefetch_reader.py,sha256=uxVwYknOjc8hLF7q_T2QKMsBqFcrf411ZsuK25CN1eQ,12848
24
24
  megfile/lib/combine_reader.py,sha256=Kp2wEloOUpTlIU7dve87MBpSzmIM-F9OtpTawAjFkiU,4828
@@ -43,10 +43,10 @@ megfile/lib/stdio_handler.py,sha256=IDdgENLQlhigEwkLL4zStueVSzdWg7xVcTF_koof_Ek,
43
43
  megfile/lib/url.py,sha256=ER32pWy9Q2MAk3TraAaNEBWIqUeBmLuM57ol2cs7-Ks,103
44
44
  megfile/utils/__init__.py,sha256=pawmXnCNokWLj338a60b_hK21koYavpEiEohZhsOaGQ,10156
45
45
  megfile/utils/mutex.py,sha256=asb8opGLgK22RiuBJUnfsvB8LnMmodP8KzCVHKmQBWA,2561
46
- megfile-4.2.0.dist-info/licenses/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
47
- megfile-4.2.0.dist-info/licenses/LICENSE.pyre,sha256=9lf5nT-5ZH25JijpYAequ0bl8E8z5JmZB1qrjiUMp84,1080
48
- megfile-4.2.0.dist-info/METADATA,sha256=0IuIzy3B0sO0YhPrMdEK5kCkK16K1ZCX6w3vZO-SlB4,9595
49
- megfile-4.2.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
50
- megfile-4.2.0.dist-info/entry_points.txt,sha256=M6ZWSSv5_5_QtIpZafy3vq7WuOJ_5dSGQQnEZbByt2Q,49
51
- megfile-4.2.0.dist-info/top_level.txt,sha256=i3rMgdU1ZAJekAceojhA-bkm3749PzshtRmLTbeLUPQ,8
52
- megfile-4.2.0.dist-info/RECORD,,
46
+ megfile-4.2.1.dist-info/licenses/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
47
+ megfile-4.2.1.dist-info/licenses/LICENSE.pyre,sha256=9lf5nT-5ZH25JijpYAequ0bl8E8z5JmZB1qrjiUMp84,1080
48
+ megfile-4.2.1.dist-info/METADATA,sha256=8-Gzye2STZTocHieLky8XR0nAae8sHEmanRVeTWKWYM,9595
49
+ megfile-4.2.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
50
+ megfile-4.2.1.dist-info/entry_points.txt,sha256=M6ZWSSv5_5_QtIpZafy3vq7WuOJ_5dSGQQnEZbByt2Q,49
51
+ megfile-4.2.1.dist-info/top_level.txt,sha256=i3rMgdU1ZAJekAceojhA-bkm3749PzshtRmLTbeLUPQ,8
52
+ megfile-4.2.1.dist-info/RECORD,,