o
     e                  	   @   s   d dl 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 g dZdgZg dZ	dd	eee  d
eee  deegef fddZdedefddZG dd dZdS )    N)AnyCallableDictListOptionalTuple)	PSLiteral   )decode_text)zutf-8zlatin-1zutf-16zutf-16leobject_type)
page_numberx0x1y0y1doctoptopbottomwidthheightinclude_attrsexclude_attrsreturnc                    s   | d ur|d urt d| d urtt|  fddS |d ur@t|tt}t|r6t dt| t|  fddS dd S )NzDCannot specify `include_attrs` and `exclude_attrs` at the same time.c                    s   |  v S N attr)inclr   E/var/www/html/venv/lib/python3.10/site-packages/pdfplumber/convert.py<lambda>+       z!get_attr_filter.<locals>.<lambda>z*Cannot exclude these required properties: c                    s   |  vS r   r   r   )exclr   r   r   4   r    c                 S   s   dS )NTr   r   r   r   r   r   7   s    )
ValueErrorsetCSV_COLS_REQUIREDintersectionlenlist)r   r   nonexcludabler   )r!   r   r   get_attr_filter!   s    r)   datac                 C   s   t | dS )Nascii)base64	b64encodedecode)r*   r   r   r   to_b64:   s   r/   c                	   @   s  e Zd Z			ddee deee  deee  fddZdedefd	d
Z	de
de
fddZdedefddZdee dee fddZdeedf deedf fddZdeeef deeef fddZdedeeef fddZdedefddZdedee fddZdS )
SerializerN	precisionr   r   c                 C   s   || _ t||d| _d S )N)r   r   )r1   r)   attr_filter)selfr1   r   r   r   r   r   __init__?   s   zSerializer.__init__objr   c                 C   sP   |d u rd S t |}|ttfv r|S t| d|j d }|d ur$||S t|S )Ndo_)typeintstrgetattr__name__)r3   r5   tfnr   r   r   	serializeK   s   zSerializer.serializexc                 C   s   | j d u r|S t|| j S r   )r1   roundr3   r?   r   r   r   do_float^   s   zSerializer.do_floatc                 C   s   t |S r   )r8   rA   r   r   r   do_boola   s   zSerializer.do_boolc                       t  fdd|D S )Nc                 3       | ]}  |V  qd S r   r>   .0r?   r3   r   r   	<genexpr>e       z%Serializer.do_list.<locals>.<genexpr>)r'   r3   r5   r   rI   r   do_listd      zSerializer.do_list.c                    rD   )Nc                 3   rE   r   rF   rG   rI   r   r   rJ   h   rK   z&Serializer.do_tuple.<locals>.<genexpr>)tuplerL   r   rI   r   do_tupleg   rN   zSerializer.do_tuplec                    s8   d|  v r fdd| D S  fdd| D S )Nr   c                    s&   i | ]\}}  |r| |qS r   )r2   r>   rH   kvrI   r   r   
<dictcomp>l   s   & z&Serializer.do_dict.<locals>.<dictcomp>c                    s   i | ]
\}}|  |qS r   rF   rQ   rI   r   r   rT   n   s    )keysitemsrL   r   rI   r   do_dictj   s   zSerializer.do_dictc                 C   s   dt |jiS )Nrawdata)r/   rX   rL   r   r   r   do_PDFStreamp   s   zSerializer.do_PDFStreamc                 C   s
   t |jS r   )r
   namerL   r   r   r   do_PSLiterals   s   
zSerializer.do_PSLiteralc              	   C   sB   t D ]}z||W   S  ty   Y  d S w |t d  d S )Nr   )ENCODINGS_TO_TRYr.   UnicodeDecodeError)r3   r5   er   r   r   do_bytesv   s   zSerializer.do_bytes)NNN)r;   
__module____qualname__r   r8   r   r9   r4   r   r>   floatrB   boolrC   rM   r   rP   r   rW   rY   r   r[   bytesr_   r   r   r   r   r0   >   s(    


""r0   )NN)r,   typingr   r   r   r   r   r   pdfminer.psparserr   utilsr
   r\   r$   CSV_COLS_TO_PREPENDr9   rc   r)   rd   r/   r0   r   r   r   r   <module>   s$     


