o
    ¾Ùøiò  ã                   @   s¦   d dl Z d dlZd dlmZ d dlmZmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZ e d¡Ze  e¡Zd	ed
efdd„Zded
dfdd„ZG dd„ dƒZdS )é    N)ÚIterable)ÚClassVarÚcast)Úglyphname2unicode)ÚENCODING©ÚPDFKeyError)Ú	PSLiteralz[0-9a-fA-F]+ÚnameÚreturnc                    s@  t | tƒstd| › dt| ƒ› �ƒ‚|  d¡d } |  d¡}t|ƒdkr+d tt|ƒ¡S | t	v r3t	|  S |  
d¡rm|  d¡‰ t ˆ ¡rltˆ ƒd	 dkrl‡ fd
d„tdtˆ ƒd	ƒD ƒ}|D ]}t|ƒ q[tt|ƒ}d |¡S n+|  
d¡r˜|  d¡}t |¡r˜d	t|ƒ  krˆdkr˜n nt|dd�}t|ƒ t|ƒS td| › d�ƒ‚)a·  Converts Adobe glyph names to Unicode numbers.

    In contrast to the specification, this raises a KeyError instead of return
    an empty string when the key is unknown.
    This way the caller must explicitly define what to do
    when there is not a match.

    Reference:
    https://github.com/adobe-type-tools/agl-specification#2-the-mapping

    :returns unicode character if name resembles something,
    otherwise a KeyError
    z Could not convert unicode name "z?" to character because it should be of type str but is of type Ú.r   Ú_é   Ú Úunié   c                    s$   g | ]}t ˆ ||d  … dd�‘qS )r   é   ©Úbase)Úint)Ú.0Úi©Úname_without_uni© ú`/home/develop/edictos_py/central_edictos/env/lib/python3.10/site-packages/pdfminer/encodingdb.pyÚ
<listcomp>1   s    ÿÿz name2unicode.<locals>.<listcomp>Úué   r   r   z6" to character because it does not match specification)Ú
isinstanceÚstrr   ÚtypeÚsplitÚlenÚjoinÚmapÚname2unicoder   Ú
startswithÚstripÚHEXADECIMALÚmatchÚrangeÚ#raise_key_error_for_invalid_unicodeÚchrr   )r
   Ú
componentsÚunicode_digitsÚdigitÚ
charactersÚname_without_uÚunicode_digitr   r   r   r&      s@   
ÿÿ



þ


€

&
ÿr&   r3   c                 C   s.   d|   k r
dk rn dS t d| › d�ƒ‚dS )z©Unicode values should not be in the range D800 through DFFF because
    that is used for surrogate pairs in UTF-16

    :raises KeyError if unicode digit is invalid
    iÿ×  i à  zUnicode digit z8 is invalid because it is in the range D800 through DFFFNr   )r3   r   r   r   r,   H   s
   
ÿÿr,   c                
   @   s  e Zd ZU i Zeeeef  ed< i Z	eeeef  ed< i Z
eeeef  ed< i Zeeeef  ed< eD ]#\ZZZZZeeƒZerHeee< erNee	e< erTee
e< erZeee< q7ee	e
edœZeeeeeef f  ed< e	dded	ee dB d
eeef fdd„ƒZdS )Ú
EncodingDBÚstd2unicodeÚmac2unicodeÚwin2unicodeÚpdf2unicode)ÚStandardEncodingÚMacRomanEncodingÚWinAnsiEncodingÚPDFDocEncodingÚ	encodingsNr
   Údiffr   c                 C   s    | j  || j¡}|rN| ¡ }d}|D ];}t|tƒr|}qt|tƒrMzttt	|j
ƒƒ||< W n ttfyH } zt t	|ƒ¡ W Y d }~nd }~ww |d7 }q|S )Nr   r   )r=   Úgetr5   Úcopyr   r   r	   r&   r   r    r
   ÚKeyErrorÚ
ValueErrorÚlogÚdebug)Úclsr
   r>   Úcid2unicodeÚcidÚxÚer   r   r   Úget_encodingl   s"   

€ÿ€zEncodingDB.get_encoding)N)Ú__name__Ú
__module__Ú__qualname__r5   r   Údictr   r    Ú__annotations__r6   r7   r8   r   r
   ÚstdÚmacÚwinÚpdfr&   Úcr=   Úclassmethodr   ÚobjectrJ   r   r   r   r   r4   U   s<   
 €"üýþ
ý
ür4   )ÚloggingÚreÚcollections.abcr   Útypingr   r   Úpdfminer.glyphlistr   Úpdfminer.latin_encr   Úpdfminer.pdfexceptionsr   Úpdfminer.psparserr	   Úcompiler)   Ú	getLoggerrK   rC   r    r&   r   r,   r4   r   r   r   r   Ú<module>   s    

8