File: //home/arjun/projects/env/lib/python3.10/site-packages/docx/parts/__pycache__/story.cpython-310.pyc
o
$we� � @ s� d Z ddlmZ ddlmZmZmZ ddlmZ ddl
mZ ddlm
Z
ddlmZmZ erFddlmZ dd lmZ dd
lmZ ddlmZ G dd
� d
e�ZdS )z |StoryPart| and related objects.� )�annotations)�IO�
TYPE_CHECKING�Tuple)�RELATIONSHIP_TYPE)�XmlPart)� CT_Inline)�Length�lazyproperty)�
WD_STYLE_TYPE)�Image)�DocumentPart)� BaseStylec @ sZ e Zd ZdZd dd�Zd!d
d�Zd"dd�Z d#d$dd�Zed%dd��Z e
d&dd��ZdS )'� StoryPartz�Base class for story parts.
A story part is one that can contain textual content, such as the document-part and
header or footer parts. These all share content behaviors like `.paragraphs`,
`.add_paragraph()`, `.add_table()` etc.
�image_descriptor�str | IO[bytes]�return�Tuple[str, Image]c C s4 | j }|dus J �|�|�}| �|tj�}||jfS )a| Return (rId, image) pair for image identified by `image_descriptor`.
`rId` is the str key (often like "rId7") for the relationship between this story
part and the image part, reused if already present, newly created if not.
`image` is an |Image| instance providing access to the properties of the image,
such as dimensions and image type.
N)�_package�get_or_add_image_part� relate_to�RT�IMAGE�image)�selfr �package�
image_part�rId� r �I/home/arjun/projects/env/lib/python3.10/site-packages/docx/parts/story.py�get_or_add_image s
zStoryPart.get_or_add_image�style_id�
str | None�
style_typer r c C � | j �||�S )z�Return the style in this document matching `style_id`.
Returns the default style for `style_type` if `style_id` is |None| or does not
match a defined style of `style_type`.
)�_document_part� get_style)r r! r# r r r r&