Write data to a given ``filepath`` with 'w' mode. Note: ``write_text`` will create a directory if the directory of ``filepath`` does not exist. Args: obj (str): Data to be written. filepath (str or Path): Path to write data.
(obj: str, uri: str, encoding: str = 'utf-8')
| 305 | |
| 306 | @staticmethod |
| 307 | def write_text(obj: str, uri: str, encoding: str = 'utf-8') -> None: |
| 308 | """Write data to a given ``filepath`` with 'w' mode. |
| 309 | |
| 310 | Note: |
| 311 | ``write_text`` will create a directory if the directory of |
| 312 | ``filepath`` does not exist. |
| 313 | |
| 314 | Args: |
| 315 | obj (str): Data to be written. |
| 316 | filepath (str or Path): Path to write data. |
| 317 | encoding (str): The encoding format used to open the ``filepath``. |
| 318 | Default: 'utf-8'. |
| 319 | """ |
| 320 | storage = File._get_storage(uri) |
| 321 | return storage.write_text(obj, uri) |
| 322 | |
| 323 | @contextlib.contextmanager |
| 324 | def as_local_path(uri: str) -> Generator[Union[str, Path], None, None]: |