o
    -Ä"j¯y  ã                   @   sæ  d Z ddlZddlZddlZddlmZ ddlmZmZm	Z	m
Z
mZmZ ddlmZ ddlmZ ddlmZ ddlmZ dd	lmZmZ d
dlmZ d
dlmZmZmZ d
dlmZm Z m!Z! d
dl"m#Z#m$Z$ dZ%dZ&dZ'dZ(dZ)dZ*dZ+dZ,dZ-e(de)de*de+de-de,diZ.e /dej0¡Z1e
dƒZ2d e'› d!e(› d"e)› d#e*› d$e+› d%e-› d&e,› d'�Z3d(e2d)e2fd*d+„Z4d(e5d)ejfd,d-„Z6d(ejd)e5fd.d/„Z7e4fd0ed1d2d3e5d4eegef d)e	e8e5  f
d5d6„Z9G d7d8„ d8eƒZ:G d9d2„ d2ee$ƒZ;dS ):z~
Anything related to Extensible Metadata Platform (XMP) metadata.

https://en.wikipedia.org/wiki/Extensible_Metadata_Platform
é    N)ÚIterator)Ú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                 C   s   | S ©N© ©r    r#   r#   úV/home/develop/edictos_py/central_edictos/env/lib/python3.10/site-packages/pypdf/xmp.pyÚ	_identityo   s   r&   c              	   C   s$  t  | ¡}|d u rtd| › �ƒ‚t| d¡ƒ}t| d¡pdƒ}t| d¡p'dƒ}t| d¡p0dƒ}t| d¡p9dƒ}t | d	¡pCd¡}| tj¡}|| d
 }	t|ƒ}
t|	ƒ}| d¡p_d}t	 	||||||
|¡}|dkr�dd„ | 
d¡D ƒ\}}|d9 }|dk r‡|d9 }|t	j||d� }|S )NzInvalid date format: ÚyearÚmonthÚ1ÚdayÚhourÚ0ÚminuteÚsecondi@B ÚtzdÚZc                 s   s   � | ]}t |ƒV  qd S r"   )Úint)Ú.0Úxr#   r#   r%   Ú	<genexpr>†   s   € z"_converter_date.<locals>.<genexpr>ú:éÿÿÿÿr   )ÚhoursÚminutes)Úiso8601ÚmatchÚ
ValueErrorr1   ÚgroupÚdecimalÚDecimalÚto_integralÚROUND_FLOORÚdatetimeÚsplitÚ	timedelta)r    Úmatchesr'   r(   r*   r+   r-   r.   Úseconds_decÚmilliseconds_decÚsecondsÚmillisecondsr/   ÚdtÚ	tzd_hoursÚtzd_minutesr#   r#   r%   Ú_converter_dates   s,   
rL   c                 C   s:   | j dur|  ¡ dur|  tjj¡} | jdd�} |  d¡S )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)rM   Ú	utcoffsetÚ
astimezonerA   ÚtimezoneÚutcÚreplaceÚstrftimer$   r#   r#   r%   Ú_format_datetime_utcŽ   s   
rT   ÚelementÚselfÚXmpInformationÚ	list_typeÚ	converterc           	      C   sX   |   t|¡}g }t|ƒr*|D ]}|  td¡D ]}| |¡}||ƒ}| |¡ qq|S d S )NÚli)ÚgetElementsByTagNameNSÚRDF_NAMESPACEÚlenÚ	_get_textÚappend)	rU   rV   rX   rY   Ú
containersÚretvalÚ	containerÚitemr    r#   r#   r%   Ú_generic_get›   s   
ýrd   c                       sž   e Zd ZdZddee ddf‡ fdd„Zdeded	ee d
ee dedee dee ddfdd„Z	dede
e ddf‡ fdd„Zdeddf‡ fdd„Z‡  ZS )Ú_XmpBuilderac  
    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                    s   t ƒ j|d� d| _d S )N)rf   r   )ÚsuperÚ__init__Ú_element_count)rV   rf   ©Ú	__class__r#   r%   rh   ´   s   
z_XmpBuilder.__init__Úentity_nameÚis_parameter_entityr    ÚbaseÚ	system_idÚ	public_idÚnotation_namec                 C   s   t d|›�ƒ‚)NzForbidden entities: )r   )rV   rl   rm   r    rn   ro   rp   rq   r#   r#   r%   Ú!custom_entity_declaration_handler¸   s   
z-_XmpBuilder.custom_entity_declaration_handlerÚnameÚ
attributesc                    s<   |  j d7  _ | j tkrtdt› d�ƒ‚tƒ j||d� d S )Nr   zXMP metadata exceeds limit of z
 elements.)rs   rt   )ri   ÚXMP_MAX_ELEMENT_COUNTr   rg   Ústart_element_handler)rV   rs   rt   rj   r#   r%   rv   Ä   s   
z!_XmpBuilder.start_element_handlerÚparserc                    s    t ƒ  |¡ | j|_| j|_d S r"   )rg   Úinstallrr   ÚEntityDeclHandlerrv   ÚStartElementHandler)rV   rw   rj   r#   r%   rx   Ê   s   z_XmpBuilder.installr"   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   rh   ÚstrÚboolrr   Úlistrv   r   rx   Ú__classcell__r#   r#   rj   r%   re   ª   s,    	þýüûúùø	
÷re   c                   @   s¾  e Zd ZdZdeddfdd„Zed‚dd„ƒZ	dƒded	e	de
ef ddfd
d„Zde
de
de
dee fdd„Zde
de
dee fdd„Zdede
fdd„Zefde
de
dee
gef dee fdd„Zde
de
deee
  fdd„Zefde
de
deegef deee  fdd„Zde
de
deeeef  fdd„Zedeee
  fdd „ƒZejd!eee
  ddfd"d „ƒZedee
 fd#d$„ƒZejd%ee
 ddfd&d$„ƒZedeee
  fd'd(„ƒZ e jd!eee
  ddfd)d(„ƒZ edeee!j!  fd*d+„ƒZ"e"jd!eee	e
e!j!f   ddfd,d+„ƒZ"edeee
e
f  fd-d.„ƒZ#e#jd!eee
e
f  ddfd/d.„ƒZ#edee
 fd0d1„ƒZ$e$jd%ee
 ddfd2d1„ƒZ$edee
 fd3d4„ƒZ%e%jd%ee
 ddfd5d4„ƒZ%edeee
  fd6d7„ƒZ&e&jd!eee
  ddfd8d7„ƒZ&edeee
  fd9d:„ƒZ'e'jd!eee
  ddfd;d:„ƒZ'edeee
  fd<d=„ƒZ(e(jd!eee
  ddfd>d=„ƒZ(edeee
e
f  fd?d@„ƒZ)e)jd!eee
e
f  ddfdAd@„ƒZ)edee
 fdBdC„ƒZ*e*jd%ee
 ddfdDdC„ƒZ*edeee
  fdEdF„ƒZ+e+jd!eee
  ddfdGdF„ƒZ+edeee
e
f  fdHdI„ƒZ,e,jd!eee
e
f  ddfdJdI„ƒZ,edeee
  fdKdL„ƒZ-e-jd!eee
  ddfdMdL„ƒZ-edee
 fdNdO„ƒZ.e.jd%ee
 ddfdPdO„ƒZ.edee
 fdQdR„ƒZ/e/jd%ee
 ddfdSdR„ƒZ/edee
 fdTdU„ƒZ0e0jd%ee
 ddfdVdU„ƒZ0edee!j! fdWdX„ƒZ1e1jd%ee!j! ddfdYdX„ƒZ1edee!j! fdZd[„ƒZ2e2jd%ee!j! ddfd\d[„ƒZ2edee!j! fd]d^„ƒZ3e3jd%ee!j! ddfd_d^„ƒZ3edee
 fd`da„ƒZ4e4jd%ee
 ddfdbda„ƒZ4edee
 fdcdd„ƒZ5e5jd%ee
 ddfdedd„ƒZ5edee
 fdfdg„ƒZ6e6jd%ee
 ddfdhdg„ƒZ6edee
 fdidj„ƒZ7e7jd%ee
 ddfdkdj„ƒZ7edee
 fdldm„ƒZ8e8jd%ee
 ddfdndm„ƒZ8edeeef fdodp„ƒZ9d„de
defdrds„Z:de
de
ddfdtdu„Z;de
de
d%ee
 ddfdvdw„Z<de
de
d!eee
  ddfdxdy„Z=de
de
d!eee
  ddfdzd{„Z>de
de
d!eee
e
f  ddfd|d}„Z?de
de
fd~d„Z@d…d€d�„ZAdS )†rW   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              
   C   sŽ   || _ z | j  ¡ }t|ƒ }tkrtd|› dt› d�ƒ‚tƒ  |¡}W n ttfy8 } zt	d|› �ƒ‚d }~ww | 
td¡d | _i | _d S )NzXMP stream size z exceeds limit of Ú.z#XML in XmpInformation was invalid: ÚRDFr   )rƒ   Úget_datar]   ÚXMP_MAX_INPUT_LENGTHr   re   ÚparseStringÚAttributeErrorr   r   r[   r\   Úrdf_rootÚcache)rV   rƒ   ÚdataÚlengthÚdoc_rootÚer#   r#   r%   rh   Û   s    
€ÿÿþ
zXmpInformation.__init__c                 C   s"   t ddƒ}| t d¡¡ | |ƒS )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ƒ   r#   r#   r%   Úcreateé   s   
zXmpInformation.createÚencryption_keyc                 C   s.   t dddƒ |d urtddƒ | j |¡ d S )Nú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)rV   rƒ   r–   r#   r#   r%   r˜   õ   s   ýÿr—   Ú	about_uriÚ	namespacers   c                 c   sV   � | j  td¡D ] }| td¡|kr(| ||¡}|d ur|V  | ||¡E d H  qd S ©NÚDescriptionÚabout)rŠ   r[   r\   ÚgetAttributeNSÚgetAttributeNodeNS)rV   r™   rš   rs   ÚdescÚattrr#   r#   r%   Úget_element  s   €€ûzXmpInformation.get_elementc                 c   sx   � | j  td¡D ]1}| td¡|kr9t|jjƒD ]}|j |¡}|r*|j|kr*|V  q|j	D ]
}|j|kr8|V  q.qd S r›   )
rŠ   r[   r\   rž   Úrangert   r�   rc   ÚnamespaceURIÚ
childNodes)rV   r™   rš   r    Úir¡   Úchildr#   r#   r%   Úget_nodes_in_namespace  s   €€

€øz%XmpInformation.get_nodes_in_namespacerU   c                 C   s*   d}|j D ]}|j|jkr||j7 }q|S ©NÚ )r¥   ÚnodeTypeÚ	TEXT_NODErŒ   )rV   rU   Útextr§   r#   r#   r%   r^     s   

€zXmpInformation._get_textrY   c                 C   s|   | j  |i ¡ |¡}|r|S d }|  d||¡D ]}|j|jkr#|j}n|  |¡} |d ur1||ƒ}| j  |i ¡}|||< |S r©   )r‹   Úgetr¢   r«   ÚATTRIBUTE_NODEÚ	nodeValuer^   Ú
setdefault)rV   rš   rs   rY   Úcachedr    rU   Úns_cacher#   r#   r%   Ú_get_single_value  s   
z XmpInformation._get_single_valuec           	      C   sŽ   | j  |i ¡ |¡}|rttt |ƒS g }|  d||¡D ]}t|| dd� }d ur/| |¡ q|  |¡}| 	|¡ q| j  
|i ¡}|||< |S )Nrª   ÚBag©rX   )r‹   r®   r   r�   r   r¢   rd   Úextendr^   r_   r±   )	rV   rš   rs   r²   ra   rU   Úbagsr    r³   r#   r#   r%   Ú_getter_bag3  s   
zXmpInformation._getter_bagc                 C   s¶   | j  |i ¡ |¡}|rttt |ƒS g }|  d||¡D ]1}t|| d|d� }d ur0| |¡ qt|| dd� }d urA| |¡ q||  |¡ƒ}	| 	|	¡ q| j  
|i ¡}
||
|< |S )Nrª   ÚSeq)rX   rY   rµ   r¶   )r‹   r®   r   r�   r   r¢   rd   r·   r^   r_   r±   )rV   rš   rs   rY   r²   ra   rU   Úseqsr¸   r    r³   r#   r#   r%   Ú_get_seq_valuesB  s   zXmpInformation._get_seq_valuesc                 C   s´   | j  |i ¡ |¡}|rttttf |ƒS i }|  d||¡D ].}| td¡}t|ƒrE|D ]}| td¡D ]}|  	|¡}	|	|| 
d¡< q4q,q|  	|¡|d< q| j  |i ¡}
||
|< |S )Nrª   ÚAltrZ   úxml:langz	x-default)r‹   r®   r   Údictr   r¢   r[   r\   r]   r^   ÚgetAttributer±   )rV   rš   rs   r²   ra   rU   ÚaltsÚaltrc   r    r³   r#   r#   r%   Ú_get_langalt_values_  s"   
þÿz"XmpInformation._get_langalt_valuesc                 C   ó   |   td¡S )z6Contributors to the resource (other than the authors).Úcontributor©r¹   ÚDC_NAMESPACE©rV   r#   r#   r%   Údc_contributorq  ó   zXmpInformation.dc_contributorÚvaluesc                 C   ó   |   td|¡ d S )NrÅ   ©Ú_set_bag_valuesrÇ   ©rV   rË   r#   r#   r%   rÉ   v  ó   c                 C   rÄ   )z4Text describing the extent or scope of the resource.Úcoverage©r´   rÇ   rÈ   r#   r#   r%   Údc_coveragez  rÊ   zXmpInformation.dc_coverager    c                 C   rÌ   )NrÑ   ©Ú_set_single_valuerÇ   ©rV   r    r#   r#   r%   rÓ     rÐ   c                 C   rÄ   )zVA sorted array of names of the authors of the resource, listed in order of precedence.Úcreator)r¼   rÇ   rÈ   r#   r#   r%   Ú
dc_creatorƒ  rÊ   zXmpInformation.dc_creatorc                 C   rÌ   )Nr×   )Ú_set_seq_valuesrÇ   rÏ   r#   r#   r%   rØ   ˆ  rÐ   c                 C   ó   |   tdt¡S )zXA sorted array of dates of significance to the resource. The dates and times are in UTC.Údate)r¼   rÇ   rL   rÈ   r#   r#   r%   Údc_dateŒ  ó   zXmpInformation.dc_datec                 C   sd   |d u r|   tdd ¡ d S g }|D ]}t|tjƒr!| t|ƒ¡ q| t|ƒ¡ q|   td|¡ d S )NrÛ   )rÙ   rÇ   Ú
isinstancerA   r_   rT   r   )rV   rË   Údate_stringsr    r#   r#   r%   rÜ   ‘  s   c                 C   rÄ   )zSA language-keyed dictionary of textual descriptions of the content of the resource.Údescription©rÃ   rÇ   rÈ   r#   r#   r%   Údc_descriptionž  rÊ   zXmpInformation.dc_descriptionc                 C   rÌ   )Nrà   ©Ú_set_langalt_valuesrÇ   rÏ   r#   r#   r%   râ   £  rÐ   c                 C   rÄ   )zThe mime-type of the resource.ÚformatrÒ   rÈ   r#   r#   r%   Ú	dc_format§  rÊ   zXmpInformation.dc_formatc                 C   rÌ   )Nrå   rÔ   rÖ   r#   r#   r%   ræ   ¬  rÐ   c                 C   rÄ   )z"Unique identifier of the resource.Ú
identifierrÒ   rÈ   r#   r#   r%   Údc_identifier°  rÊ   zXmpInformation.dc_identifierc                 C   rÌ   )Nrç   rÔ   rÖ   r#   r#   r%   rè   µ  rÐ   c                 C   rÄ   )zAAn unordered array specifying the languages used in the resource.ÚlanguagerÆ   rÈ   r#   r#   r%   Údc_language¹  rÊ   zXmpInformation.dc_languagec                 C   rÌ   )Nré   rÍ   rÏ   r#   r#   r%   rê   ¾  rÐ   c                 C   rÄ   )z&An unordered array of publisher names.Ú	publisherrÆ   rÈ   r#   r#   r%   Údc_publisherÂ  rÊ   zXmpInformation.dc_publisherc                 C   rÌ   )Nrë   rÍ   rÏ   r#   r#   r%   rì   Ç  rÐ   c                 C   rÄ   )zLAn unordered array of text descriptions of relationships to other documents.ÚrelationrÆ   rÈ   r#   r#   r%   Údc_relationË  rÊ   zXmpInformation.dc_relationc                 C   rÌ   )Nrí   rÍ   rÏ   r#   r#   r%   rî   Ð  rÐ   c                 C   rÄ   )z`A language-keyed dictionary of textual descriptions of the rights the user has to this resource.Úrightsrá   rÈ   r#   r#   r%   Ú	dc_rightsÔ  rÊ   zXmpInformation.dc_rightsc                 C   rÌ   )Nrï   rã   rÏ   r#   r#   r%   rð   Ù  rÐ   c                 C   rÄ   )zCUnique identifier of the work from which this resource was derived.ÚsourcerÒ   rÈ   r#   r#   r%   Ú	dc_sourceÝ  rÊ   zXmpInformation.dc_sourcec                 C   rÌ   )Nrñ   rÔ   rÖ   r#   r#   r%   rò   â  rÐ   c                 C   rÄ   )z\An unordered array of descriptive phrases or keywords that specify the topic of the content.ÚsubjectrÆ   rÈ   r#   r#   r%   Ú
dc_subjectæ  rÊ   zXmpInformation.dc_subjectc                 C   rÌ   )Nró   rÍ   rÏ   r#   r#   r%   rô   ë  rÐ   c                 C   rÄ   )z9A language-keyed dictionary of the title of the resource.Útitlerá   rÈ   r#   r#   r%   Údc_titleï  rÊ   zXmpInformation.dc_titlec                 C   rÌ   )Nrõ   rã   rÏ   r#   r#   r%   rö   ô  rÐ   c                 C   rÄ   )z@An unordered array of textual descriptions of the document type.ÚtyperÆ   rÈ   r#   r#   r%   Údc_typeø  rÊ   zXmpInformation.dc_typec                 C   rÌ   )Nr÷   rÍ   rÏ   r#   r#   r%   rø   ý  rÐ   c                 C   rÄ   )z:An unformatted text string representing document keywords.ÚKeywords©r´   ÚPDF_NAMESPACErÈ   r#   r#   r%   Úpdf_keywords  rÊ   zXmpInformation.pdf_keywordsc                 C   rÌ   )Nrù   ©rÕ   rû   rÖ   r#   r#   r%   rü     rÐ   c                 C   rÄ   )z-The PDF file version, for example 1.0 or 1.3.Ú
PDFVersionrú   rÈ   r#   r#   r%   Úpdf_pdfversion
  rÊ   zXmpInformation.pdf_pdfversionc                 C   rÌ   )Nrþ   rý   rÖ   r#   r#   r%   rÿ     rÐ   c                 C   rÄ   )z6The name of the tool that saved the document as a PDF.ÚProducerrú   rÈ   r#   r#   r%   Úpdf_producer  rÊ   zXmpInformation.pdf_producerc                 C   rÌ   )Nr   rý   rÖ   r#   r#   r%   r    rÐ   c                 C   rÚ   )zYThe date and time the resource was originally created. Returned as a UTC datetime object.Ú
CreateDate©r´   ÚXMP_NAMESPACErL   rÈ   r#   r#   r%   Úxmp_create_date  rÝ   zXmpInformation.xmp_create_datec                 C   ó0   |rt |ƒ}|  td|¡ d S |  tdd ¡ d S )Nr  ©rT   rÕ   r  ©rV   r    Údate_strr#   r#   r%   r  !  ó   c                 C   rÚ   )zTThe date and time the resource was last modified. Returned as a UTC datetime object.Ú
ModifyDater  rÈ   r#   r#   r%   Úxmp_modify_date)  rÝ   zXmpInformation.xmp_modify_datec                 C   r  )Nr  r  r  r#   r#   r%   r  .  r
  c                 C   rÚ   )zjThe date and time that any metadata for this resource was last changed. Returned as a UTC datetime object.ÚMetadataDater  rÈ   r#   r#   r%   Úxmp_metadata_date6  rÝ   z XmpInformation.xmp_metadata_datec                 C   r  )Nr  r  r  r#   r#   r%   r  ;  r
  c                 C   rÄ   )z=The name of the first known tool used to create the resource.ÚCreatorTool)r´   r  rÈ   r#   r#   r%   Úxmp_creator_toolC  rÊ   zXmpInformation.xmp_creator_toolc                 C   rÌ   )Nr  )rÕ   r  rÖ   r#   r#   r%   r  H  rÐ   c                 C   rÄ   )zGThe common identifier for all versions and renditions of this resource.Ú
DocumentID©r´   ÚXMPMM_NAMESPACErÈ   r#   r#   r%   Úxmpmm_document_idL  rÊ   z XmpInformation.xmpmm_document_idc                 C   rÌ   )Nr  ©rÕ   r  rÖ   r#   r#   r%   r  Q  rÐ   c                 C   rÄ   )zZAn identifier for a specific incarnation of a document, updated each time a file is saved.Ú
InstanceIDr  rÈ   r#   r#   r%   Úxmpmm_instance_idU  rÊ   z XmpInformation.xmpmm_instance_idc                 C   rÌ   )Nr  r  rÖ   r#   r#   r%   r  Z  rÐ   c                 C   rÄ   )zMThe part of the PDF/A standard that the document conforms to (e.g., 1, 2, 3).Úpart©r´   ÚPDFAID_NAMESPACErÈ   r#   r#   r%   Úpdfaid_part^  rÊ   zXmpInformation.pdfaid_partc                 C   rÌ   )Nr  ©rÕ   r  rÖ   r#   r#   r%   r  c  rÐ   c                 C   rÄ   )zFThe conformance level within the PDF/A standard (e.g., 'A', 'B', 'U').Úconformancer  rÈ   r#   r#   r%   Úpdfaid_conformanceg  rÊ   z!XmpInformation.pdfaid_conformancec                 C   rÌ   )Nr  r  rÖ   r#   r#   r%   r  l  rÐ   c                 C   sª   t | dƒsRi | _|  dt¡D ]C}|j}	 | d¡}|dkrn|d|… tt||d |d … d	d
�ƒ ||d d…  }q|j|j	krG|j
}n|  |¡}|| j|< q| jS )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ª   Tu   â†‚r6   Nr   é   é   )rn   )Úhasattrr  r¨   ÚPDFX_NAMESPACEÚ	localNameÚfindÚchrr1   r«   r¯   r°   r^   )rV   ÚnodeÚkeyÚidxr    r#   r#   r%   Úcustom_propertiesp  s(   



ÿþÿû

z XmpInformation.custom_propertiesrª   c                 C   sn   | j  td¡D ]}| td¡|kr|  S q| j j}|du r"tdƒ‚| td¡}| td|¡ | j  |¡ |S )zBGet or create an rdf:Description element with the given about URI.rœ   r�   NúXMP Document is Nonezrdf:Descriptionz	rdf:about)	rŠ   r[   r\   rž   ÚownerDocumentr   ÚcreateElementNSÚsetAttributeNSÚappendChild)rV   r™   r    Údocr#   r#   r%   Ú_get_or_create_description�  s   ÿz)XmpInformation._get_or_create_descriptionc                 C   s*   | j  |¡}|r||v r||= dS dS dS )z<Remove a cached value for a given namespace/name if present.N)r‹   r®   )rV   rš   rs   r³   r#   r#   r%   Ú_clear_cache_entry�  s   
ÿz!XmpInformation._clear_cache_entryc                 C   sÀ   |   ||¡ |  ¡ }t| ||¡ƒ}|D ]}| |¡ q| ||¡ }r)| |¡ |durZ| jj}|du r9t	dƒ‚|  
|¡}	| ||	› d|› �¡}| t|ƒ¡}
| |
¡ | |¡ |  ¡  dS )z&Set or remove a single metadata value.Nr+  r5   )r2  r1  r�   r[   ÚremoveChildrŸ   ÚremoveAttributeNoderŠ   r,  r   Ú_get_namespace_prefixr-  ÚcreateTextNoder   r/  Ú_update_stream)rV   rš   rs   r    r    Úexisting_elementsÚelemÚexisting_attrr0  ÚprefixÚ	text_noder#   r#   r%   rÕ   £  s"   



z XmpInformation._set_single_valuec                 C   óØ   |   ||¡ |  ¡ }t| ||¡ƒ}|D ]}| |¡ q|rf| jj}|du r*tdƒ‚|  |¡}| 	||› d|› �¡}| 	t
d¡}	|D ]}
| 	t
d¡}| t|
ƒ¡}| |¡ |	 |¡ qB| |	¡ | |¡ |  ¡  dS )z+Set or remove bag values (unordered array).Nr+  r5   zrdf:Bagúrdf:li©r2  r1  r�   r[   r3  rŠ   r,  r   r5  r-  r\   r6  r   r/  r7  )rV   rš   rs   rË   r    r8  r9  r0  r;  Úbagr    rZ   r<  r#   r#   r%   rÎ   »  ó(   



zXmpInformation._set_bag_valuesc                 C   r=  )z.Set or remove sequence values (ordered array).Nr+  r5   zrdf:Seqr>  r?  )rV   rš   rs   rË   r    r8  r9  r0  r;  Úseqr    rZ   r<  r#   r#   r%   rÙ   ×  rA  zXmpInformation._set_seq_valuesc                 C   sì   |   ||¡ |  ¡ }t| ||¡ƒ}|D ]}| |¡ q|rp| jj}|du r*tdƒ‚|  |¡}| 	||› d|› �¡}| 	t
d¡}	| ¡ D ]!\}
}| 	t
d¡}| d|
¡ | t|ƒ¡}| |¡ |	 |¡ qD| |	¡ | |¡ |  ¡  dS )z*Set or remove language alternative values.Nr+  r5   zrdf:Altr>  r¾   )r2  r1  r�   r[   r3  rŠ   r,  r   r5  r-  r\   ÚitemsÚsetAttributer6  r   r/  r7  )rV   rš   rs   rË   r    r8  r9  r0  r;  rÂ   Úlangr    rZ   r<  r#   r#   r%   rä   ó  s*   



z"XmpInformation._set_langalt_valuesc                 C   s   t  |d¡S )z?Get the appropriate namespace prefix for a given namespace URI.Úunknown)Ú_NAMESPACE_PREFIX_MAPr®   )rV   rš   r#   r#   r%   r5    s   z$XmpInformation._get_namespace_prefixc                 C   s4   | j j}|du rtdƒ‚|jdd�}| j |¡ dS )z/Update the stream with the current XML content.Nr+  r�   )Úencoding)rŠ   r,  r   Útoxmlrƒ   r‘   )rV   r0  Úxml_datar#   r#   r%   r7    s
   zXmpInformation._update_stream)r!   rW   r"   )rª   )r!   N)Br{   r|   r}   r~   r   rh   Úclassmethodr•   r   r   r   Úbytesr˜   r   r   r¢   r¨   Ú
XmlElementr^   r&   r   r   r´   r�   r¹   r¼   r¿   rÃ   ÚpropertyrÉ   ÚsetterrÓ   rØ   rA   rÜ   râ   ræ   rè   rê   rì   rî   rð   rò   rô   rö   rø   rü   rÿ   r  r  r  r  r  r  r  r  r  r*  r1  r2  rÕ   rÎ   rÙ   rä   r5  r7  r#   r#   r#   r%   rW   Ñ   s0   	ÿÿÿ
þüþýü
ûüþýü

û"&   ""&)<r~   rA   r=   ÚreÚcollections.abcr   Útypingr   r   r   r   r   r   Úxml.dom.expatbuilderr	   Úxml.dom.minidomr
   r   rM  Úxml.dom.xmlbuilderr   Úxml.parsers.expatr   r   Ú
_protocolsr   Ú_utilsr   r   r   Úerrorsr   r   r   Úgenericr   r   r‡   ru   r\   rÇ   r  rû   r  r#  r  rG  ÚcompileÚVERBOSEr9   r   r’   r&   r   rL   rT   r�   rd   re   rW   r#   r#   r#   r%   Ú<module>   sˆ     ú	ðþüûúùø	÷ÿÿÿÿÿ

þ'