ó
    ‰*£h"  ã                  óö   • 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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KJr  SSKJr   " S S5      r  " S S5      r!g)z8Objects that implement reading and writing OPC packages.é    )Úannotations)ÚIOÚTYPE_CHECKINGÚIteratorÚcast)ÚRELATIONSHIP_TYPE)ÚPACKAGE_URIÚPackURI)ÚPartFactory)ÚCorePropertiesPart)ÚPackageReader)ÚPackageWriter)ÚRelationships)Úlazyproperty)ÚSelf)ÚCoreProperties)ÚPart)Ú_Relationshipc                  óØ   • \ rS rSrSrS r\SS j5       rSS jrSS jr	SSS jjr
\S 5       rSS	 jr\SS
 j5       rSS jr\SS j5       rSS jr\S 5       rSS jr\SS j5       rSrg)Ú
OpcPackageé   z«Main API class for |python-opc|.

A new instance is constructed by calling the :meth:`open` class method with a path
to a package file or file-like object containing one.
c                ó   • g)zuEntry point for any post-unmarshaling processing.

May be overridden by subclasses without forwarding call to super.
N© ©Úselfs    ÚM/home/mande/repo/quber/.venv/lib/python3.13/site-packages/docx/opc/package.pyÚafter_unmarshalÚOpcPackage.after_unmarshal   s   € ð 	ó    c                ó.   • U R                   R                  $ )zd|CoreProperties| object providing read/write access to the Dublin Core
properties for this document.)Ú_core_properties_partÚcore_propertiesr   s    r   r"   ÚOpcPackage.core_properties(   s   € ð ×)Ñ)×9Ñ9Ð9r   c              #  óT   ^#   •  S     SU4S jjjmT" U 5       H  nUv •  M	     g7f)z{Generate exactly one reference to each relationship in the package by
performing a depth-first traversal of the rels graph.Nc              3  óþ   >#   • Uc  / OUnU R                   R                  5        HS  nUv •  UR                  (       a  M  UR                  nX1;   a  M-  UR	                  U5        UnT" XA5       H  nUv •  M	     MU     g 7f©N©ÚrelsÚvaluesÚis_externalÚtarget_partÚappend)ÚsourceÚvisitedÚrelÚpartÚ
new_sourceÚ	walk_relss        €r   r2   Ú'OpcPackage.iter_rels.<locals>.walk_rels2   so   øé € ð $™O‘b°ˆGØ—{‘{×)Ñ)Ö+�Ø’	Ø—?—?ÙØ—‘�Ø“?ÙØ—‘˜tÔ$Ø!�
Ù$ ZÖ9�CØ”Ió :ò ,ùs   ƒA:A=r&   )r-   zOpcPackage | Partr.   zlist[Part] | NoneÚreturnúIterator[_Relationship]r   )r   r/   r2   s     @r   Ú	iter_relsÚOpcPackage.iter_rels.   sD   øé € ð
 EIð	Ø%ð	Ø0Að	à$÷	ð 	ñ  ˜T–?ˆCØŒIò #ùs   ƒ%(c              #  óF   ^#   • / 4U4S jjmT" U 5       H  nUv •  M	     g7f)z{Generate exactly one reference to each of the parts in the package by
performing a depth-first traversal of the rels graph.c              3  óð   >#   • U R                   R                  5        HS  nUR                  (       a  M  UR                  nX1;   a  M)  UR	                  U5        Uv •  UnT" XA5       H  nUv •  M	     MU     g 7fr&   r'   )r-   r.   r/   r0   r1   Ú
walk_partss        €r   r:   Ú)OpcPackage.iter_parts.<locals>.walk_partsI   sb   øé € Ø—{‘{×)Ñ)Ö+�Ø—?—?ÙØ—‘�Ø“?ÙØ—‘˜tÔ$Ø’
Ø!�
Ù& zÖ;�DØ”Jó <ò ,ùs   ƒA3A6Nr   )r   r0   r:   s     @r   Ú
iter_partsÚOpcPackage.iter_partsE   s&   øé € ð (*÷ 	ñ ˜tÖ$ˆDØŒJò %ùs   ƒ!c                ó:   • U R                   R                  XX45      $ )aU  Return newly added |_Relationship| instance of `reltype` between this part
and `target` 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 the package during processing.
)r(   Úadd_relationship)r   ÚreltypeÚtargetÚrIdr*   s        r   Úload_relÚOpcPackage.load_relY   s   € ð �y‰y×)Ñ)¨'¸3ÓLÐLr   c                ó@   • U R                  [        R                  5      $ )zãReturn a reference to the main document part for this package.

Examples include a document part for a WordprocessingML package, a presentation
part for a PresentationML package, or a workbook part for a SpreadsheetML
package.
)Úpart_related_byÚRTÚOFFICE_DOCUMENTr   s    r   Úmain_document_partÚOpcPackage.main_document_partc   s   € ð ×#Ñ#¤B×$6Ñ$6Ó7Ð7r   c                óÊ   • U R                  5        Vs1 s H  o"R                  iM     nn[        S[        U5      S-   5       H  nX-  nXS;  d  M  [	        U5      s  $    gs  snf )ak  Return a |PackURI| instance representing partname matching `template`.

The returned part-name has the next available numeric suffix to distinguish it
from other parts of its type. `template` is a printf (%)-style template string
containing a single replacement item, a '%d' to be used to insert the integer
portion of the partname. Example: "/word/header%d.xml"
é   é   N)r<   ÚpartnameÚrangeÚlenr
   )r   Útemplater0   Ú	partnamesÚnÚcandidate_partnames         r   Únext_partnameÚOpcPackage.next_partnamem   s]   € ð 04¯©Ô/@ÓAÒ/@ t—]”]Ñ/@ˆ	ÐAÜ�qœ#˜i›.¨1Ñ,Ö-ˆAØ!)¡ÐØ!Õ2ÜÐ1Ó2Ò2ò .ùò Bs   “A c                ót   • [         R                  " U5      nU " 5       n[        R                  X#[        5        U$ )zGReturn an |OpcPackage| instance loaded with the contents of `pkg_file`.)r   Ú	from_fileÚUnmarshallerÚ	unmarshalr   )ÚclsÚpkg_fileÚ
pkg_readerÚpackages       r   ÚopenÚOpcPackage.open{   s0   € ô #×,Ò,¨XÓ6ˆ
Ù“%ˆÜ×Ñ˜z´KÔ@Øˆr   c                ó8   • U R                   R                  U5      $ )zµReturn part to which this package has a relationship of `reltype`.

Raises |KeyError| if no such relationship is found and |ValueError| if more than
one such relationship is found.
)r(   Úpart_with_reltype)r   r@   s     r   rF   ÚOpcPackage.part_related_byƒ   s   € ð �y‰y×*Ñ*¨7Ó3Ð3r   c                ó4   • [        U R                  5       5      $ )zJReturn a list containing a reference to each of the parts in this package.)Úlistr<   r   s    r   ÚpartsÚOpcPackage.parts‹   s   € ô �D—O‘OÓ%Ó&Ð&r   c                óP   • U R                   R                  X!5      nUR                  $ )zËReturn rId key of new or existing relationship to `part`.

If a relationship of `reltype` to `part` already exists, its rId is returned. Otherwise a
new relationship is created and that rId is returned.
)r(   Ú
get_or_addrB   )r   r0   r@   r/   s       r   Ú	relate_toÚOpcPackage.relate_to�   s!   € ð �i‰i×"Ñ" 7Ó1ˆØ�w‰wˆr   c                ó4   • [        [        R                  5      $ )zlReturn a reference to the |Relationships| instance holding the collection of
relationships for this package.)r   r	   ÚbaseURIr   s    r   r(   ÚOpcPackage.rels™   s   € ô œ[×0Ñ0Ó1Ð1r   c                ó    • U R                    H  nUR                  5         M     [        R                  " XR                  U R                   5        g)z^Save this package to `pkg_file`.

`pkg_file` can be either a file-path or a file-like object.
N)rf   Úbefore_marshalr   Úwriter(   )r   r\   r0   s      r   ÚsaveÚOpcPackage.saveŸ   s6   € ð
 —J”JˆDØ×ÑÖ!ñ ä×Ò˜H§i¡i°·±Õ<r   c                óî   •  [        [        U R                  [        R                  5      5      $ ! [
         a;    [        R                  " U 5      nU R                  U[        R                  5        Us $ f = f)z�|CorePropertiesPart| object related to this package.

Creates a default core properties part if one is not present (not common).
)r   r   rF   rG   ÚCORE_PROPERTIESÚKeyErrorÚdefaultrj   )r   Úcore_properties_parts     r   r!   Ú OpcPackage._core_properties_part¨   sa   € ð	(ÜÔ*¨D×,@Ñ,@Ä×ASÑASÓ,TÓUÐUøÜó 	(Ü#5×#=Ò#=¸dÓ#CÐ Ø�N‰NÐ/´×1CÑ1CÔDØ'Ò'ð	(ús   ‚,/ ¯AA4Á3A4r   N)r4   r   )r4   r5   )r4   zIterator[Part])F)r@   ÚstrrA   z
Part | strrB   rz   r*   Úbool)rQ   rz   r4   r
   )r\   ústr | IO[bytes]r4   r   )r@   rz   r4   r   )r4   z
list[Part])r0   r   r@   rz   )r\   r|   )r4   r   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   Úpropertyr"   r6   r<   rC   rI   rU   Úclassmethodr_   rF   rf   rj   r   r(   rr   r!   Ú__static_attributes__r   r   r   r   r      s¨   † ñòð ó:ó ð:ô
ô.ö(Mð ñ8ó ð8ô3ð óó ðô4ð ó'ó ð'ôð ñ2ó ð2ô
=ð ó
(ó ó
(r   r   c                  óH   • \ rS rSrSr\S 5       r\S 5       r\S 5       rSr	g)rY   é¶   zHHosts static methods for unmarshalling a package from a |PackageReader|.c                óÊ   • [         R                  XU5      n[         R                  XU5        UR                  5        H  nUR	                  5         M     UR	                  5         g)z¾Construct graph of parts and realized relationships based on the contents of
`pkg_reader`, delegating construction of each part to `part_factory`.

Package relationships are added to `pkg`.
N)rY   Ú_unmarshal_partsÚ_unmarshal_relationshipsr)   r   )r]   r^   Úpart_factoryrf   r0   s        r   rZ   ÚUnmarshaller.unmarshal¹   sN   € ô ×-Ñ-¨jÀ<ÓPˆÜ×-Ñ-¨jÀ5ÔIØ—L‘L–NˆDØ× Ñ Ö"ñ #à×ÑÕ!r   c                óV   • 0 nU R                  5        H  u  pEpgU" XEXgU5      X4'   M     U$ )z¯Return a dictionary of |Part| instances unmarshalled from `pkg_reader`, keyed
by partname.

Side-effect is that each part in `pkg_reader` is constructed using
`part_factory`.
)Úiter_sparts)r]   r^   rŠ   rf   rN   Úcontent_typer@   Úblobs           r   rˆ   ÚUnmarshaller._unmarshal_partsÆ   s8   € ð ˆØ5?×5KÑ5KÖ5MÑ1ˆH GÙ*¨8À7ÐRYÓZˆE‹Oñ 6Nàˆr   c                ó  • U R                  5        Hm  u  p4US:X  a  UOX#   nUR                  (       a  UR                  OX$R                     nUR	                  UR
                  XdR                  UR                  5        Mo     g)z¡Add a relationship to the source object corresponding to each of the
relationships in `pkg_reader` with its target_part set to the actual target part
in `parts`.Ú/N)Ú
iter_srelsr*   Ú
target_refÚtarget_partnamerC   r@   rB   )r]   r^   rf   Ú
source_uriÚsrelr-   rA   s          r   r‰   Ú%Unmarshaller._unmarshal_relationshipsÓ   se   € ð
 !+× 5Ñ 5Ö 7ÑˆJØ *¨cÓ 1‘W°uÑ7HˆFØ(,×(8×(8�T—_’_¸e×DXÑDXÑ>YˆFØ�O‰O˜DŸL™L¨&·(±(¸D×<LÑ<LÖMò !8r   r   N)
r}   r~   r   r€   r�   ÚstaticmethodrZ   rˆ   r‰   r„   r   r   r   rY   rY   ¶   sA   † ÙRàñ
"ó ð
"ð ñ
ó ð
ð ñNó óNr   rY   N)"r�   Ú
__future__r   Útypingr   r   r   r   Údocx.opc.constantsr   rG   Údocx.opc.packurir	   r
   Údocx.opc.partr   Údocx.opc.parts.corepropsr   Údocx.opc.pkgreaderr   Údocx.opc.pkgwriterr   Údocx.opc.relr   Údocx.sharedr   Útyping_extensionsr   Údocx.opc.corepropsr   r   r   r   rY   r   r   r   Ú<module>r¦      sQ   ðÙ >å "ç 4Ó 4å 6ß 1Ý %Ý 7Ý ,Ý ,Ý &Ý $æÝ&å1Ý"Ý*÷[(ñ [(÷|%Nò %Nr   