def rename(src: PathType, dst: PathType, overwrite: bool = False) -> None: try: tf.io.gfile.rename(src, dst, overwrite=overwrite) except tf.errors.NotFoundError as e: raise filesystem.NotFoundError() from e
def rename(src: PathType, dst: PathType, overwrite: bool = False) -> None: if not overwrite and os.path.exists(dst): raise OSError(( 'Destination path %r already exists and argument `overwrite` is ' 'false.') % dst) try: os.rename(src, dst) except FileNotFoundError as e: raise filesystem.NotFoundError() from e
def walk( top: PathType, topdown: bool = True, onerror: Callable[..., None] = None ) -> Iterable[Tuple[PathType, List[PathType], List[PathType]]]: try: yield from os.walk(top, topdown=topdown, onerror=onerror) except FileNotFoundError as e: raise filesystem.NotFoundError() from e
def walk( top: PathType, topdown: bool = True, onerror: Optional[Callable[..., None]] = None ) -> Iterable[Tuple[PathType, List[PathType], List[PathType]]]: try: yield from tf.io.gfile.walk(top, topdown=topdown, onerror=onerror) except tf.errors.NotFoundError as e: raise filesystem.NotFoundError() from e
def rmtree(path: PathType) -> None: try: tf.io.gfile.rmtree(path) except tf.errors.NotFoundError as e: raise filesystem.NotFoundError() from e
def listdir(path: PathType) -> List[PathType]: try: return tf.io.gfile.listdir(path) except tf.errors.NotFoundError as e: raise filesystem.NotFoundError() from e
def stat(path: PathType) -> Any: try: return tf.io.gfile.stat(path) except tf.errors.NotFoundError as e: raise filesystem.NotFoundError() from e
def remove(path: PathType) -> None: try: os.remove(path) except FileNotFoundError as e: raise filesystem.NotFoundError() from e
def listdir(path: PathType) -> List[PathType]: try: return os.listdir(path) except FileNotFoundError as e: raise filesystem.NotFoundError() from e
def open(name: PathType, mode: Text = 'r') -> Any: try: return open(name, mode=mode) except FileNotFoundError as e: raise filesystem.NotFoundError() from e
def stat(path: PathType) -> Any: try: return os.stat(path) except FileNotFoundError as e: raise filesystem.NotFoundError() from e
def rmtree(path: PathType) -> None: try: shutil.rmtree(path) except FileNotFoundError as e: raise filesystem.NotFoundError() from e