MCPcopy Create free account
hub / github.com/modelscope/FunASR / write_text

Method write_text

funasr/download/file.py:384–398  ·  view source on GitHub ↗

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")

Source from the content-addressed store, hash-verified

382
383 @staticmethod
384 def write_text(obj: str, uri: str, encoding: str = "utf-8") -> None:
385 """Write data to a given ``filepath`` with 'w' mode.
386
387 Note:
388 ``write_text`` will create a directory if the directory of
389 ``filepath`` does not exist.
390
391 Args:
392 obj (str): Data to be written.
393 filepath (str or Path): Path to write data.
394 encoding (str): The encoding format used to open the ``filepath``.
395 Default: 'utf-8'.
396 """
397 storage = File._get_storage(uri)
398 return storage.write_text(obj, uri)
399
400 @contextlib.contextmanager
401 def as_local_path(uri: str) -> Generator[Union[str, Path], None, None]:

Calls 1

_get_storageMethod · 0.45