Filesystem InterfaceΒΆ
The following methods are available in all PyFilesystem implementation:
close()
Close the filesystem and free any resourcescopy()
Copy a file to a new locationcopydir()
Recursively copy a directory to a new locationcachehint()
Permit implementation to use aggressive caching for performance reasonscreatefile()
Create a file with datadesc()
Return a short descriptive text regarding a pathexists()
Check whether a path exists as file or directorygetcontents()
Returns the contents of a file as a stringgetinfo()
Return information about the path e.g. size, mtimegetmeta()
Get the value of a filesystem meta value, if it existsgetmmap()
Gets an mmap object for the given resource, if supportedgetpathurl()
Get an external URL at which the given file can be accessed, if possiblegetsize()
Returns the number of bytes used for a given file or directorygetsyspath()
Get a file’s name in the local filesystem, if possiblehasmeta()
Check if a filesystem meta value existshaspathurl()
Check if a path maps to an external URLhassyspath()
Check if a path maps to a system path (recognized by the OS)ilistdir()
Generator version of thelistdir()
methodilistdirinfo()
Generator version of thelistdirinfo()
methodisdir()
Check whether a path exists and is a directoryisdirempty()
Checks if a directory contains no filesisfile()
Check whether the path exists and is a filelistdir()
List the contents of a directorylistdirinfo()
Get a directory listing along with the info dict for each entrymakedir()
Create a new directorymakeopendir()
Make a directory and returns the FS object that represents itmove()
Move a file to a new locationmovedir()
Recursively move a directory to a new locationopen()
Opens a file for read/writingopendir()
Opens a directory and returns a FS object that represents itremove()
Remove an existing fileremovedir()
Remove an existing directoryrename()
Atomically rename a file or directorysafeopen()
Likeopen()
but returns aNullFile
if the file could not be openedsetcontents()
Sets the contents of a file as a string or file-like objectsetcontents_async()
Sets the contents of a file asynchronouslysettimes()
Sets the accessed and modified times of a pathtree()
Display an ascii rendering of the directory structurewalk()
Likelistdir()
but descends in to sub-directorieswalkdirs()
Returns an iterable of paths to sub-directorieswalkfiles()
Returns an iterable of file paths in a directory, and its sub-directories
See FS
for the method signature and full details.
If you intend to implement an FS object, see A Guide For Filesystem Implementers.