
    j:j{                     ^   S r SSKrSSKrSSKrSSKJr  SSKJr  SSKJ	r	J
r
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Jr  SSKJr  SSKJrJrJr  SSK J!r!J"r"J#r#  SSK$J%r%J&r&  Sr'Sr(Sr)Sr*Sr+Sr,Sr-Sr.Sr/\*S\+S\,S\-S\/S\.S0r0\Rb                  " S\Rd                  5      r3\" S 5      r4S!\) S"\* S#\+ S$\, S%\- S&\/ S'\. S(3r5S)\4S*\44S+ jr6S)\7S*\R                  4S, jr8S)\R                  S*\74S- jr9\64S.\S/S0S1\7S2\
\	/\	4   S*\\:\7      4
S3 jjr; " S4 S5\5      r< " S6 S0\\&5      r=g)7z~
Anything related to Extensible Metadata Platform (XMP) metadata.

https://en.wikipedia.org/wiki/Extensible_Metadata_Platform
    N)Iterator	hexdigits)AnyCallableOptionalTypeVarUnioncast)ExpatBuilderNS)Document)Element)Options)
ExpatErrorXMLParserType   )XmpInformationProtocol)
StreamTypedeprecate_with_replacementdeprecation_no_replacement)LimitReachedErrorPdfReadErrorXmpDocumentError)ContentStream	PdfObjecti@KL i z+http://www.w3.org/1999/02/22-rdf-syntax-ns#z http://purl.org/dc/elements/1.1/zhttp://ns.adobe.com/xap/1.0/zhttp://ns.adobe.com/pdf/1.3/zhttp://ns.adobe.com/xap/1.0/mm/zhttp://ns.adobe.com/pdfx/1.3/zhttp://www.aiim.org/pdfa/ns/id/dcxmppdfxmpMMpdfaidpdfxa{  
        (?P<year>[0-9]{4})
        (-
            (?P<month>[0-9]{2})
            (-
                (?P<day>[0-9]+)
                (T
                    (?P<hour>[0-9]{2}):
                    (?P<minute>[0-9]{2})
                    (:(?P<second>[0-9]{2}(.[0-9]+)?))?
                    (?P<tzd>Z|[-+][0-9]{2}:[0-9]{2})
                )?
            )?
        )?
        Ku   <?xpacket begin="﻿" id="W5M0MpCehiHzreSzNTczkc9d"?>
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="pypdf">
    <rdf:RDF xmlns:rdf="z?">
        <rdf:Description rdf:about=""
            xmlns:dc="z"
            xmlns:xmp="z"
            xmlns:pdf="z"
            xmlns:xmpMM="z"
            xmlns:pdfaid="z"
            xmlns:pdfx="zM">
        </rdf:Description>
    </rdf:RDF>
</x:xmpmeta>
<?xpacket end="r"?>valuereturnc                     U $ N r#   s    ?/var/www/website/venv/lib/python3.13/site-packages/pypdf/xmp.py	_identityr*   p   s    L    c           	      f   [         R                  U 5      nUc  [        SU  35      e[        UR	                  S5      5      n[        UR	                  S5      =(       d    S5      n[        UR	                  S5      =(       d    S5      n[        UR	                  S5      =(       d    S5      n[        UR	                  S5      =(       d    S5      n[
        R                  " UR	                  S	5      =(       d    S5      nUR                  [
        R                  5      nXx-
  S
-  n	[        U5      n
[        U	5      nUR	                  S5      =(       d    Sn[        R                  " X#XEXjU5      nUS:w  aA  S UR                  S5       5       u  pUS-  nUS:  a  US-  nU[        R                  " XS9-   nU$ )NzInvalid date format: yearmonth1dayhour0minutesecondi@B tzdZc              3   8   #    U  H  n[        U5      v   M     g 7fr&   )int).0xs     r)   	<genexpr>"_converter_date.<locals>.<genexpr>   s     !A.Q#a&&.s   :r   )hoursminutes)iso8601match
ValueErrorr8   groupdecimalDecimalto_integralROUND_FLOORdatetimesplit	timedelta)r#   matchesr-   r.   r0   r1   r3   r4   seconds_decmilliseconds_decsecondsmillisecondsr5   dt	tzd_hourstzd_minutess                   r)   _converter_daterT   t   si   mmE"G0899w}}V$%Dg&-#.E
gmmE")c
*Cw}}V$+,Dx(/C0F__W]]84;<F$$W%8%89K,	9+G'(L
--

%#C			46L	QB
cz!A#))C.!A	R	q=2K($$9JJIr+   c                     U R                   b:  U R                  5       b)  U R                  [        R                  R
                  5      n U R                  SS9n U R                  S5      $ )z}Format a datetime as UTC with trailing 'Z'.

- If the input is timezone-aware, convert to UTC first.
- If naive, assume UTC.
N)tzinfoz%Y-%m-%dT%H:%M:%S.%fZ)rV   	utcoffset
astimezonerI   timezoneutcreplacestrftimer(   s    r)   _format_datetime_utcr]      sV     ||EOO$5$A  !2!2!6!67MMM&E>>122r+   elementselfXmpInformation	list_type	converterc                     U R                  [        U5      n/ n[        U5      (       aR  U HJ  nUR                  [        S5       H-  nUR                  U5      nU" U5      nUR	                  U5        M/     ML     U$ g )Nli)getElementsByTagNameNSRDF_NAMESPACElen	_get_textappend)	r^   r_   ra   rb   
containersretval	containeritemr#   s	            r)   _generic_getrn      st     //yIJF
:#I!88Mt,!%(e$ N $
 r+   c                      ^  \ rS rSrSrSS\\   SS4U 4S jjjrS\S\	S	\\   S
\\   S\S\\   S\\   SS4S jr
S\S\\   SS4U 4S jjrS\SS4U 4S jjrSrU =r$ )_XmpBuilder   aO  
Custom XML parser denying all entity declarations.

This is a stripped down and typed version inspired by what *defusedxml* does.

Why do we need this? The default limits of *libexpat* used by Python only block exponential entity expansion,
but not cases like quadratic entity expansion which can still cause quite some memory usage.
Noptionsr$   c                 .   > [         TU ]  US9  SU l        g )N)rr   r   )super__init___element_count)r_   rr   	__class__s     r)   ru   _XmpBuilder.__init__   s    )r+   entity_nameis_parameter_entityr#   base	system_id	public_idnotation_namec                      [        SU< 35      e)NzForbidden entities: )r   )r_   ry   rz   r#   r{   r|   r}   r~   s           r)   !custom_entity_declaration_handler-_XmpBuilder.custom_entity_declaration_handler   s     /?@@r+   name
attributesc                    > U =R                   S-  sl         U R                   [        :  a  [        S[         S35      e[        TU ]  XS9  g )Nr   zXMP metadata exceeds limit of z
 elements.)r   r   )rv   XMP_MAX_ELEMENT_COUNTr   rt   start_element_handler)r_   r   r   rw   s      r)   r   !_XmpBuilder.start_element_handler   sK    q !66#&DEZD[[e$fgg%4%Gr+   parserc                 h   > [         TU ]  U5        U R                  Ul        U R                  Ul        g r&   )rt   installr   EntityDeclHandlerr   StartElementHandler)r_   r   rw   s     r)   r   _XmpBuilder.install   s+    #'#I#I %)%?%?"r+   )rv   r&   )__name__
__module____qualname____firstlineno____doc__r   r   ru   strboolr   listr   r   r   __static_attributes____classcell__)rw   s   @r)   rp   rp      s      1  T    
A
A "&
A C=	
A
 3-
A 
A  }
A $C=
A 

AH# H49 H H@m @ @ @r+   rp   c                   4   \ rS rSrSrS\SS4S jr\SVS j5       r SWS\	S\
S\\4   SS4S	 jjrS
\S\S\S\\   4S jrS
\S\S\\   4S jrS\S\4S jr\4S\S\S\\/\4   S\\   4S jjrS\S\S\\\      4S jr\4S\S\S\\/\4   S\\\      4S jjrS\S\S\\\\4      4S jr\S\\\      4S j5       r\R>                  S\\\      SS4S j5       r\S\\   4S j5       r \ R>                  S\\   SS4S j5       r \S\\\      4S j5       r!\!R>                  S\\\      SS4S j5       r!\S\\\"RD                        4S j5       r#\#R>                  S\\\
\\"RD                  4         SS4S j5       r#\S\\\\4      4S  j5       r$\$R>                  S\\\\4      SS4S! j5       r$\S\\   4S" j5       r%\%R>                  S\\   SS4S# j5       r%\S\\   4S$ j5       r&\&R>                  S\\   SS4S% j5       r&\S\\\      4S& j5       r'\'R>                  S\\\      SS4S' j5       r'\S\\\      4S( j5       r(\(R>                  S\\\      SS4S) j5       r(\S\\\      4S* j5       r)\)R>                  S\\\      SS4S+ j5       r)\S\\\\4      4S, j5       r*\*R>                  S\\\\4      SS4S- j5       r*\S\\   4S. j5       r+\+R>                  S\\   SS4S/ j5       r+\S\\\      4S0 j5       r,\,R>                  S\\\      SS4S1 j5       r,\S\\\\4      4S2 j5       r-\-R>                  S\\\\4      SS4S3 j5       r-\S\\\      4S4 j5       r.\.R>                  S\\\      SS4S5 j5       r.\S\\   4S6 j5       r/\/R>                  S\\   SS4S7 j5       r/\S\\   4S8 j5       r0\0R>                  S\\   SS4S9 j5       r0\S\\   4S: j5       r1\1R>                  S\\   SS4S; j5       r1\S\\"RD                     4S< j5       r2\2R>                  S\\"RD                     SS4S= j5       r2\S\\"RD                     4S> j5       r3\3R>                  S\\"RD                     SS4S? j5       r3\S\\"RD                     4S@ j5       r4\4R>                  S\\"RD                     SS4SA j5       r4\S\\   4SB j5       r5\5R>                  S\\   SS4SC j5       r5\S\\   4SD j5       r6\6R>                  S\\   SS4SE j5       r6\S\\   4SF j5       r7\7R>                  S\\   SS4SG j5       r7\S\\   4SH j5       r8\8R>                  S\\   SS4SI j5       r8\S\\   4SJ j5       r9\9R>                  S\\   SS4SK j5       r9\S\\\4   4SL j5       r:SXS
\S\4SM jjr;S\S\SS4SN jr<S\S\S\\   SS4SO jr=S\S\S\\\      SS4SP jr>S\S\S\\\      SS4SQ jr?S\S\S\\\\4      SS4SR jr@S\S\4SS jrASYST jrBSUrCg)Zr`      z
An object that represents Extensible Metadata Platform (XMP) metadata.
Usually accessed by :py:attr:`xmp_metadata()<pypdf.PdfReader.xmp_metadata>`.

Raises:
  PdfReadError: if XML is invalid

streamr$   Nc                    Xl          U R                   R                  5       n[        U5      =n[        :  a  [	        SU S[         S35      e[        5       R                  U5      nUR                  [        S5      nU(       d  [        S5      eUS   U l        0 U l        g ! [        [        4 a  n[        SU 35      eS nAff = f)NzXMP stream size z exceeds limit of .z#XML in XmpInformation was invalid: RDFz?XML in XmpInformation was invalid: Missing rdf:RDF root elementr   )r   get_datarg   XMP_MAX_INPUT_LENGTHr   rp   parseStringAttributeErrorr   r   re   rf   rdf_rootcache)r_   r   datalengthdoc_roote	rdf_rootss          r)   ru   XmpInformation.__init__   s    	J;;'')Dd)#';;'*:6(BTUiTjjk(lmm!,!:!:4!@H 33M5I	Q  %.aL%'
 
+ 	J!DQCHII	Js   AB   C0B>>Cc                 r    [        SS5      nUR                  [        R                  S5      5        U " U5      $ )z
Create a new XmpInformation object with minimal structure.

Returns:
    A new XmpInformation instance with empty metadata fields.
Nutf-8)r   set_data_MINIMAL_XMPencode)clsr   s     r)   createXmpInformation.create   s1     tT*++G456{r+   encryption_keyc                 r    [        SSS5        Ub  [        SS5        U R                  R                  U5        g )NzXmpInformation.write_to_streamzPdfWriter.xmp_metadataz6.0.0z/the encryption_key parameter of write_to_streamz5.0.0)r   r   r   write_to_stream)r_   r   r   s      r)   r   XmpInformation.write_to_stream   s>     	#,$	

 %&A7 	##F+r+   	about_uri	namespacer   c              #      #    U R                   R                  [        S5       HP  nUR                  [        S5      U:X  d  M  UR	                  X#5      nUb  Uv   UR                  X#5       S h  vN   MR     g  N	7fNDescriptionabout)r   re   rf   getAttributeNSgetAttributeNodeNS)r_   r   r   r   descattrs         r)   get_elementXmpInformation.get_element  sk     MM88VD""=':iG..y?#J66yGGG W
 Hs   <A:,A:.A8/
A:c              #     #    U R                   R                  [        S5       H  nUR                  [        S5      U:X  d  M  [	        UR
                  R                  5       H=  nUR
                  R                  U5      nU(       d  M'  UR                  U:X  d  M9  Uv   M?     UR                   H  nUR                  U:X  d  M  Uv   M     M     g 7fr   )
r   re   rf   r   ranger   r   rm   namespaceURI
childNodes)r_   r   r   r   ir   childs          r)   get_nodes_in_namespace%XmpInformation.get_nodes_in_namespace  s     MM88VD""=':iGt556A??//2Dt 1 1Y >"
 7 "__E))Y6# - Ws   <CACC%CCr^   c                     SnUR                    H-  nUR                  UR                  :X  d  M  X#R                  -  nM/     U$ N )r   nodeType	TEXT_NODEr   )r_   r^   textr   s       r)   rh   XmpInformation._get_text  s:    ''E~~0

" ( r+   rb   c                 j   U R                   R                  U0 5      R                  U5      nU(       a  U$ S nU R                  SX5       H;  nUR                  UR                  :X  a  UR
                  nOU R                  U5      n  O   Ub  U" U5      nU R                   R                  U0 5      nXWU'   U$ r   )r   getr   r   ATTRIBUTE_NODE	nodeValuerh   
setdefault)r_   r   r   rb   cachedr#   r^   ns_caches           r)   _get_single_value XmpInformation._get_single_value!  s     	2.2248M''I<G7#9#99))w/ = e$E::((B7r+   c                    U R                   R                  U0 5      R                  U5      nU(       a  [        [        [           U5      $ / nU R                  SX5       HE  n[        XPSS9=nb  UR                  U5        M#  U R                  U5      nUR                  U5        MG     U R                   R                  U0 5      nXHU'   U$ )Nr   Bagra   )r   r   r   r   r   r   rn   extendrh   ri   r   )	r_   r   r   r   rk   r^   bagsr#   r   s	            r)   _getter_bagXmpInformation._getter_bag7  s    	2.2248S	6**''I<G$WeDDQd#w/e$ = ::((B7r+   c                    U R                   R                  U0 5      R                  U5      nU(       a  [        [        [           U5      $ / nU R                  SX5       Hl  n[        X`SUS9=nb  UR                  U5        M$  [        X`SS9=nb  UR                  U5        MD  U" U R                  U5      5      n	UR                  U	5        Mn     U R                   R                  U0 5      n
XZU'   U$ )Nr   Seq)ra   rb   r   r   )r   r   r   r   r   r   rn   r   rh   ri   r   )r_   r   r   rb   r   rk   r^   seqsr   r#   r   s              r)   _get_seq_valuesXmpInformation._get_seq_valuesF  s     	2.2248S	6**''I<G$WeyYYfd#&wFF$S d#!$.."9:e$ = ::((B7r+   c                 &   U R                   R                  U0 5      R                  U5      nU(       a  [        [        [        [        4   U5      $ 0 nU R                  SX5       H  nUR                  [        S5      n[        U5      (       aL  U HD  nUR                  [        S5       H'  nU R                  U5      n	XUR                  S5      '   M)     MF     Mu  U R                  U5      US'   M     U R                   R                  U0 5      n
XJU'   U$ )Nr   Altrd   xml:langz	x-default)r   r   r   dictr   r   re   rf   rg   rh   getAttributer   )r_   r   r   r   rk   r^   altsaltrm   r#   r   s              r)   _get_langalt_values"XmpInformation._get_langalt_valuesc  s    	2.2248S#X//!#''I<G11-GD4yyC # : :=$ O $t 4@Et00<= !P  
 '+nnW&={# = ::((B7r+   c                 .    U R                  [        S5      $ )z6Contributors to the resource (other than the authors).contributorr   DC_NAMESPACEr_   s    r)   dc_contributorXmpInformation.dc_contributoru  s     m<<r+   valuesc                 2    U R                  [        SU5        g )Nr   _set_bag_valuesr   r_   r   s     r)   r   r   z  s    \=&Ar+   c                 .    U R                  [        S5      $ )z4Text describing the extent or scope of the resource.coverager   r   r   s    r)   dc_coverageXmpInformation.dc_coverage~  s     %%lJ??r+   r#   c                 2    U R                  [        SU5        g )Nr   _set_single_valuer   r_   r#   s     r)   r   r     s    |Z?r+   c                 .    U R                  [        S5      $ )zVA sorted array of names of the authors of the resource, listed in order of precedence.creator)r   r   r   s    r)   
dc_creatorXmpInformation.dc_creator  s     ##L)<<r+   c                 2    U R                  [        SU5        g )Nr  )_set_seq_valuesr   r   s     r)   r  r        \9f=r+   c                 8    U R                  [        S[        5      $ )zXA sorted array of dates of significance to the resource. The dates and times are in UTC.date)r   r   rT   r   s    r)   dc_dateXmpInformation.dc_date  s     ##L&/JJr+   c                 (   Uc  U R                  [        SS 5        g / nU HX  n[        U[        R                  5      (       a  UR	                  [        U5      5        M>  UR	                  [        U5      5        MZ     U R                  [        SU5        g )Nr  )r	  r   
isinstancerI   ri   r]   r   )r_   r   date_stringsr#   s       r)   r  r    su    >  vt<LeX%6%677 ''(<U(CD ''E
3	  
   v|Dr+   c                 .    U R                  [        S5      $ )zSA language-keyed dictionary of textual descriptions of the content of the resource.descriptionr   r   r   s    r)   dc_descriptionXmpInformation.dc_description  s     ''mDDr+   c                 2    U R                  [        SU5        g )Nr  _set_langalt_valuesr   r   s     r)   r  r    s      }fEr+   c                 .    U R                  [        S5      $ )zThe mime-type of the resource.formatr   r   s    r)   	dc_formatXmpInformation.dc_format       %%lH==r+   c                 2    U R                  [        SU5        g )Nr  r  r  s     r)   r  r        |Xu=r+   c                 .    U R                  [        S5      $ )z"Unique identifier of the resource.
identifierr   r   s    r)   dc_identifierXmpInformation.dc_identifier  s     %%lLAAr+   c                 2    U R                  [        SU5        g )Nr"  r  r  s     r)   r#  r$    s    |\5Ar+   c                 .    U R                  [        S5      $ )zAAn unordered array specifying the languages used in the resource.languager   r   s    r)   dc_languageXmpInformation.dc_language       j99r+   c                 2    U R                  [        SU5        g )Nr'  r   r   s     r)   r(  r)        \:v>r+   c                 .    U R                  [        S5      $ )z&An unordered array of publisher names.	publisherr   r   s    r)   dc_publisherXmpInformation.dc_publisher  s     k::r+   c                 2    U R                  [        SU5        g )Nr.  r   r   s     r)   r/  r0    s    \;?r+   c                 .    U R                  [        S5      $ )zLAn unordered array of text descriptions of relationships to other documents.relationr   r   s    r)   dc_relationXmpInformation.dc_relation  r*  r+   c                 2    U R                  [        SU5        g )Nr3  r   r   s     r)   r4  r5    r,  r+   c                 .    U R                  [        S5      $ )z`A language-keyed dictionary of textual descriptions of the rights the user has to this resource.rightsr  r   s    r)   	dc_rightsXmpInformation.dc_rights  s     ''h??r+   c                 2    U R                  [        SU5        g )Nr8  r  r   s     r)   r9  r:    s      x@r+   c                 .    U R                  [        S5      $ )zCUnique identifier of the work from which this resource was derived.sourcer   r   s    r)   	dc_sourceXmpInformation.dc_source  r  r+   c                 2    U R                  [        SU5        g )Nr=  r  r  s     r)   r>  r?    r   r+   c                 .    U R                  [        S5      $ )z\An unordered array of descriptive phrases or keywords that specify the topic of the content.subjectr   r   s    r)   
dc_subjectXmpInformation.dc_subject  s     i88r+   c                 2    U R                  [        SU5        g )NrB  r   r   s     r)   rC  rD    r
  r+   c                 .    U R                  [        S5      $ )z9A language-keyed dictionary of the title of the resource.titler  r   s    r)   dc_titleXmpInformation.dc_title  s     ''g>>r+   c                 2    U R                  [        SU5        g )NrG  r  r   s     r)   rH  rI    s      w?r+   c                 .    U R                  [        S5      $ )z@An unordered array of textual descriptions of the document type.typer   r   s    r)   dc_typeXmpInformation.dc_type  s     f55r+   c                 2    U R                  [        SU5        g )NrL  r   r   s     r)   rM  rN    s    \66:r+   c                 .    U R                  [        S5      $ )z:An unformatted text string representing document keywords.Keywordsr   PDF_NAMESPACEr   s    r)   pdf_keywordsXmpInformation.pdf_keywords       %%mZ@@r+   c                 2    U R                  [        SU5        g )NrQ  r  rS  r  s     r)   rT  rU  
      }j%@r+   c                 .    U R                  [        S5      $ )z-The PDF file version, for example 1.0 or 1.3.
PDFVersionrR  r   s    r)   pdf_pdfversionXmpInformation.pdf_pdfversion  s     %%m\BBr+   c                 2    U R                  [        SU5        g )Nr[  rX  r  s     r)   r\  r]    s    }lEBr+   c                 .    U R                  [        S5      $ )z6The name of the tool that saved the document as a PDF.ProducerrR  r   s    r)   pdf_producerXmpInformation.pdf_producer  rV  r+   c                 2    U R                  [        SU5        g )Nr`  rX  r  s     r)   ra  rb    rY  r+   c                 8    U R                  [        S[        5      $ )zYThe date and time the resource was originally created. Returned as a UTC datetime object.
CreateDater   XMP_NAMESPACErT   r   s    r)   xmp_create_dateXmpInformation.xmp_create_date        %%m\?SSr+   c                     U(       a#  [        U5      nU R                  [        SU5        g U R                  [        SS 5        g )Nre  r]   r  rg  r_   r#   date_strs      r)   rh  ri  %  3    +E2H""=,I""=,Er+   c                 8    U R                  [        S[        5      $ )zTThe date and time the resource was last modified. Returned as a UTC datetime object.
ModifyDaterf  r   s    r)   xmp_modify_dateXmpInformation.xmp_modify_date-  rj  r+   c                     U(       a#  [        U5      nU R                  [        SU5        g U R                  [        SS 5        g )Nrq  rl  rm  s      r)   rr  rs  2  ro  r+   c                 8    U R                  [        S[        5      $ )zjThe date and time that any metadata for this resource was last changed. Returned as a UTC datetime object.MetadataDaterf  r   s    r)   xmp_metadata_date XmpInformation.xmp_metadata_date:  s     %%m^_UUr+   c                     U(       a#  [        U5      nU R                  [        SU5        g U R                  [        SS 5        g )Nrv  rl  rm  s      r)   rw  rx  ?  s3    +E2H""=.(K""=.$Gr+   c                 .    U R                  [        S5      $ )z=The name of the first known tool used to create the resource.CreatorTool)r   rg  r   s    r)   xmp_creator_toolXmpInformation.xmp_creator_toolG  s     %%m]CCr+   c                 2    U R                  [        SU5        g )Nr{  )r  rg  r  s     r)   r|  r}  L  s    }mUCr+   c                 .    U R                  [        S5      $ )zGThe common identifier for all versions and renditions of this resource.
DocumentIDr   XMPMM_NAMESPACEr   s    r)   xmpmm_document_id XmpInformation.xmpmm_document_idP       %%o|DDr+   c                 2    U R                  [        SU5        g )Nr  r  r  r  s     r)   r  r  U      eDr+   c                 .    U R                  [        S5      $ )zZAn identifier for a specific incarnation of a document, updated each time a file is saved.
InstanceIDr  r   s    r)   xmpmm_instance_id XmpInformation.xmpmm_instance_idY  r  r+   c                 2    U R                  [        SU5        g )Nr  r  r  s     r)   r  r  ^  r  r+   c                 .    U R                  [        S5      $ )zMThe part of the PDF/A standard that the document conforms to (e.g., 1, 2, 3).partr   PDFAID_NAMESPACEr   s    r)   pdfaid_partXmpInformation.pdfaid_partb  s     %%&6??r+   c                 2    U R                  [        SU5        g )Nr  r  r  r  s     r)   r  r  g  s    /?r+   c                 .    U R                  [        S5      $ )zFThe conformance level within the PDF/A standard (e.g., 'A', 'B', 'U').conformancer  r   s    r)   pdfaid_conformance!XmpInformation.pdfaid_conformancek  s     %%&6FFr+   c                 2    U R                  [        SU5        g )Nr  r  r  s     r)   r  r  p  s    /Fr+   c           	         [        U S5      (       d  0 U l        U R                  S[        5       H  nUR                  nSn UR                  SU5      nUS:X  a  O_X$S-   US-    n[        U5      S:w  d  [        S	 U 5       5      (       d  US-   nMQ  US
U [        [        USS95      -   X$S-   S
 -   nUS-   nMx  UR                  UR                  :X  a  UR                  nOU R                  U5      nX`R                  U'   M     U R                  $ )z
Retrieve custom metadata properties defined in the undocumented pdfx
metadata schema.

Returns:
    A dictionary of key/value items for custom metadata properties.

_custom_propertiesr   r   u   ↂr>   r         c              3   2   #    U  H  o[         ;   v   M     g 7fr&   r   )r9   cs     r)   r;   3XmpInformation.custom_properties.<locals>.<genexpr>  s     2R6a	>6s   N   )r{   )hasattrr  r   PDFX_NAMESPACE	localNamefindrg   allchrr8   r   r   r   rh   )r_   nodekeystartidxhex_idr#   s          r)   custom_properties XmpInformation.custom_propertiest  s    t122&(D#33BGnn((8U3Cby q373F6{a's2R62R/R/R !$a ds)c#f2*>&??#Agi.PC!GE  ==D$7$77 NNE NN40E/4'',) H* &&&r+   c                 h   U R                   R                  [        S5       H!  nUR                  [        S5      U:X  d  M  Us  $    U R                   R                  nUc  [        S5      eUR                  [        S5      nUR                  [        SU5        U R                   R                  U5        U$ )zBGet or create an rdf:Description element with the given about URI.r   r   XMP Document is Nonezrdf:Descriptionz	rdf:about)	r   re   rf   r   ownerDocumentr   createElementNSsetAttributeNSappendChild)r_   r   r   docs       r)   _get_or_create_description)XmpInformation._get_or_create_description  s    MM88VD""=':iG W mm));"#9::""=2CDM;	B!!$'r+   c                 Z    U R                   R                  U5      nU(       a	  X#;   a  X2	 ggg)z<Remove a cached value for a given namespace/name if present.N)r   r   )r_   r   r   r   s       r)   _clear_cache_entry!XmpInformation._clear_cache_entry  s(    ::>>),( )8r+   c                 4   U R                  X5        U R                  5       n[        UR                  X5      5      nU H  nUR	                  U5        M     UR                  X5      =n(       a  UR                  U5        Ub  U R                  R                  nUc  [        S5      eU R                  U5      n	UR                  X SU 35      nUR                  [        U5      5      n
UR                  U
5        UR                  U5        U R                  5         g)z&Set or remove a single metadata value.Nr  r=   )r  r  r   re   removeChildr   removeAttributeNoder   r  r   _get_namespace_prefixr  createTextNoder   r  _update_stream)r_   r   r   r#   r   existing_elementselemexisting_attrr  prefix	text_nodes              r)   r   XmpInformation._set_single_value  s    	0..0 !<!<Y!MN%DT" & !33IDD=D$$]3----C{&'=>>//	:F&&yHAdV2DED**3u:6IY'T"r+   c                    U R                  X5        U R                  5       n[        UR                  X5      5      nU H  nUR	                  U5        M     U(       a  U R
                  R                  nUc  [        S5      eU R                  U5      nUR                  X SU 35      nUR                  [        S5      n	U HU  n
UR                  [        S5      nUR                  [        U
5      5      nUR                  U5        U	R                  U5        MW     UR                  U	5        UR                  U5        U R                  5         g)z+Set or remove bag values (unordered array).Nr  r=   zrdf:Bagrdf:lir  r  r   re   r  r   r  r   r  r  rf   r  r   r  r  )r_   r   r   r   r   r  r  r  r  bagr#   rd   r  s                r)   r   XmpInformation._set_bag_values      	0..0 !<!<Y!MN%DT" & ----C{&'=>>//	:F&&yHAdV2DED%%mY?C((A..s5z:	y)#	   S!T"r+   c                    U R                  X5        U R                  5       n[        UR                  X5      5      nU H  nUR	                  U5        M     U(       a  U R
                  R                  nUc  [        S5      eU R                  U5      nUR                  X SU 35      nUR                  [        S5      n	U HU  n
UR                  [        S5      nUR                  [        U
5      5      nUR                  U5        U	R                  U5        MW     UR                  U	5        UR                  U5        U R                  5         g)z.Set or remove sequence values (ordered array).Nr  r=   zrdf:Seqr  r  )r_   r   r   r   r   r  r  r  r  seqr#   rd   r  s                r)   r	  XmpInformation._set_seq_values  r  r+   c                    U R                  X5        U R                  5       n[        UR                  X5      5      nU H  nUR	                  U5        M     U(       Ga   U R
                  R                  nUc  [        S5      eU R                  U5      nUR                  X SU 35      nUR                  [        S5      n	UR                  5        Hi  u  pUR                  [        S5      nUR                  SU
5        UR                  [        U5      5      nUR                  U5        U	R                  U5        Mk     UR                  U	5        UR                  U5        U R!                  5         g)z*Set or remove language alternative values.Nr  r=   zrdf:Altr  r   )r  r  r   re   r  r   r  r   r  r  rf   itemssetAttributer  r   r  r  )r_   r   r   r   r   r  r  r  r  r   langr#   rd   r  s                 r)   r  "XmpInformation._set_langalt_values  s6   	0..0 !<!<Y!MN%DT" & ----C{&'=>>//	:F&&yHAdV2DED%%mY?C%||~((A
D1..s5z:	y)#  . S!T"r+   c                 .    [         R                  US5      $ )z?Get the appropriate namespace prefix for a given namespace URI.unknown)_NAMESPACE_PREFIX_MAPr   )r_   r   s     r)   r  $XmpInformation._get_namespace_prefix  s    $((I>>r+   c                     U R                   R                  nUc  [        S5      eUR                  SS9nU R                  R                  U5        g)z/Update the stream with the current XML content.Nr  r   )encoding)r   r  r   toxmlr   r   )r_   r  xml_datas      r)   r  XmpInformation._update_stream  sD    mm));"#9::99g9.X&r+   )r  r   r   r   )r$   r`   r&   )r   )r$   N)Dr   r   r   r   r   r   ru   classmethodr   r   r
   r   bytesr   r   r   r   r   
XmlElementrh   r*   r   r   r   r   r   r   r   r   propertyr   setterr   r  rI   r  r  r  r#  r(  r/  r4  r9  r>  rC  rH  rM  rT  r\  ra  rh  rr  rw  r|  r  r  r  r  r  r  r  r  r   r	  r  r  r  r   r'   r+   r)   r`   r`      s}   (} ( (" 	 	 MQ, ,27c58H2I,	,HS HS H HQT H	$ 	$ 	$QT 	$   +4	  SE3J'	
 
#,S  c8K & +4	  SE3J'	
 
$s)	:S  cSVh@X $ =c 3 = = BXd3i%8 BT B B @Xc] @ @ @# @4 @ @ =HT#Y/ = = >$s)!4 > > > K$x'8'8"9: K K ^^
EhtE#x7H7H2H,I'JK 
EPT 
E 
E Ec3h 8 E E FXd38n%= F$ F F >8C= > > >x} > > > Bx} B B B8C= BT B B :Xd3i0 : : ?(49"5 ?$ ? ? ;htCy1 ; ; @8DI#6 @4 @ @ :Xd3i0 : : ?(49"5 ?$ ? ? @8DcN3 @ @ Ac3h 8 AT A A >8C= > > >x} > > > 9HT#Y/ 9 9 >$s)!4 > > > ?(4S>2 ? ? __@xS#X7 @D @ @ 6$s), 6 6 ^^;htCy1 ;d ; ; Ahsm A A A(3- AD A A C C C CHSM Cd C C Ahsm A A A(3- AD A A T(*;*;!< T T FXh.?.?%@ FT F F T(*;*;!< T T FXh.?.?%@ FT F F V8H,=,=#> V V Hx0A0A'B Ht H H D(3- D D Dhsm D D D E8C= E E Ex} E E E E8C= E E Ex} E E E @Xc] @ @ @# @4 @ @ GHSM G G G G$ G G  '4S>  '  'DC  C s t 3 c (3- TX 0 C $s)AT Y] 8 C $s)AT Y] 8S  XdSVX[S[nE] bf :?s ?s ?'r+   )>r   rI   rE   recollections.abcr   stringr   typingr   r   r   r	   r
   r   xml.dom.expatbuilderr   xml.dom.minidomr   r   r  xml.dom.xmlbuilderr   xml.parsers.expatr   r   
_protocolsr   _utilsr   r   r   errorsr   r   r   genericr   r   r   r   rf   r   rg  rS  r  r  r  r  compileVERBOSErA   r"   r   r*   r   rT   r]   r   rn   rp   r`   r'   r+   r)   <module>r     s     	 $   0 $ 1 & 7 . V V E E -   =1..3( 1 5  $55WhF  ** JJ!( CL& (#n %% '% ')* ++, -'( ) Q 1 3 8#4#4 6
3 1 1 
3c 
3 hq#3@CPXZ]Y^`cYcPdd3i$@. $@NQ	'+Y Q	'r+   