|
Safemotion Lib
|
Protected Member Functions | |
| str | _get_local_path (self, str path, **Any kwargs) |
| Union[IO[str], IO[bytes]] | _open (self, str path, str mode="r", int buffering=-1, Optional[str] encoding=None, Optional[str] errors=None, Optional[str] newline=None, bool closefd=True, Optional[Callable] opener=None, **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) |
Protected Member Functions inherited from fastreid.utils.file_io.PathHandler | |
| None | _check_kwargs (self, Dict[str, Any] kwargs) |
| List[str] | _get_supported_prefixes (self) |
Additional Inherited Members | |
Static Protected Attributes inherited from fastreid.utils.file_io.PathHandler | |
| bool | _strict_kwargs_check = True |
Handles paths that can be accessed using Python native system calls. This handler uses `open()` and `os.*` calls on the given path.
Definition at line 184 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 from fastreid.utils.file_io.PathHandler.
Definition at line 254 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 from fastreid.utils.file_io.PathHandler.
Definition at line 285 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 from fastreid.utils.file_io.PathHandler.
Definition at line 190 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 from fastreid.utils.file_io.PathHandler.
Definition at line 293 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 from fastreid.utils.file_io.PathHandler.
Definition at line 289 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 from fastreid.utils.file_io.PathHandler.
Definition at line 297 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 from fastreid.utils.file_io.PathHandler.
Definition at line 301 of file file_io.py.
|
protected |
Open a path.
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 works as follows:
* Binary files are buffered in fixed-size chunks; the size of
the buffer is chosen using a heuristic trying to determine the
underlying device’s “block size” and falling back on
io.DEFAULT_BUFFER_SIZE. On many systems, the buffer will
typically be 4096 or 8192 bytes long.
encoding (Optional[str]): the name of the encoding used to decode or
encode the file. This should only be used in text mode.
errors (Optional[str]): an optional string that specifies how encoding
and decoding errors are to be handled. This cannot be used in binary
mode.
newline (Optional[str]): controls how universal newlines mode works
(it only applies to text mode). It can be None, '', '\n', '\r',
and '\r\n'.
closefd (bool): If closefd is False and a file descriptor rather than
a filename was given, the underlying file descriptor will be kept
open when the file is closed. If a filename is given closefd must
be True (the default) otherwise an error will be raised.
opener (Optional[Callable]): A custom opener can be used by passing
a callable as opener. The underlying file descriptor for the file
object is then obtained by calling opener with (file, flags).
opener must return an open file descriptor (passing os.open as opener
results in functionality similar to passing None).
See https://docs.python.org/3/library/functions.html#open for details.
Returns:
file: a file-like object.
Reimplemented from fastreid.utils.file_io.PathHandler.
Definition at line 194 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 from fastreid.utils.file_io.PathHandler.
Definition at line 310 of file file_io.py.