Folder reference
Constructor
Constructing these yourself is not recommended. You should make an
EdgeSession and access the .files
property, which
will return a Folder object at the root of the file system.
Methods
open
open(name, open_with=None) -> File, Folder, or object
Open an existing file or folder.
Parameters
- name (str)
The name of the file or folder to open. May be a delimited series of folder names like "/this/folder/file" and we will walk all folders and open the final one. - open_with (str)
Optional; name of an opener to use to open the object. Examples are "pandas" or "imageio", or "file" to get a file-like object giving access to the raw bytes. If not specified, an opener will be automatically picked for you.
Returns
The opened object. By default, the exact type depends on the combination of the opener
and file type. To disable this behavior and always get a plain File
instance,
set open_with="file"
.
If the object pointed to by name
is a folder, open_with
must not be set.
Raises
- NotFound: No object of the given
name
exists - ValueError: The given opener couldn't understand the file.
download
download(name, localpath=None)
Download to a local file. Currently, only downloading an individual file (not a folder) is supported.
Parameters
- name (str)
Name (or path, with "/" characters) of the remote object. - localpath (str) Download to this path locally. Defaults to the same basename in the current working directory.
upload
upload(destination, fp, overwrite=False)
Upload a file to this folder
Parameters
- destination (str)
The name (or path, with "/" characters) of the file to create in Edge. - fp (file-like)
A Python file-like object which provides a read() method, returning bytes. - overwrite (bool)
If True, any existing file will be overwritten. Default is False.
make_folder
make_folder(name) -> Folder
Make a new folder.
Parameters
- name (str)
The name (or path, with "/" characters) of the new folder.
Returns
Folder The new folder object.
list
list() -> list(str)
List all file and folder names in this folder. The order in which they are returned is undefined.
Returns
list(str) File and folder names.
list_files
list_files() -> list(str)
List only the names of files in this folder. The order in which they are returned is undefined.
Returns
list(str) File names only.
list_folders
list_folders() -> list(str)
List only the names of folders in this folder. The order in which they are returned is undefined.
Returns
list(str) Folder names only.
exists
exists(name) -> bool
Determine if a file or folder exists.
Parameters
- name (str)
The name (or path, with "/" characters) of the object to test.
Returns
bool Whether the object exists.
delete
delete(object)
Delete a file or folder, given a name (or path). No error is raised if the object does not exist.
Parameters
- object (str)
Name (or path, with "/" components) of object to delete.
move
move(source, destination)
Move a file or folder to a new location.
Parameters
- source (str)
The name (or path, with "/" characters) of the file or folder to move. - destination (str)
The path to which the file or folder will be moved.
rename
rename(source, name)
Rename a file, while keeping it in the same folder.
Parameters
- source (str)
The name (not path) of the file or folder to rename. - name (str)
The new name for the file or folder.