Skip to content

Commit

Permalink
add {read,write}_{text,bytes} api (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
skshetry authored Oct 20, 2022
1 parent 9a443ba commit afdc955
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/dvc_objects/fs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,39 @@ def tail(self, path: AnyFSPath, size: int = 1024) -> bytes:
def pipe_file(self, path: AnyFSPath, value: bytes, **kwargs: Any) -> None:
return self.fs.pipe_file(path, value, **kwargs)

write_bytes = pipe_file
read_bytes = cat_file

def read_text(
self,
path: AnyFSPath,
encoding: str = None,
errors: str = None,
newline: str = None,
**kwargs: Any,
) -> str:
return self.fs.read_text(
path, encoding=encoding, errors=errors, newline=newline, **kwargs
)

def write_text(
self,
path: AnyFSPath,
value: str,
encoding: str = None,
errors: str = None,
newline: str = None,
**kwargs: Any,
) -> None:
self.fs.write_text(
path,
value,
encoding=encoding,
errors=errors,
newline=newline,
**kwargs,
)

def pipe(
self,
path: Union[AnyFSPath, Dict[AnyFSPath, bytes]],
Expand Down

0 comments on commit afdc955

Please sign in to comment.