+
    i"                        R t ^ RIHt ^ RIHtHtHtHt ^ RIH	t
 ^ RIHtHt ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ R	IHt ^ R
IHt ]'       d   ^ RIHt ^ RIHt ^ RIHt ^ RIHt  ! R R4      t  ! R R4      t!R# )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                      ] tR t^tRtR t]R R l4       tR R ltR R lt	RR	 R
 llt
]R 4       tR R lt]R R l4       tR R lt]R R l4       tR R lt]R 4       tR R lt]R R l4       tRtR# )
OpcPackagezMain 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                    R# )zuEntry point for any post-unmarshaling processing.

May be overridden by subclasses without forwarding call to super.
N selfs   &W/Users/agent/.openclaw/workspace/.venv/lib/python3.14/site-packages/docx/opc/package.pyafter_unmarshalOpcPackage.after_unmarshal   s     	    c                   V ^8  d   QhRR/# )   returnr   r   )formats   "r   __annotate__OpcPackage.__annotate__)   s     : : :r   c                .    V P                   P                  # )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                   V ^8  d   QhRR/# )r   r    Iterator[_Relationship]r   )r!   s   "r   r"   r#   .   s      2 r   c              #  L   a"   RR V3R llloS! V 4       F  pVx  K	  	  R# 5i)z{Generate exactly one reference to each relationship in the package by
performing a depth-first traversal of the rels graph.Nc               $    V ^8  d   QhRRRRRR/# )r   sourcezOpcPackage | Partvisitedzlist[Part] | Noner    r)   r   )r!   s   "r   r"   *OpcPackage.iter_rels.<locals>.__annotate__2   s$     	 	%	0A	$	r   c              3    <"   Vf   . MTpV P                   P                  4        FU  pVx  VP                  '       d   K  VP                  pW19   d   K/  VP	                  V4       TpS! WA4       F  pVx  K	  	  KW  	  R # 5iNrelsvaluesis_externaltarget_partappend)r,   r-   relpart
new_source	walk_relss   &&   r   r:   'OpcPackage.iter_rels.<locals>.walk_rels2   sq      $ObG{{))+	????t$!
$Z9CI : ,s   A>Br0   r   )r   r7   r:   s   & @r   	iter_relsOpcPackage.iter_rels.   s%     	 	  T?CI #s   !$c                   V ^8  d   QhRR/# )r   r    zIterator[Part]r   )r!   s   "r   r"   r#   E   s      N r   c              #  H   a"   . 3V3R lloS! V 4       F  pVx  K	  	  R# 5i)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     <"   V P                   P                  4        FU  pVP                  '       d   K  VP                  pW19   d   K+  VP	                  V4       Vx  TpS! WA4       F  pVx  K	  	  KW  	  R # 5ir0   r1   )r,   r-   r7   r8   r9   
walk_partss   &&   r   rA   )OpcPackage.iter_parts.<locals>.walk_partsI   sd     {{))+????t$
!
&z;DJ < ,s   A6A9Nr   )r   r8   rA   s   & @r   
iter_partsOpcPackage.iter_partsE   s&      (* 	 t$DJ %s   "c               (    V ^8  d   QhRRRRRRRR/# )r   reltypestrtargetz
Part | strrIdr4   boolr   )r!   s   "r   r"   r#   Y   s/     M M MZ Mc MPT Mr   c                :    V P                   P                  WW44      # )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.
)r2   add_relationship)r   rF   rH   rI   r4   s   &&&&&r   load_relOpcPackage.load_relY   s     yy))'3LLr   c                @    V P                  \        P                  4      # )zReturn 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                    V ^8  d   QhRRRR/# )r   templaterG   r    r	   r   )r!   s   "r   r"   r#   m   s     3 3c 3g 3r   c                    V P                  4        Uu0 uF  q"P                  kK  	  pp\        ^\        V4      ^,           4       F  pW,          pWS9  g   K  \	        V4      u # 	  R# u upi )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)rC   partnamerangelenr	   )r   rV   r8   	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                    V ^8  d   QhRRRR/# )r   pkg_filestr | IO[bytes]r    r   r   )r!   s   "r   r"   r#   |   s      O  r   c                t    \         P                  ! V4      pV ! 4       p\        P                  W#\        4       V# )zGReturn an |OpcPackage| instance loaded with the contents of `pkg_file`.)r   	from_fileUnmarshaller	unmarshalr
   )clsra   
pkg_readerpackages   &&  r   openOpcPackage.open{   s0     #,,X6
%zK@r   c                    V ^8  d   QhRRRR/# )r   rF   rG   r    r   r   )r!   s   "r   r"   r#      s     4 4s 4t 4r   c                8    V P                   P                  V4      # )zReturn 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.
)r2   part_with_reltype)r   rF   s   &&r   rP   OpcPackage.part_related_by   s     yy**733r   c                   V ^8  d   QhRR/# )r   r    z
list[Part]r   )r!   s   "r   r"   r#      s     ' 'z 'r   c                4    \        V P                  4       4      # )zJReturn a list containing a reference to each of the parts in this package.)listrC   r   s   &r   partsOpcPackage.parts   s     DOO%&&r   c                    V ^8  d   QhRRRR/# )r   r8   r   rF   rG   r   )r!   s   "r   r"   r#      s      d S r   c                P    V P                   P                  W!4      pVP                  # )zReturn 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.
)r2   
get_or_addrI   )r   r8   rF   r7   s   &&& r   	relate_toOpcPackage.relate_to   s!     ii""71wwr   c                4    \        \        P                  4      # )zlReturn a reference to the |Relationships| instance holding the collection of
relationships for this package.)r   r   baseURIr   s   &r   r2   OpcPackage.rels   s     [0011r   c                   V ^8  d   QhRR/# )r   ra   rb   r   )r!   s   "r   r"   r#      s     = =_ =r   c                    V P                    F  pVP                  4        K  	  \        P                  ! WP                  V P                   4       R# )z^Save this package to `pkg_file`.

`pkg_file` can be either a file-path or a file-like object.
N)rs   before_marshalr   writer2   )r   ra   r8   s   && r   saveOpcPackage.save   s6    
 JJD! Hii<r   c                   V ^8  d   QhRR/# )r   r    r   r   )r!   s   "r   r"   r#      s     
( 
('9 
(r   c                     \        \        V P                  \        P                  4      4      #   \
         d<    \        P                  ! T 4      pT P                  T\        P                  4       Tu # i ; i)z|CorePropertiesPart| object related to this package.

Creates a default core properties part if one is not present (not common).
)r   r   rP   rQ   CORE_PROPERTIESKeyErrordefaultrx   )r   core_properties_parts   & r   r%    OpcPackage._core_properties_part   sa    	(*D,@,@ASAS,TUU 	(#5#=#=d#C NN/1C1CD''	(s   ,/ AA54A5r   N)F)__name__
__module____qualname____firstlineno____doc__r   propertyr&   r<   rC   rM   rS   r^   classmethodrj   rP   rs   rx   r   r2   r   r%   __static_attributes__r   r   r   r   r      s     : :
.(M 8 83  4 ' ' 2 2
= 
( 
(r   r   c                  J    ] tR t^tRt]R 4       t]R 4       t]R 4       tRt	R# )re   zHHosts static methods for unmarshalling a package from a |PackageReader|.c                    \         P                  WV4      p\         P                  WV4       VP                  4        F  pVP	                  4        K  	  VP	                  4        R# )zConstruct 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)re   _unmarshal_parts_unmarshal_relationshipsr3   r   )rh   ri   part_factoryrs   r8   s   &&&  r   rf   Unmarshaller.unmarshal   sN     --j<P--j5ILLND  " #!r   c                V    / pV P                  4        F  w  rErgV! WEWgV4      W4&   K  	  V# )zReturn 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)rh   ri   r   rs   rX   content_typerF   blobs   &&&     r   r   Unmarshaller._unmarshal_parts   s8     5?5K5K5M1HG*87RYZEO 6Nr   c                   V P                  4        Fw  w  r4VR8X  d   TMW#,          pVP                  '       d   VP                  MW$P                  ,          pVP	                  VP
                  WdP                  VP                  4       Ky  	  R# )zAdd 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_srelsr4   
target_reftarget_partnamerM   rF   rI   )rh   ri   rs   
source_urisrelr,   rH   s   &&&    r   r   %Unmarshaller._unmarshal_relationships   sh    
 !+ 5 5 7J *c 1Wu7HF(,(8(8(8T__eDXDX>YFOODLL&((D<L<LM !8r   r   N)
r   r   r   r   r   staticmethodrf   r   r   r   r   r   r   re   re      sA    R
" 
" 
 
 N Nr   re   N)"r   
__future__r   typingr   r   r   r   docx.opc.constantsr   rQ   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   re   r   r   r   <module>r      sQ    > " 4 4 6 1 % 7 , , & $&1"*[( [(|%N %Nr   