Utilities#

cxplain.util.get_resource_string(path: str, decode: bool = True) str | bytes#

Load a package resource, such as a file within the package.

Parameters:
  • path – The path to the resource file, starting at the root of the current module (e.g., ‘res/default.conf’). Must be a string, not a Path object.

  • decode – If True, decode the file contents as a string; otherwise, return the contents as bytes.

Returns:

The contents of the resource file, either as a string or bytes.

Return type:

Union[str, bytes]