MCPcopy Index your code
hub / github.com/tensorflow/datasets / add_file

Method add_file

tensorflow_datasets/testing/test_utils.py:203–209  ·  view source on GitHub ↗

Add a file, creating all parent directories.

(self, path, content=None)

Source from the content-addressed store, hash-verified

201 return out
202
203 def add_file(self, path, content=None) -> None:
204 """Add a file, creating all parent directories."""
205 path = os.fspath(path)
206 content = content or f'Content of {path}'
207 fpath = self._to_tmp(path)
208 fpath.parent.mkdir(parents=True, exist_ok=True) # pytype: disable=attribute-error
209 fpath.write_text(content) # pytype: disable=attribute-error
210
211 def read_file(self, path) -> str:
212 return self._to_tmp(path).read_text() # pytype: disable=attribute-error

Calls 1

_to_tmpMethod · 0.95

Tested by

no test coverage detected