+
    it%                         R t ^ RIHt ^ RIHt ^ RIHtHt ^ RI	H
t
 ^ RIHt  ! R R4      t ! R R	4      t ! R
 R4      t ! R R4      t ! R R4      tR# )zQLow-level, read-only API to a serialized Open Packaging Convention (OPC) package.)RELATIONSHIP_TARGET_MODE)	parse_xml)PACKAGE_URIPackURI)PhysPkgReader)CaseInsensitiveDictc                      a a ] tR t^
t oRtV 3R lt]R 4       tR tR t	]R 4       t
]R 4       t]R
R l4       tR	tVtV ;t# )PackageReaderz~Provides access to the contents of a zip-format OPC package via its
:attr:`serialized_parts` and :attr:`pkg_srels` attributes.c                D   < \         \        V `  4        W n        W0n        R # N)superr	   __init__
_pkg_srels_sparts)selfcontent_types	pkg_srelssparts	__class__s   &&&&Y/Users/agent/.openclaw/workspace/.venv/lib/python3.14/site-packages/docx/opc/pkgreader.pyr   PackageReader.__init__   s    mT+-#    c                    \        V 4      p\        P                  VP                  4      p\        P                  V\        4      p\        P                  WV4      pVP                  4        \	        W#V4      # )zEReturn a |PackageReader| instance loaded with contents of `pkg_file`.)	r   _ContentTypeMapfrom_xmlcontent_types_xmlr	   
_srels_forr   _load_serialized_partsclose)pkg_filephys_readerr   r   r   s   &    r   	from_filePackageReader.from_file   sa     $H-'001N1NO!,,[+F	55km\]v>>r   c              #     "   V P                    F3  pVP                  VP                  VP                  VP                  3x  K5  	  R# 5i)zmGenerate a 4-tuple `(partname, content_type, reltype, blob)` for each of the
serialized parts in the package.N)r   partnamecontent_typereltypeblob)r   ss   & r   iter_spartsPackageReader.iter_sparts   s4      A::q~~qyy!&&AA s   AAc              #     "   V P                    F  p\        V3x  K  	  V P                   F&  pVP                   F  pVP                  V3x  K  	  K(  	  R# 5i)zUGenerate a 2-tuple `(source_uri, srel)` for each of the relationships in the
package.N)r   r   r   srelsr$   )r   srelsparts   &  r   
iter_srelsPackageReader.iter_srels#   sK      OOD%% $\\E~~t,, $ "s   AAc                    . p\         P                  W4      pV F,  w  rVrxW%,          p	\        WYWvV4      p
VP                  V
4       K.  	  \	        V4      # )zReturn a list of |_SerializedPart| instances corresponding to the parts in
`phys_reader` accessible by walking the relationship graph starting with
`pkg_srels`.)r	   _walk_phys_parts_SerializedPartappendtuple)r    r   r   r   part_walkerr$   r'   r&   r,   r%   r.   s   &&&        r   r   $PackageReader._load_serialized_parts,   sV    
 #44[L.9*HG(2L#HG5QEMM%  /: V}r   c                d    V P                  V4      p\        P                  VP                  V4      # )znReturn |_SerializedRelationships| instance populated with relationships for
source identified by `source_uri`.)rels_xml_for_SerializedRelationshipsload_from_xmlbaseURI)r    
source_urirels_xmls   && r   r   PackageReader._srels_for9   s-     ++J7'55j6H6H(SSr   c              #  ^  "   Vf   . pV F  pVP                   '       d   K  VP                  pWB9   d   K+  VP                  V4       VP                  p\        P                  W4      pV P                  V4      pWGWV3x  \        P                  WV4      pV F  w  rGrQWGWQ3x  K  	  K  	  R# 5i)zGenerate a 4-tuple `(partname, blob, reltype, srels)` for each of the parts
in `phys_reader` by walking the relationship graph rooted at srels.N)is_externaltarget_partnamer4   r&   r	   r   blob_forr2   )	r    r,   visited_partnamesr-   r$   r&   
part_srelsr'   next_walkers	   &&&      r   r2   PackageReader._walk_phys_parts@   s      $ "D++H,$$X.llG&11+HJ''1D777'88RcdK2=.w66 3> s   B+B-)r   r   r   )__name__
__module____qualname____firstlineno____doc__r   staticmethodr!   r)   r/   r   r   r2   __static_attributes____classdictcell____classcell__r   __classdict__s   @@r   r	   r	   
   sr     B
 ? ?B- 
 
 T T 7 7 7r   r	   c                   X   a a ] tR t^Vt oRtV 3R ltR t]R 4       tR t	R t
RtVtV ;t# )r   zValue type providing dictionary semantics for looking up content type by part
name, e.g. ``content_type = cti['/ppt/presentation.xml']``.c                h   < \         \        V `  4        \        4       V n        \        4       V n        R # r   )r   r   r   r   
_overrides	_defaultsr   r   s   &r   r   _ContentTypeMap.__init__Z   s$    ot-/-/,.r   c                D   \        V\        4      '       g   Rp\        V\        V4      ,          4      hWP                  9   d   V P                  V,          # VP
                  V P                  9   d   V P                  VP
                  ,          # Rp\        W!,          4      h)z6Return content type for part identified by `partname`.z4_ContentTypeMap key must be <type 'PackURI'>, got %sz8no content type for partname '%s' in [Content_Types].xml)
isinstancer   KeyErrortyperU   extrV   )r   r$   tmpls   && r   __getitem___ContentTypeMap.__getitem___   sv    (G,,ID4$x.011&??8,,<<4>>)>>(,,//It''r   c                   \        V 4      p\        4       pVP                   F)  pVP                  VP                  VP
                  4       K+  	  VP                   F)  pVP                  VP                  VP
                  4       K+  	  V# )z[Return a new |_ContentTypeMap| instance populated with the contents of
`content_types_xml`.)	r   r   	overrides_add_overrider$   r%   defaults_add_default	extension)r   	types_elmct_mapods   &    r   r   _ContentTypeMap.from_xmlk   sl     /0	 "$$A  Q^^< %##AQ^^< $r   c                "    W P                   V&   R# )zVAdd the default mapping of `extension` to `content_type` to this content type
mapping.N)rV   )r   rf   r%   s   &&&r   re   _ContentTypeMap._add_defaultw   s     %1y!r   c                "    W P                   V&   R# )zUAdd the default mapping of `partname` to `content_type` to this content type
mapping.N)rU   )r   r$   r%   s   &&&r   rc   _ContentTypeMap._add_override|   s     %1!r   )rV   rU   )rH   rI   rJ   rK   rL   r   r_   rM   r   re   rc   rN   rO   rP   rQ   s   @@r   r   r   V   s8     C/

( 	 	1
1 1r   r   c                      a a ] tR t^t oRtV 3R lt]R 4       t]R 4       t]R 4       t	]R 4       t
]R 4       tRtVtV ;t# )	r3   zValue object for an OPC package part.

Provides access to the partname, content type, blob, and serialized relationships
for the part.
c                h   < \         \        V `  4        Wn        W n        W0n        W@n        WPn        R # r   )r   r3   r   	_partname_content_type_reltype_blob_srels)r   r$   r%   r&   r'   r,   r   s   &&&&&&r   r   _SerializedPart.__init__   s*    ot-/!)
r   c                    V P                   # r   )rr   r   s   &r   r$   _SerializedPart.partname   s    ~~r   c                    V P                   # r   )rs   ry   s   &r   r%   _SerializedPart.content_type   s    !!!r   c                    V P                   # r   )ru   ry   s   &r   r'   _SerializedPart.blob   s    zzr   c                    V P                   # )z-The referring relationship type of this part.rt   ry   s   &r   r&   _SerializedPart.reltype        }}r   c                    V P                   # r   rv   ry   s   &r   r,   _SerializedPart.srels   s    {{r   )ru   rs   rr   rt   rv   )rH   rI   rJ   rK   rL   r   propertyr$   r%   r'   r&   r,   rN   rO   rP   rQ   s   @@r   r3   r3      sx        " "       r   r3   c                      a a ] tR t^t oRtV 3R lt]R 4       t]R 4       t]R 4       t	]R 4       t
]R 4       t]R 4       tR	tVtV ;t# )
_SerializedRelationshipzValue object representing a serialized relationship in an OPC package.

Serialized, in this case, means any target part is referred to via its partname
rather than a direct link to an in-memory |Part| object.
c                   < \         \        V `  4        Wn        VP                  V n        VP                  V n        VP                  V n	        VP                  V n        R # r   )r   r   r   _baseURIrId_rIdr&   rt   target_mode_target_mode
target_ref_target_ref)r   r<   rel_elmr   s   &&&r   r    _SerializedRelationship.__init__   sH    %t57KK	#//"--r   c                <    V P                   \        P                  8H  # )z'True if target_mode is ``RTM.EXTERNAL``)r   RTMEXTERNALry   s   &r   rA   #_SerializedRelationship.is_external   s       CLL00r   c                    V P                   # )z.Relationship type, like ``RT.OFFICE_DOCUMENT``r   ry   s   &r   r&   _SerializedRelationship.reltype   r   r   c                    V P                   # )zeRelationship id, like 'rId9', corresponds to the ``Id`` attribute on the
``CT_Relationship`` element.)r   ry   s   &r   r   _SerializedRelationship.rId   s     yyr   c                    V P                   # )zoString in ``TargetMode`` attribute of ``CT_Relationship`` element, one of
``RTM.INTERNAL`` or ``RTM.EXTERNAL``.)r   ry   s   &r   r   #_SerializedRelationship.target_mode   s        r   c                    V P                   # )zString in ``Target`` attribute of ``CT_Relationship`` element, a relative
part reference for internal target mode or an arbitrary URI, e.g. an HTTP URL,
for external target mode.)r   ry   s   &r   r   "_SerializedRelationship.target_ref   s    
 r   c                    V P                   '       d   Rp\        V4      h\        V R4      '       g1   \        P                  ! V P
                  V P                  4      V n        V P                  # )z|PackURI| instance containing partname targeted by this relationship.

Raises ``ValueError`` on reference if target_mode is ``'External'``. Use
:attr:`target_mode` to check before referencing.
zUtarget_partname attribute on Relationship is undefined where TargetMode == "External"_target_partname)rA   
ValueErrorhasattrr   from_rel_refr   r   r   )r   msgs   & r   rB   '_SerializedRelationship.target_partname   s]     0  S/!t/00$+$8$8$XD!$$$r   )r   r   rt   r   r   r   )rH   rI   rJ   rK   rL   r   r   rA   r&   r   r   r   rB   rN   rO   rP   rQ   s   @@r   r   r      s     . 1 1    
 ! !
     % % %r   r   c                   L   a a ] tR t^t oRtV 3R ltR t]R 4       tRt	Vt
V ;t# )r:   z|Read-only sequence of |_SerializedRelationship| instances corresponding to the
relationships item XML passed to constructor.c                :   < \         \        V `  4        . V n        R # r   )r   r:   r   rv   rW   s   &r   r   !_SerializedRelationships.__init__   s    &68r   c                6    V P                   P                  4       # )z*Support iteration, e.g. 'for x in srels:'.)rv   __iter__ry   s   &r   r   !_SerializedRelationships.__iter__   s    {{##%%r   c                    \        4       pVeC   \        V4      pVP                   F'  pVP                  P	                  \        W4      4       K)  	  V# )zReturn |_SerializedRelationships| instance loaded with the relationships
contained in `rels_item_xml`.

Returns an empty collection if `rels_item_xml` is |None|.
)r:   r   Relationship_lstrv   r4   r   )r<   rels_item_xmlr,   rels_elmr   s   &&   r   r;   &_SerializedRelationships.load_from_xml   sI     )*$ /H#44##$;G$MN 5r   r   )rH   rI   rJ   rK   rL   r   r   rM   r;   rN   rO   rP   rQ   s   @@r   r:   r:      s-     5&   r   r:   N)rL   docx.opc.constantsr   r   docx.opc.oxmlr   docx.opc.packurir   r   docx.opc.phys_pkgr   docx.opc.sharedr   r	   r   r3   r   r:    r   r   <module>r      sO    W > # 1 + /I7 I7X)1 )1X" "J<% <%~ r   