Ejemplo n.º 1
0
 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
Ejemplo n.º 2
0
 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
Ejemplo n.º 3
0
 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
Ejemplo n.º 4
0
 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
Ejemplo n.º 5
0
 def rmtree(path: PathType) -> None:
     try:
         tf.io.gfile.rmtree(path)
     except tf.errors.NotFoundError as e:
         raise filesystem.NotFoundError() from e
Ejemplo n.º 6
0
 def listdir(path: PathType) -> List[PathType]:
     try:
         return tf.io.gfile.listdir(path)
     except tf.errors.NotFoundError as e:
         raise filesystem.NotFoundError() from e
Ejemplo n.º 7
0
 def stat(path: PathType) -> Any:
     try:
         return tf.io.gfile.stat(path)
     except tf.errors.NotFoundError as e:
         raise filesystem.NotFoundError() from e
Ejemplo n.º 8
0
 def remove(path: PathType) -> None:
     try:
         os.remove(path)
     except FileNotFoundError as e:
         raise filesystem.NotFoundError() from e
Ejemplo n.º 9
0
 def listdir(path: PathType) -> List[PathType]:
     try:
         return os.listdir(path)
     except FileNotFoundError as e:
         raise filesystem.NotFoundError() from e
Ejemplo n.º 10
0
 def open(name: PathType, mode: Text = 'r') -> Any:
     try:
         return open(name, mode=mode)
     except FileNotFoundError as e:
         raise filesystem.NotFoundError() from e
Ejemplo n.º 11
0
 def stat(path: PathType) -> Any:
     try:
         return os.stat(path)
     except FileNotFoundError as e:
         raise filesystem.NotFoundError() from e
Ejemplo n.º 12
0
 def rmtree(path: PathType) -> None:
     try:
         shutil.rmtree(path)
     except FileNotFoundError as e:
         raise filesystem.NotFoundError() from e