project_config.tree module

File system tree API.

project_config.tree.cache_file(fpath: str, serializers: Optional[list[str]] = None, forbid_serializers: Optional[Iterable[str]] = None, ignore_serialization_errors: bool = False) None[source]

Cache the file content and its serialized version.

If the file is local, the cache key is the file path, its last modification time and root directory name. If the file is remote, the cache key is the file URL.

Parameters:
  • fpath (str) – The file path or URL.

  • serializers (Iterable[str], optional) – The serializers to use.

  • forbid_serializers (Iterable[str], optional) – The serializers to forbid. Only makes sense for serializers guessed for the file.

  • ignore_serialization_errors (bool, optional) – If True, ignore serialization errors.

project_config.tree.cached_local_file(fpath: str, serializer: Optional[str] = None) Any[source]

Get the cached file content.

Parameters:
  • fpath (str) – The file path.

  • serializer (str, optional) – The serializer to use reading the file.

Returns:

The cached file content.

Return type:

str

project_config.tree.edit_local_file(fpath: str, new_content: Any) bool[source]

Edit the local file and update the cache.

Parameters:
  • fpath (str) – The file path.

  • new_content (Any) – The new object to serialize.

project_config.tree.fetch_remote_file(uri: str, serializer: Optional[str] = None) Any[source]

Fetch the remote file content.

Parameters:
  • uri (str) – The file uri.

  • serializer (str, optional) – The serializer to use.