ó
    ‰*£hA#  ã                  óØ   • S r SSKJr  SSKJrJrJrJr  SSKJ	r	  SSK
Jr  SSKJr  SSKJr  SSKJr  SS	KJr  \(       a  SS
KJr  SSKJr   " S S5      r " S S5      r " S S\5      rg)zAOpen Packaging Convention (OPC) objects related to package parts.é    )Úannotations)ÚTYPE_CHECKINGÚCallableÚTypeÚcast)Úserialize_part_xml)ÚPackURI)ÚRelationships)Úcls_method_fn©Ú	parse_xml)Úlazyproperty)ÚBaseOxmlElement)ÚPackagec                  ó6  ^ • \ rS rSrSr  S       SU 4S jjjrS rS r\SS j5       r	\S 5       r
SS jr\SS	 j5       rSSS
 jjr\S 5       r\S 5       r\R"                  SS j5       rSS jrSSS jjr\S 5       r\S 5       rSS jrS S jrSrU =r$ )!ÚParté   zšBase class for package parts.

Provides common properties and methods, but intended to be subclassed in client code
to implement specific part behaviors.
c                óZ   >• [         [        U ]  5         Xl        X l        X0l        X@l        g ©N)Úsuperr   Ú__init__Ú	_partnameÚ_content_typeÚ_blobÚ_package)ÚselfÚpartnameÚcontent_typeÚblobÚpackageÚ	__class__s        €ÚJ/home/mande/repo/quber/.venv/lib/python3.13/site-packages/docx/opc/part.pyr   ÚPart.__init__   s'   ø€ ô 	Œd�DÑ"Ô$Ø!ŒØ)ÔØŒ
Ø�ó    c                ó   • g)z”Entry point for post-unmarshaling processing, for example to parse the part
XML.

May be overridden by subclasses without forwarding call to super.
N© ©r   s    r"   Úafter_unmarshalÚPart.after_unmarshal)   ó   € ð 	r$   c                ó   • g)z£Entry point for pre-serialization processing, for example to finalize part
naming if necessary.

May be overridden by subclasses without forwarding call to super.
Nr&   r'   s    r"   Úbefore_marshalÚPart.before_marshal3   r*   r$   c                ó,   • U R                   =(       d    S$ )z Contents of this package part as a sequence of bytes.

May be text or binary. Intended to be overridden by subclasses. Default behavior
is to return load blob.
r$   )r   r'   s    r"   r   Ú	Part.blob=   s   € ð �z‰z× ˜SÐ r$   c                ó   • U R                   $ )zContent type of this part.)r   r'   s    r"   r   ÚPart.content_typeF   s   € ð ×!Ñ!Ð!r$   c                óJ   • U R                  U5      S:  a  U R                  U	 gg)zšRemove the relationship identified by `rId` if its reference count is less
than 2.

Relationships with a reference count of 0 are implicit relationships.
é   N)Ú_rel_ref_countÚrels©r   ÚrIds     r"   Údrop_relÚPart.drop_relK   s'   € ð ×Ñ˜sÓ# aÓ'Ø—	‘	˜#‘ð (r$   c                ó   • U " XX45      $ r   r&   )Úclsr   r   r   r    s        r"   ÚloadÚ	Part.loadT   s   € á�8¨4Ó9Ð9r$   c                ó:   • U R                   R                  XX45      $ )av  Return newly added |_Relationship| instance of `reltype`.

The new relationship relates the `target` part to this part with key `rId`.

Target mode is set to ``RTM.EXTERNAL`` if `is_external` is |True|. Intended for
use during load from a serialized package, where the rId is well-known. Other
methods exist for adding a new relationship to a part when manipulating a part.
)r5   Úadd_relationship)r   ÚreltypeÚtargetr7   Úis_externals        r"   Úload_relÚPart.load_relX   s   € ð �y‰y×)Ñ)¨'¸3ÓLÐLr$   c                ó   • U R                   $ )z+|OpcPackage| instance this part belongs to.)r   r'   s    r"   r    ÚPart.packagec   ó   € ð �}‰}Ðr$   c                ó   • U R                   $ )zP|PackURI| instance holding partname of this part, e.g.
'/ppt/slides/slide1.xml'.)r   r'   s    r"   r   ÚPart.partnameh   s   € ð �~‰~Ðr$   c                ó€   • [        U[        5      (       d#  Sn[        U[        U5      R                  -  5      eXl        g )Nz.partname must be instance of PackURI, got '%s')Ú
isinstancer	   Ú	TypeErrorÚtypeÚ__name__r   )r   r   Útmpls      r"   r   rI   n   s3   € ä˜(¤G×,Ñ,ØCˆDÜ˜D¤4¨£>×#:Ñ#:Ñ:Ó;Ð;Ø!�r$   c                ó8   • U R                   R                  U5      $ )a  Return part to which this part has a relationship of `reltype`.

Raises |KeyError| if no such relationship is found and |ValueError| if more than
one such relationship is found. Provides ability to resolve implicitly related
part, such as Slide -> SlideLayout.
)r5   Úpart_with_reltype)r   r@   s     r"   Úpart_related_byÚPart.part_related_byu   s   € ð �y‰y×*Ñ*¨7Ó3Ð3r$   c                óÐ   • U(       a*  U R                   R                  U[        [        U5      5      $ U R                   R	                  U[        [
        U5      5      nUR                  $ )z¨Return rId key of relationship of `reltype` to `target`.

The returned `rId` is from an existing relationship if there is one, otherwise a
new relationship is created.
)r5   Úget_or_add_ext_relr   ÚstrÚ
get_or_addr   r7   )r   rA   r@   rB   Úrels        r"   Ú	relate_toÚPart.relate_to~   sK   € ö Ø—9‘9×/Ñ/°¼¼cÀ6Ó9JÓKÐKà—)‘)×&Ñ& w´´T¸6Ó0BÓCˆCØ—7‘7ˆNr$   c                ó.   • U R                   R                  $ )z£Dictionary mapping related parts by rId, so child objects can resolve
explicit relationships present in the part XML, e.g. sldIdLst to a specific
|Slide| instance.)r5   Úrelated_partsr'   s    r"   r\   ÚPart.related_partsŠ   s   € ð
 �y‰y×&Ñ&Ð&r$   c                ób   • [        U R                  R                  5      U l        U R                  $ )zA|Relationships| instance holding the relationships for this part.)r
   r   ÚbaseURIÚ_relsr'   s    r"   r5   Ú	Part.rels‘   s$   € ô # 4§>¡>×#9Ñ#9Ó:ˆŒ
Ø�z‰zÐr$   c                ó8   • U R                   U   nUR                  $ )zGReturn URL contained in target ref of relationship identified by `rId`.)r5   Ú
target_ref)r   r7   rX   s      r"   rc   ÚPart.target_ref˜   s   € à�i‰i˜‰nˆØ�~‰~Ðr$   c                ó   • g)z˜Return the count of references in this part to the relationship identified by `rId`.

Only an XML part can contain references, so this is 0 for `Part`.
r   r&   r6   s     r"   r4   ÚPart._rel_ref_count�   s   € ð
 r$   )r   r   r   r   r`   )NN)r   r	   r   rV   r   zbytes | Noner    zPackage | None)ÚreturnÚbytes)r7   rV   ©r   r	   r   rV   r   rh   r    r   )F)r@   rV   rA   ú
Part | strr7   rV   rB   Úbool)r   rV   )r@   rV   rg   r   )rA   rj   r@   rV   rB   rk   rg   rV   )r7   rV   rg   rV   ©r7   rV   rg   Úint)rN   Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r(   r,   Úpropertyr   r   r8   Úclassmethodr<   rC   r    r   ÚsetterrR   rY   r\   r   r5   rc   r4   Ú__static_attributes__Ú__classcell__©r!   s   @r"   r   r      s  ø† ñð "Ø"&ð àð ð ð ð ð	 ð
  ÷ ð  òòð ó!ó ð!ð ñ"ó ð"ôð ó:ó ð:ö	Mð ñó ðð ñó ðð
 ‡_�_ó"ó ð"ô4ö
ð ñ'ó ð'ð ñó ðô÷
ò r$   r   c                  óh   • \ rS rSr% SrS\S'   0 rS\S'   \r          SS jr	\
SS j5       rS	rg
)ÚPartFactoryé¥   aÁ  Provides a way for client code to specify a subclass of |Part| to be constructed
by |Unmarshaller| based on its content type and/or a custom callable.

Setting ``PartFactory.part_class_selector`` to a callable object will cause that
object to be called with the parameters ``content_type, reltype``, once for each
part in the package. If the callable returns an object, it is used as the class for
that part. If it returns |None|, part class selection falls back to the content type
map defined in ``PartFactory.part_type_for``. If no class is returned from either of
these, the class contained in ``PartFactory.default_part_type`` is used to construct
the part, which is by default ``opc.package.Part``.
z.Callable[[str, str], Type[Part] | None] | NoneÚpart_class_selectorzdict[str, Type[Part]]Úpart_type_forc                ó”   • S nU R                   b  [        U S5      nU" X#5      nUc  U R                  U5      nUR                  XXE5      $ )Nr{   )r{   r   Ú_part_cls_forr<   )r;   r   r   r@   r   r    Ú	PartClassr{   s           r"   Ú__new__ÚPartFactory.__new__¶   sT   € ð (,ˆ	Ø×"Ñ"Ñ.Ü"/°Ð5JÓ"KÐÙ+¨LÓBˆIØÑØ×)Ñ)¨,Ó7ˆIØ�~‰~˜h°dÓDÐDr$   c                óV   • XR                   ;   a  U R                   U   $ U R                  $ )zŠReturn the custom part class registered for `content_type`, or the default
part class if no custom class is registered for `content_type`.)r|   Údefault_part_type)r;   r   s     r"   r~   ÚPartFactory._part_cls_forÆ   s-   € ð ×,Ñ,Ó,Ø×$Ñ$ \Ñ2Ð2Ø×$Ñ$Ð$r$   r&   N)
r   r	   r   rV   r@   rV   r   rh   r    r   )r   rV   )rN   rn   ro   rp   rq   Ú__annotations__r|   r   rƒ   r€   rs   r~   ru   r&   r$   r"   ry   ry   ¥   sp   ‡ ñ
ð HÓGØ+-€MÐ(Ó-ØÐðEàðEð ðEð ð	Eð
 ðEð ôEð  ó%ó ó%r$   ry   c                  óŽ   ^ • \ rS rSrSr        S
U 4S jjr\S 5       r\S 5       r\	SS j5       r
\S 5       rSS jrS	rU =r$ )ÚXmlPartéÏ   zìBase class for package parts containing an XML payload, which is most of them.

Provides additional methods to the |Part| base class that take care of parsing and
reserializing the XML payload and managing relationships to other parts.
c                ó6   >• [         [        U ]  XUS9  X0l        g )N)r    )r   r‡   r   Ú_element)r   r   r   Úelementr    r!   s        €r"   r   ÚXmlPart.__init__Ö   s   ø€ ô 	Œg�tÑ% hÀgÐ%ÑNØ�r$   c                ó,   • [        U R                  5      $ r   )r   rŠ   r'   s    r"   r   ÚXmlPart.blobÜ   s   € ä! $§-¡-Ó0Ð0r$   c                ó   • U R                   $ )z&The root XML element of this XML part.©rŠ   r'   s    r"   r‹   ÚXmlPart.elementà   rG   r$   c                ó*   • [        U5      nU " XXT5      $ r   r   )r;   r   r   r   r    r‹   s         r"   r<   ÚXmlPart.loadå   s   € ä˜D“/ˆÙ�8¨7Ó<Ð<r$   c                ó   • U $ )zºPart of the parent protocol, "children" of the document will not know the
part that contains them so must ask their parent object.

That chain of delegation ends here for child objects.
r&   r'   s    r"   ÚpartÚXmlPart.partê   s	   € ð ˆr$   c                óœ   • [        SU R                  R                  S5      5      n[        U Vs/ s H  o3U:X  d  M
  UPM     sn5      $ s  snf )zZReturn the count of references in this part's XML to the relationship
identified by `rId`.z	list[str]z//@r:id)r   rŠ   ÚxpathÚlen)r   r7   ÚrIdsÚ_rIds       r"   r4   ÚXmlPart._rel_ref_countó   s@   € ô �K §¡×!4Ñ!4°YÓ!?Ó@ˆÜ¡TÓ9¢T˜T°S©[—D¡TÑ9Ó:Ð:ùÒ9s
   ¯	A	¼A	r�   )r   r	   r   rV   r‹   r   r    r   ri   rl   )rN   rn   ro   rp   rq   r   rr   r   r‹   rs   r<   r•   r4   ru   rv   rw   s   @r"   r‡   r‡   Ï   s‡   ø† ñð Øð Ø/2ð Ø=Lð ØW^÷ ð ñ1ó ð1ð ñó ðð ó=ó ð=ð ñó ð÷;ò ;r$   r‡   N)rq   Ú
__future__r   Útypingr   r   r   r   Údocx.opc.oxmlr   Údocx.opc.packurir	   Údocx.opc.relr
   Údocx.opc.sharedr   Údocx.oxml.parserr   Údocx.sharedr   Údocx.oxml.xmlchemyr   Údocx.packager   r   ry   r‡   r&   r$   r"   Ú<module>r§      sS   ðñ Hå "ç 6Ó 6å ,Ý $Ý &Ý )Ý &Ý $æÝ2Ý$÷Mñ M÷`'%ñ '%ôT(;ˆdõ (;r$   