|
Safemotion Lib
|
Protected Member Functions | |
| None | _check_kwargs (self, Dict[str, Any] kwargs) |
| List[str] | _get_supported_prefixes (self) |
| str | _get_local_path (self, str path, **Any kwargs) |
| Union[IO[str], IO[bytes]] | _open (self, str path, str mode="r", int buffering=-1, **Any kwargs) |
| bool | _copy (self, str src_path, str dst_path, bool overwrite=False, **Any kwargs) |
| bool | _exists (self, str path, **Any kwargs) |
| bool | _isfile (self, str path, **Any kwargs) |
| bool | _isdir (self, str path, **Any kwargs) |
| List[str] | _ls (self, str path, **Any kwargs) |
| None | _mkdirs (self, str path, **Any kwargs) |
| None | _rm (self, str path, **Any kwargs) |
Static Protected Attributes | |
| bool | _strict_kwargs_check = True |
PathHandler is a base class that defines common I/O functionality for a URI protocol. It routes I/O for a generic URI which may look like "protocol://*" or a canonical filepath "/foo/bar/baz".
Definition at line 40 of file file_io.py.
|
protected |
Checks if the given arguments are empty. Throws a ValueError if strict
kwargs checking is enabled and args are non-empty. If strict kwargs
checking is disabled, only a warning is logged.
Args:
kwargs (Dict[str, Any])
Definition at line 49 of file file_io.py.
|
protected |
Copies a source path to a destination path.
Args:
src_path (str): A URI supported by this PathHandler
dst_path (str): A URI supported by this PathHandler
overwrite (bool): Bool flag for forcing overwrite of existing file
Returns:
status (bool): True on success
Reimplemented in fastreid.utils.file_io.NativePathHandler.
Definition at line 107 of file file_io.py.
|
protected |
Checks if there is a resource at the given URI.
Args:
path (str): A URI supported by this PathHandler
Returns:
bool: true if the path exists
Reimplemented in fastreid.utils.file_io.NativePathHandler.
Definition at line 125 of file file_io.py.
|
protected |
Get a filepath which is compatible with native Python I/O such as `open`
and `os.path`.
If URI points to a remote resource, this function may download and cache
the resource to local disk. In this case, this function is meant to be
used with read-only resources.
Args:
path (str): A URI supported by this PathHandler
Returns:
local_path (str): a file path which exists on the local file system
Reimplemented in fastreid.utils.file_io.NativePathHandler.
Definition at line 74 of file file_io.py.
|
protected |
Returns:
List[str]: the list of URI prefixes this PathHandler can support
Definition at line 67 of file file_io.py.
|
protected |
Checks if the resource at the given URI is a directory.
Args:
path (str): A URI supported by this PathHandler
Returns:
bool: true if the path is a directory
Reimplemented in fastreid.utils.file_io.NativePathHandler.
Definition at line 145 of file file_io.py.
|
protected |
Checks if the resource at the given URI is a file.
Args:
path (str): A URI supported by this PathHandler
Returns:
bool: true if the path is a file
Reimplemented in fastreid.utils.file_io.NativePathHandler.
Definition at line 135 of file file_io.py.
|
protected |
List the contents of the directory at the provided URI.
Args:
path (str): A URI supported by this PathHandler
Returns:
List[str]: list of contents in given path
Reimplemented in fastreid.utils.file_io.NativePathHandler.
Definition at line 155 of file file_io.py.
|
protected |
Recursive directory creation function. Like mkdir(), but makes all
intermediate-level directories needed to contain the leaf directory.
Similar to the native `os.makedirs`.
Args:
path (str): A URI supported by this PathHandler
Reimplemented in fastreid.utils.file_io.NativePathHandler.
Definition at line 165 of file file_io.py.
|
protected |
Open a stream to a URI, similar to the built-in `open`.
Args:
path (str): A URI supported by this PathHandler
mode (str): Specifies the mode in which the file is opened. It defaults
to 'r'.
buffering (int): An optional integer used to set the buffering policy.
Pass 0 to switch buffering off and an integer >= 1 to indicate the
size in bytes of a fixed-size chunk buffer. When no buffering
argument is given, the default buffering policy depends on the
underlying I/O implementation.
Returns:
file: a file-like object.
Reimplemented in fastreid.utils.file_io.NativePathHandler.
Definition at line 88 of file file_io.py.
|
protected |
Remove the file (not directory) at the provided URI.
Args:
path (str): A URI supported by this PathHandler
Reimplemented in fastreid.utils.file_io.NativePathHandler.
Definition at line 175 of file file_io.py.
|
staticprotected |
Definition at line 47 of file file_io.py.