You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/base.rst
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,11 +10,11 @@ All Filesystem objects inherit from this class.
10
10
11
11
.. autoclass:: fs.base.FS
12
12
:members:
13
-
13
+
14
14
fs.base.SubFS
15
15
-------------
16
16
17
-
A SubFS is an FS implementation that represents a directory on another Filesystem. When you use the :meth:`fs.base.FS.opendir` method it will return a SubFS instance. You should not need to instantiate a SubFS directly.
17
+
A SubFS is an FS implementation that represents a directory on another Filesystem. When you use the :meth:`~fs.base.FS.opendir` method it will return a SubFS instance. You should not need to instantiate a SubFS directly.
18
18
19
19
For example::
20
20
@@ -28,7 +28,7 @@ fs.base.NullFile
28
28
29
29
A NullFile is a file-like object with no functionality. It is used in situations where a file-like object is required but the caller doesn't have any data to read or write.
30
30
31
-
The :meth:`fs.base.FS.safeopen` method returns an NullFile instance, which can reduce error-handling code.
31
+
The :meth:`~fs.base.FS.safeopen` method returns an NullFile instance, which can reduce error-handling code.
32
32
33
33
For example, the following code may be written to append some text to a log file::
Copy file name to clipboardExpand all lines: docs/concepts.rst
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
Concepts
2
2
========
3
3
4
-
Working with PyFilesystem is generally easier than working with lower level interfaces, as long as you are aware these simple concepts.
4
+
Working with PyFilesystem is generally easier than working with lower level interfaces, as long as you are aware these simple concepts.
5
5
6
6
Sandboxing
7
7
----------
@@ -31,7 +31,7 @@ Fortunately we can isolate a single sub-directory with then :meth:`~fs.base.FS.o
31
31
32
32
bar_fs = foo_fs.opendir('bar')
33
33
34
-
This creates a completely new FS object that represents everything in the `foo/bar` directory. The root directory of `bar_fs` has been re-position, so that from `bar_fs`'s point of view, the readme.txt and photo.jpg files are in the root::
34
+
This creates a completely new FS object that represents everything in the `foo/bar` directory. The root directory of `bar_fs` has been re-positioned, so that from `bar_fs`'s point of view, the readme.txt and photo.jpg files are in the root::
35
35
36
36
--bar
37
37
|--readme.txt
@@ -45,7 +45,7 @@ PyFilesystem will catch any attempts to read outside of the root directory. For
45
45
Paths
46
46
-----
47
47
48
-
Paths used within an FS object use the same common format, regardless of the underlying file system it represents (or the platform it resides on).
48
+
Paths used within an FS object use the same common format, regardless of the underlying file system it represents (or the platform it resides on).
49
49
50
50
When working with paths in FS objects, keep in mind the following:
51
51
@@ -54,11 +54,11 @@ When working with paths in FS objects, keep in mind the following:
54
54
* Paths not beginning with a forward slash are relative
55
55
* A single dot means 'current directory'
56
56
* A double dot means 'previous directory'
57
-
57
+
58
58
Note that paths used by the FS interface will use this format, but the constructor or additional methods may not.
59
59
Notably the :mod:`~fs.osfs.OSFS` constructor which requires an OS path -- the format of which is platform-dependent.
60
60
61
-
There are many helpful functions for working with paths in the :mod:`fs.path` module.
61
+
There are many helpful functions for working with paths in the :mod:`~fs.path` module.
62
62
63
63
System Paths
64
64
++++++++++++
@@ -78,7 +78,7 @@ If you call :meth:`~fs.base.FS.getsyspath` on such FS objects you will either ge
78
78
Errors
79
79
------
80
80
81
-
PyFilesystem converts all exceptions to a common type, so that you need only write your exception handling code once. For example, if you try to open a file that doesn't exist, PyFilesystem will throw a :class:`fs.errors.ResourceNotFoundError` regardless of whether the filesystem is local, on a ftp server or in a zip file::
81
+
PyFilesystem converts all exceptions to a common type, so that you need only write your exception handling code once. For example, if you try to open a file that doesn't exist, PyFilesystem will throw a :class:`~fs.errors.ResourceNotFoundError` regardless of whether the filesystem is local, on a ftp server or in a zip file::
82
82
83
83
>>> from fs.osfs import OSFS
84
84
>>> root_fs = OSFS('/')
@@ -91,4 +91,4 @@ PyFilesystem converts all exceptions to a common type, so that you need only wri
fs.errors.ResourceNotFoundError: Resource not found: doesnotexist.txt
93
93
94
-
All PyFilesystem exceptions are derived from :class:`fs.errors.FSError`, so you may use that if you want to catch all possible filesystem related exceptions.
94
+
All PyFilesystem exceptions are derived from :class:`~fs.errors.FSError`, so you may use that if you want to catch all possible filesystem related exceptions.
The ``fs.expose`` module offers a number of ways of making an FS implementation available over an Internet connection, or to other processes on the system.
4
+
The ``fs.expose`` module offers a number of ways of making an FS implementation available over an Internet connection, or to other processes on the system.
5
5
6
6
7
7
FUSE
8
8
----
9
-
Makes an FS object available to other applications on the system. See :mod:`fs.expose.fuse`.
9
+
Makes an FS object available to other applications on the system. See :mod:`~fs.expose.fuse`.
10
10
11
11
Dokan
12
12
-----
13
-
Makes an FS object available to other applications on the system. See :mod:`fs.expose.dokan`.
13
+
Makes an FS object available to other applications on the system. See :mod:`~fs.expose.dokan`.
14
14
15
15
Secure FTP
16
16
----------
17
-
Makes an FS object available via Secure FTP. See :mod:`fs.expose.sftp`.
17
+
Makes an FS object available via Secure FTP. See :mod:`~fs.expose.sftp`.
18
18
19
19
XMLRPC
20
20
------
21
-
Makes an FS object available over XMLRPC. See :mod:`fs.expose.xmlrpc`
21
+
Makes an FS object available over XMLRPC. See :mod:`~fs.expose.xmlrpc`
22
22
23
23
Import Hook
24
24
-----------
25
-
Allows importing python modules from the files in an FS object. See :mod:`fs.expose.importhook`
25
+
Allows importing python modules from the files in an FS object. See :mod:`~fs.expose.importhook`
26
26
27
27
Django Storage
28
28
--------------
29
-
Connects FS objects to Django. See :mod:`fs.expose.django_storage`
29
+
Connects FS objects to Django. See :mod:`~fs.expose.django_storage`
Copy file name to clipboardExpand all lines: docs/getting_started.rst
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,9 +41,9 @@ Prerequisites
41
41
42
42
PyFilesystem requires at least **Python 2.6**. There are a few other dependencies if you want to use some of the more advanced filesystem interfaces, but for basic use all that is needed is the Python standard library.
43
43
44
-
* Boto (required for :mod:`fs.s3fs`) https://github.com/boto/boto
45
-
* Paramiko (required for :mod:`fs.sftpfs`) https://github.com/paramiko/paramiko
46
-
* wxPython (required for :mod:`fs.browsewin`) http://www.wxpython.org/
44
+
* Boto (required for :mod:`~fs.s3fs`) https://github.com/boto/boto
45
+
* Paramiko (required for :mod:`~fs.sftpfs`) https://github.com/paramiko/paramiko
46
+
* wxPython (required for :mod:`~fs.browsewin`) http://www.wxpython.org/
Copy file name to clipboardExpand all lines: docs/implementersguide.rst
+18-18Lines changed: 18 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,43 +1,43 @@
1
1
.. _implementers:
2
2
3
-
A Guide For Filesystem Implementers
3
+
A Guide For Filesystem Implementers
4
4
===================================
5
5
6
6
PyFilesystem objects are designed to be as generic as possible and still expose the full filesystem functionality.
7
-
With a little care, you can write a wrapper for your filesystem that allows it to work interchangeably with any of the built-in FS classes and tools.
7
+
With a little care, you can write a wrapper for your filesystem that allows it to work interchangeably with any of the built-in FS classes and tools.
8
8
9
-
To create a working PyFilesystem interface, derive a class from :py:class:`fs.base.FS` and implement the 9 :ref:`essential-methods`.
9
+
To create a working PyFilesystem interface, derive a class from :py:class:`~fs.base.FS` and implement the 9 :ref:`essential-methods`.
10
10
The base class uses these essential methods as a starting point for providing a lot of extra functionality,
11
11
but in some cases the default implementation may not be the most efficient.
12
12
For example, most filesystems have an atomic way of moving a file from one location to another without having to copy data,
13
13
whereas the default implementation of :meth:`~fs.base.FS.move` method must copy all the bytes in the source file to the destination file.
14
-
Any of the :ref:`non-essential-methods` may be overridden, but efficient custom versions of the following methods will have the greatest impact on performance:
14
+
Any of the :ref:`non-essential-methods` may be overridden, but efficient custom versions of the following methods will have the greatest impact on performance:
15
15
16
16
* :meth:`~fs.base.FS.copy` copy a file
17
17
* :meth:`~fs.base.FS.copydir` copy a directory
18
18
* :meth:`~fs.base.FS.exists` check if a file / directory exists
19
-
* :meth:`~fs.base.FS.getsyspath` get a system path for a given resource, if it exists
19
+
* :meth:`~fs.base.FS.getsyspath` get a system path for a given resource, if it exists
20
20
* :meth:`~fs.base.FS.move` move a file
21
21
* :meth:`~fs.base.FS.movedir` move a directory
22
22
23
23
For network based filesystems (i.e. where the physical data is pulled over a network),
24
24
there are a few methods which can reduce the number of round trips to the server,
25
25
if an efficient implementation is provided:
26
-
26
+
27
27
* :meth:`~fs.base.FS.listdirinfo` returns the directory contents and info dictionary in one call
28
-
* :meth:`~fs.base.FS.ilistdir` a generator version of :meth:`~fs.base.FS.listdir`
28
+
* :meth:`~fs.base.FS.ilistdir` a generator version of :meth:`~fs.base.FS.listdir`
29
29
* :meth:`~fs.base.FS.ilistdirinfo` a generator version of :meth:`~fs.base.FS.listdirinfo`
30
30
31
31
The generator methods (beginning with ``i``) are intended for use with filesystems that contain a lot of files,
32
32
where reading the directory in one go may be expensive.
33
33
34
34
Other methods in the :doc:`interface` are unlikely to require a non-default implementation,
35
-
but there is nothing preventing you from implementing them -- just be careful to use the same signature and replicate expected functionality.
35
+
but there is nothing preventing you from implementing them -- just be careful to use the same signature and replicate expected functionality.
36
36
37
37
Filesystem Errors
38
38
-----------------
39
39
40
-
With the exception of the constructor, FS methods should throw :class:`fs.errors.FSError` exceptions in preference to any implementation-specific exception classes,
40
+
With the exception of the constructor, FS methods should throw :class:`~fs.errors.FSError` exceptions in preference to any implementation-specific exception classes,
41
41
so that generic exception handling can be written.
42
42
The constructor *may* throw a non-FSError exception, if no appropriate FSError exists.
43
43
The rationale for this is that creating an FS interface may require specific knowledge,
@@ -53,7 +53,7 @@ and passes the original exception as an argument.::
Any code written to catch the generic error, can also retrieve the original exception if it contains additional information.
58
58
59
59
Thread Safety
@@ -75,7 +75,7 @@ Implementations are also free to reserve a dotted namespace notation for themsel
75
75
If you do this, please avoid generic terms as they may conflict with existing or future implementations.
76
76
For example ``"bobs_ftpfs.author"``, rather than ``"ftpfs.author"``.
77
77
78
-
If your meta values are static, i.e. they never change, then create a dictionary class attribute called ``_meta`` in your implementation that contains all the meta keys and values.
78
+
If your meta values are static, i.e. they never change, then create a dictionary class attribute called ``_meta`` in your implementation that contains all the meta keys and values.
79
79
The default ``getmeta`` implementation will pull the meta values from this dictionary.
80
80
81
81
.. _essential-methods:
@@ -94,29 +94,29 @@ The following methods are required for a minimal Filesystem interface:
94
94
* :meth:`~fs.base.FS.removedir` Remove an existing directory
95
95
* :meth:`~fs.base.FS.rename` Atomically rename a file or directory
96
96
* :meth:`~fs.base.FS.getinfo` Return information about the path e.g. size, mtime
97
-
97
+
98
98
99
99
.. _non-essential-methods:
100
100
101
101
Non - Essential Methods
102
102
-----------------------
103
103
104
-
The following methods have default implementations in :py:class:`fs.base.FS` and aren't required for a functional FS interface. They may be overridden if an alternative implementation can be supplied:
104
+
The following methods have default implementations in :py:class:`~fs.base.FS` and aren't required for a functional FS interface. They may be overridden if an alternative implementation can be supplied:
105
105
106
106
* :meth:`~fs.base.FS.copy` Copy a file to a new location
107
107
* :meth:`~fs.base.FS.copydir` Recursively copy a directory to a new location
108
108
* :meth:`~fs.base.FS.desc` Return a short descriptive text regarding a path
109
-
* :meth:`~fs.base.FS.exists` Check whether a path exists as file or directory
109
+
* :meth:`~fs.base.FS.exists` Check whether a path exists as file or directory
110
110
* :meth:`~fs.base.FS.listdirinfo` Get a directory listing along with the info dict for each entry
111
111
* :meth:`~fs.base.FS.ilistdir` Generator version of the listdir method
112
112
* :meth:`~fs.base.FS.ilistdirinfo` Generator version of the listdirinfo method
113
113
* :meth:`~fs.base.FS.getpathurl` Get an external URL at which the given file can be accessed, if possible
114
114
* :meth:`~fs.base.FS.getsyspath` Get a file's name in the local filesystem, if possible
115
115
* :meth:`~fs.base.FS.getmeta` Get the value of a filesystem meta value, if it exists
116
116
* :meth:`~fs.base.FS.getmmap` Gets an mmap object for the given resource, if supported
117
-
* :meth:`~fs.base.FS.hassyspath` Check if a path maps to a system path (recognized by the OS)
118
-
* :meth:`~fs.base.FS.haspathurl` Check if a path maps to an external URL
117
+
* :meth:`~fs.base.FS.hassyspath` Check if a path maps to a system path (recognized by the OS)
118
+
* :meth:`~fs.base.FS.haspathurl` Check if a path maps to an external URL
119
119
* :meth:`~fs.base.FS.hasmeta` Check if a filesystem meta value exists
120
-
* :meth:`~fs.base.FS.move` Move a file to a new location
121
-
* :meth:`~fs.base.FS.movedir` Recursively move a directory to a new location
120
+
* :meth:`~fs.base.FS.move` Move a file to a new location
121
+
* :meth:`~fs.base.FS.movedir` Recursively move a directory to a new location
122
122
* :meth:`~fs.base.FS.settimes` Sets the accessed and modified times of a path
Copy file name to clipboardExpand all lines: docs/utilities.rst
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,17 +7,17 @@ new FS implementations easier.
7
7
8
8
fs.path
9
9
-------
10
-
Contains many utility functions for manipulating filesystem paths. See :mod:`fs.path`.
10
+
Contains many utility functions for manipulating filesystem paths. See :mod:`~fs.path`.
11
11
12
12
fs.errors
13
13
---------
14
-
Contains all the standard error classes used by PyFilesystem, along with some useful error-handling decorators. See :mod:`fs.errors`.
14
+
Contains all the standard error classes used by PyFilesystem, along with some useful error-handling decorators. See :mod:`~fs.errors`.
15
15
16
16
fs.filelike
17
17
-----------
18
-
Takes care of a lot of the groundwork for implementing and manipulating objects that support Python's standard "file-like" interface. See :mod:`fs.filelike`.
18
+
Takes care of a lot of the groundwork for implementing and manipulating objects that support Python's standard "file-like" interface. See :mod:`~fs.filelike`.
19
19
20
20
fs.remote
21
21
---------
22
-
Contains useful functions and classes for implementing remote filesystems. See :mod:`fs.remote`.
22
+
Contains useful functions and classes for implementing remote filesystems. See :mod:`~fs.remote`.
0 commit comments