airfs.os
This namespace is equivalent to the Python standard library os namespace.
Following functions are replaced by Airfs functions:
- airfs.os.listdir(path='.')
Return a list containing the names of the entries in the directory given by path.
Follow symlinks if any.
Equivalent to “os.listdir”.
New in version 1.2.0.
- Parameters:
path (path-like object) – Path or URL.
- Returns:
Entries names.
- Return type:
list of str
- airfs.os.lstat(path, *, dir_fd=None)
Get the status of a file or a file descriptor.
Perform the equivalent of a “lstat()” system call on the given path.
Equivalent to “os.lstat”.
On storage object, may return extra storage-specific attributes in “os.stat_result”.
New in version 1.2.0.
- Parameters:
path (path-like object) – Path or URL.
dir_fd (int) – directory descriptors; see the os.rmdir() description for how it is interpreted. Not supported on storage objects.
- Returns:
stat result.
- Return type:
os.stat_result
- airfs.os.makedirs(name, mode=511, exist_ok=False)
Super-mkdir; create a leaf directory and all intermediate ones.
Works like mkdir, except that any intermediate path segment (not just the rightmost) will be created if it does not exist.
Equivalent to “os.makedirs”.
New in version 1.1.0.
- Parameters:
name (path-like object) – Path or URL.
mode (int) – The mode parameter is passed to os.mkdir(); see the os.mkdir() description for how it is interpreted. Not supported on storage objects.
exist_ok (bool) – Don’t raise error if target directory already exists.
- Raises:
FileExistsError – if exist_ok is False and if the target directory already exists.
- airfs.os.mkdir(path, mode=511, *, dir_fd=None)
Create a directory named path with numeric mode.
Equivalent to “os.mkdir”.
New in version 1.1.0.
- Parameters:
path (path-like object) – Path or URL.
mode (int) – The mode parameter is passed to os.mkdir(); see the os.mkdir() description for how it is interpreted. Not supported on storage objects.
dir_fd (int) – directory descriptors; see the os.remove() description for how it is interpreted. Not supported on storage objects.
- Raises:
FileExistsError – Directory already exists.
FileNotFoundError – Parent directory does not exist.
- airfs.os.readlink(path, *, dir_fd=None)
Return a string representing the path to which the symbolic link points.
The result may be either an absolute or relative pathname; if it is relative, it may be converted to an absolute pathname using os.path.join(os.path.dirname(path), result).
If the path is a string object (directly or indirectly through a PathLike interface), the result will also be a string object, and the call may raise a UnicodeDecodeError. If the path is a bytes object (directly or indirectly), the result will be a bytes object.
Equivalent to “os.readlink”.
New in version 1.5.0.
- Parameters:
path (path-like object) – Path or URL.
dir_fd (int) – directory descriptors; see the os.readlink() description for how it is interpreted. Not supported on storage objects.
- airfs.os.remove(path, *, dir_fd=None)
Remove a file.
Equivalent to “os.remove” and “os.unlink”.
New in version 1.2.0.
- Parameters:
path (path-like object) – Path or URL.
dir_fd (int) – directory descriptors; see the os.remove() description for how it is interpreted. Not supported on storage objects.
- airfs.os.rmdir(path, *, dir_fd=None)
Remove a directory.
Equivalent to “os.rmdir”.
New in version 1.2.0.
- Parameters:
path (path-like object) – Path or URL.
dir_fd (int) – directory descriptors; see the os.rmdir() description for how it is interpreted. Not supported on storage objects.
- airfs.os.scandir(path='.')
Iterate over a directory.
Return an iterator of os.DirEntry objects corresponding to the entries in the directory given by path. The entries are yielded in arbitrary order, and the special entries ‘.’ and ‘..’ are not included.
Equivalent to “os.scandir”.
New in version 1.2.0.
- Parameters:
path (path-like object) – Path or URL. If the path is of type bytes (directly or indirectly through the PathLike interface), the type of the name and path attributes of each os.DirEntry will be bytes; in all other circumstances, they will be of type str.
- Returns:
Entries information.
- Return type:
Generator of os.DirEntry
- airfs.os.stat(path, *, dir_fd=None, follow_symlinks=True)
Get the status of a file or a file descriptor.
Perform the equivalent of a “stat()” system call on the given path.
Equivalent to “os.stat”.
On storage object, may return extra storage-specific attributes in “os.stat_result”.
New in version 1.2.0.
- Parameters:
path (path-like object) – Path or URL.
dir_fd (int) – directory descriptors; see the os.rmdir() description for how it is interpreted. Not supported on storage objects.
follow_symlinks (bool) – Follow symlinks.
- Returns:
stat result.
- Return type:
os.stat_result
- airfs.os.unlink(path, *, dir_fd=None)
Remove a file.
Equivalent to “os.remove” and “os.unlink”.
New in version 1.2.0.
- Parameters:
path (path-like object) – Path or URL.
dir_fd (int) – directory descriptors; see the os.remove() description for how it is interpreted. Not supported on storage objects.
See also
- “os” standard library documentation
Python standard library documentation, for functions that are not documented here.