Commit 4ded92bc by willmcgugan

Lots of new docs

parent b4c092f0
...@@ -85,4 +85,4 @@ PyFilesystem converts all exceptions to a common type, so that you need only wri ...@@ -85,4 +85,4 @@ PyFilesystem converts all exceptions to a common type, so that you need only wri
return open(self.getsyspath(path), mode, kwargs.get("buffering", -1)) return open(self.getsyspath(path), mode, kwargs.get("buffering", -1))
fs.errors.ResourceNotFoundError: Resource not found: doesnotexist.txt fs.errors.ResourceNotFoundError: Resource not found: doesnotexist.txt
All PyFilesystem exceptions are derived from ``fs.errors.FSError``, so you may use that if you want to catch all possible exceptions. All PyFilesystem exceptions are derived from :class:`fs.errors.FSError`, so you may use that if you want to catch all possible exceptions.
...@@ -28,6 +28,12 @@ OS ...@@ -28,6 +28,12 @@ OS
-- --
An interface to the OS Filesystem. See :mod:`fs.osfs` An interface to the OS Filesystem. See :mod:`fs.osfs`
RPCFS (Remote Procedure Call)
-----------------------------
An interface to a file-system serverd over XML RPC, See :mod:`fs.rpcfs` and :mod:`fs.expose.xmlrpc`
Secure FTP (Secure FTP) Secure FTP (Secure FTP)
----------------------- -----------------------
A secure FTP filesystem. See :mod:`fs.sftpfs` A secure FTP filesystem. See :mod:`fs.sftpfs`
......
...@@ -37,7 +37,8 @@ Code Documentation ...@@ -37,7 +37,8 @@ Code Documentation
multifs.rst multifs.rst
osfs.rst osfs.rst
path.rst path.rst
rpcfsfs.rst remote.rst
rpcfs.rst
s3fs.rst s3fs.rst
sftpfs.rst sftpfs.rst
tempfs.rst tempfs.rst
......
Filesystem Interface Filesystem Interface
==================== ====================
It requires a relatively small number of methods to implement a working Filesystem object. It requires a relatively small number of methods to implement a working FS object.
If you are looking to implement a working FS object, derive a class from fs.base.FS and implement the essential methods (below). Be sure to convert all exceptions to instances of :class:`fs.errors.FSError`.
It may also be worthwhile implementing some of the non-essential methods, as the default implementations may not be optimal. For example, the method :meth:`fs.base.FS.move` is implemeneted as a file copy followed by a delete, but may filesystems can move a file without copying data.
If the filesystem you are implementing maps path to the native filesystem, be sure to implement `getsyspath`. Doing so will improve performance, especialy when copying / moving files between FS objects.
Essential Methods Essential Methods
----------------- -----------------
...@@ -40,7 +45,7 @@ The following methods have default implementations in fs.base.FS and aren't requ ...@@ -40,7 +45,7 @@ The following methods have default implementations in fs.base.FS and aren't requ
Utility Methods Utility Methods
--------------- ---------------
The following members have implementations in fs.base.FS but will probably never need a non-default implementation, although there is nothing to prevent a derived class from implementing these: The following members have implementations in fs.base.FS but will probably never require a non-default implementation, although there is nothing to prevent a derived class from implementing these:
* :meth:`~fs.base.FS.createfile` Create a file with data * :meth:`~fs.base.FS.createfile` Create a file with data
* :meth:`~fs.base.FS.getcontents` Returns the contents of a file as a string * :meth:`~fs.base.FS.getcontents` Returns the contents of a file as a string
......
...@@ -5,5 +5,5 @@ PyFilesystem is a Python module that provides a common interface to any filesyst ...@@ -5,5 +5,5 @@ PyFilesystem is a Python module that provides a common interface to any filesyst
Think of PyFilesystem (FS) objects as the next logical step to Python's `file` objects. Just as file-like objects abstract a single file, FS objects abstract the whole filesystem by providing a common interface to operations such as reading directories, getting file information, opening/copying/deleting files etc. Think of PyFilesystem (FS) objects as the next logical step to Python's `file` objects. Just as file-like objects abstract a single file, FS objects abstract the whole filesystem by providing a common interface to operations such as reading directories, getting file information, opening/copying/deleting files etc.
Even if you only want to work with the local filesystem, FS simplifies a number of common operations and reduces the chance of error. A typical problem when working with the filesystem is writing a function that changes the current working directory, but doesn't set it back. This can be a tricky bug to identify since the problem will only manifest itself when you next try to work with the filesystem. PyFilesytem doesn't have this problem, because it doesn't modify the current working directory. It is also possible to restrict any file operations to a specific directory, which elliminates the possibility of accidently overwriting / deleting files outside of the specified directory. Even if you only want to work with the local filesystem, PyFilesystem simplifies a number of common operations and reduces the chance of error.
.. automodule:: fs.mountfs .. automodule:: fs.mountfs
.. automethod:: fs.mountfs.MountFS.mount(self, path, fs)
.. automethod:: fs.mountfs.MountFS.mountdir(self, path, fs) .. automethod:: fs.mountfs.MountFS.mountdir(self, path, fs)
.. automethod:: fs.mountfs.MountFS.mountfile(self, path, open_callable=None, info_callable=None) .. automethod:: fs.mountfs.MountFS.mountfile(self, path, open_callable=None, info_callable=None)
.. automethod:: fs.mountfs.MountFS.unmount(path) .. automethod:: fs.mountfs.MountFS.unmount(path)
\ No newline at end of file
.. automodule:: fs.wrapfs
:members:
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment