@@ -152,12 +152,16 @@ def getinfo(self, path, namespaces=None):
152
152
153
153
Arguments:
154
154
path (str): A path to a resource on the filesystem.
155
- namespaces (list, optional): Info namespaces to query
156
- (defaults to *[basic]*).
155
+ namespaces (list, optional): Info namespaces to query. The
156
+ `"basic"` namespace is alway included in the returned
157
+ info, whatever the value of `namespaces` may be.
157
158
158
159
Returns:
159
160
~fs.info.Info: resource information object.
160
161
162
+ Raises:
163
+ fs.errors.ResourceNotFound: If ``path`` does not exist.
164
+
161
165
For more information regarding resource information, see :ref:`info`.
162
166
163
167
"""
@@ -235,10 +239,12 @@ def openbin(
235
239
io.IOBase: a *file-like* object.
236
240
237
241
Raises:
238
- fs.errors.FileExpected: If the path is not a file.
239
- fs.errors.FileExists: If the file exists, and *exclusive mode*
240
- is specified (``x`` in the mode).
241
- fs.errors.ResourceNotFound: If the path does not exist.
242
+ fs.errors.FileExpected: If ``path`` exists and is not a file.
243
+ fs.errors.FileExists: If the ``path`` exists, and
244
+ *exclusive mode* is specified (``x`` in the mode).
245
+ fs.errors.ResourceNotFound: If ``path`` does not exist and
246
+ ``mode`` does not imply creating the file, or if any
247
+ ancestor of ``path`` does not exist.
242
248
243
249
"""
244
250
@@ -402,6 +408,7 @@ def copy(self, src_path, dst_path, overwrite=False):
402
408
and ``overwrite`` is `False`.
403
409
fs.errors.ResourceNotFound: If a parent directory of
404
410
``dst_path`` does not exist.
411
+ fs.errors.FileExpected: If ``src_path`` is not a file.
405
412
406
413
"""
407
414
with self ._lock :
@@ -587,6 +594,7 @@ def readbytes(self, path):
587
594
bytes: the file contents.
588
595
589
596
Raises:
597
+ fs.errors.FileExpected: if ``path`` exists but is not a file.
590
598
fs.errors.ResourceNotFound: if ``path`` does not exist.
591
599
592
600
"""
@@ -603,6 +611,10 @@ def download(self, path, file, chunk_size=None, **options):
603
611
This may be more efficient that opening and copying files
604
612
manually if the filesystem supplies an optimized method.
605
613
614
+ Note that the file object ``file`` will *not* be closed by this
615
+ method. Take care to close it after this method completes
616
+ (ideally with a context manager).
617
+
606
618
Arguments:
607
619
path (str): Path to a resource.
608
620
file (file-like): A file-like object open for writing in
@@ -613,14 +625,13 @@ def download(self, path, file, chunk_size=None, **options):
613
625
**options: Implementation specific options required to open
614
626
the source file.
615
627
616
- Note that the file object ``file`` will *not* be closed by this
617
- method. Take care to close it after this method completes
618
- (ideally with a context manager).
619
-
620
628
Example:
621
629
>>> with open('starwars.mov', 'wb') as write_file:
622
630
... my_fs.download('/Videos/starwars.mov', write_file)
623
631
632
+ Raises:
633
+ fs.errors.ResourceNotFound: if ``path`` does not exist.
634
+
624
635
"""
625
636
with self ._lock :
626
637
with self .openbin (path , ** options ) as read_file :
@@ -698,7 +709,7 @@ def getmeta(self, namespace="standard"):
698
709
network.
699
710
read_only `True` if this filesystem is read only.
700
711
supports_rename `True` if this filesystem supports an
701
- `os.rename` operation.
712
+ `os.rename` operation (or equivalent) .
702
713
=================== ============================================
703
714
704
715
Most builtin filesystems will provide all these keys, and third-
@@ -726,6 +737,9 @@ def getsize(self, path):
726
737
Returns:
727
738
int: the *size* of the resource.
728
739
740
+ Raises:
741
+ fs.errors.ResourceNotFound: if ``path`` does not exist.
742
+
729
743
The *size* of a file is the total number of readable bytes,
730
744
which may not reflect the exact number of bytes of reserved
731
745
disk space (or other storage medium).
@@ -1018,6 +1032,8 @@ def movedir(self, src_path, dst_path, create=False):
1018
1032
Raises:
1019
1033
fs.errors.ResourceNotFound: if ``dst_path`` does not exist,
1020
1034
and ``create`` is `False`.
1035
+ fs.errors.DirectoryExpected: if ``src_path`` or one of its
1036
+ ancestors is not a directory.
1021
1037
1022
1038
"""
1023
1039
with self ._lock :
@@ -1617,13 +1633,16 @@ def hash(self, path, name):
1617
1633
Arguments:
1618
1634
path(str): A path on the filesystem.
1619
1635
name(str):
1620
- One of the algorithms supported by the hashlib module, e.g. `"md5"`
1636
+ One of the algorithms supported by the `hashlib` module,
1637
+ e.g. `"md5"` or `"sha256"`.
1621
1638
1622
1639
Returns:
1623
1640
str: The hex digest of the hash.
1624
1641
1625
1642
Raises:
1626
1643
fs.errors.UnsupportedHash: If the requested hash is not supported.
1644
+ fs.errors.ResourceNotFound: If ``path`` does not exist.
1645
+ fs.errors.FileExpected: If ``path`` exists but is not a file.
1627
1646
1628
1647
"""
1629
1648
self .validatepath (path )
0 commit comments