epublib.resources.create module¶
- create_resource(
- file: IO[bytes] | bytes,
- info: ZipInfo | str | Path,
- media_type: MediaType | str | None = None,
- is_nav: bool = False,
Create a new resource outside of any EPUB.
- Parameters:
file – A file-like object or bytes representing the resource’s data.
info – Metadata about the resource, either as a ZipInfo object, a string or Path object representing a filename.
media_type – The media type of the resource. If None, it will be inferred from the filename in info.
is_nav – Whether this resource is the navigation document.
- Returns:
An instance of a subclass of Resource corresponding to the arguments.
- Raises:
If is_nav is True but the media type is not XHTML or SVG. - If the media type is not provided and cannot be determined from the filename.
- create_resource_from_path(
- path: str | Path,
- info: ZipInfo | str | Path | None = None,
- media_type: MediaType | str | None = None,
- is_nav: bool = False,
Create a new resource from existing file. The resource is not related to EPUB.
- Parameters:
file – A file-like object or bytes representing the resource’s data.
info – Metadata about the resource, either as a ZipInfo object, a string or Path object representing a filename.
media_type – The media type of the resource. If None, it will be inferred from the filename in info.
is_nav – Whether this resource is the navigation document.
- Returns:
An instance of a subclass of Resource corresponding to the arguments.
- Raises:
If is_nav is True but the media type is not XHTML or SVG. - If the media type is not provided and cannot be determined from the filename.