a
    �˜ëjh
  ã                   @   sR   d dl mZ d dlmZmZmZmZ d dlm	Z	 dd„ Z
G dd„ dƒZdd	„ ZdS )
é    N)Ú	add_inputÚadd_n_digitsÚ	get_inputÚ
round_list)ÚBooleanOptionalActionc                 C   s<   t | dd� t| ƒ | jdtddd� | jdtdd	d
� d S )NF)Zpagesz--max-depthé   zFMaximum recursion depth to consider when parsing the table of contents)ÚtypeÚdefaultÚhelpz--highlightTzdWhether console ANSI escape sequences may be used for styling or color indication. Defaults to true.)Úactionr	   r
   )r   r   Úadd_argumentÚintr   )Úparser© r   úP/mnt/bigstor/www/usecases/.venv/lib/python3.9/site-packages/pypdfium2_cli/toc.pyÚattach   s    üür   c                   @   s(   e Zd Zdd„ Zdd„ Zedd„ ƒZdS )ÚColorIndicatorc                 C   s   || _ || _d S )N)Ú	indicatorÚsep)Úselfr   r   r   r   r   Ú__init__   s    zColorIndicator.__init__c                 C   s@   t dd„ |D ƒƒ\}}}d|› d|› d|› d�| j d | j S )Nc                 s   s   | ]}t |d  ƒV  qdS )éÿ   N)Úround)Ú.0Úcr   r   r   Ú	<genexpr>$   ó    z*ColorIndicator.__call__.<locals>.<genexpr>z[38;2;ú;Úmz[0m)Útupler   r   )r   ÚcolorÚrÚgÚbr   r   r   Ú__call__#   s    zColorIndicator.__call__c                 C   s   dS )NÚ r   )r    r   r   r   Únoop'   s    zColorIndicator.noopN)Ú__name__Ú
__module__Ú__qualname__r   r$   Ústaticmethodr&   r   r   r   r   r      s   r   c                 C   s^  t | ƒ}| jrtddd�}ntj}|j| jd�D �]&}| ¡ }| ¡ }| ¡ }| 	¡ }|dkrf|d›nd}d|j
 }	|	d	||f 7 }	| ¡ }
|
rØ|
 ¡ }|
 ¡ \}}|	d
|d kr¸|d ndtj |¡t|| jƒf 7 }	n|	d7 }	g }|�r| t|ƒjddd�d  dd¡ ¡ ¡ |�r8| ||ƒdt|| jƒ› � ¡ |�rP|	dd |¡ 7 }	t|	ƒ q0d S )Nu   â¬¤ú )r   )Ú	max_depthr   ú+Ú*z    z[%s] %s -> z%s  # %s %sé   ú?Ú_Ú.)Úmaxsplitú|ZRGBz | z, )r   Z	highlightr   r&   Zget_tocr,   Z	get_titleZ	get_styleZ	get_colorZ	get_countÚlevelZget_destZ	get_indexZget_viewÚpdfium_iZViewmodeToStrÚgetr   Zn_digitsÚappendÚstrÚsplitÚreplaceÚlowerÚjoinÚprint)ÚargsZpdfZicolZbmÚtitleÚstyler    ÚcountZ	count_strÚoutÚdestÚindexZ	view_modeZview_posÚextrasr   r   r   Úmain,   s<    


ý
( rG   )Zpypdfium2.internalZinternalr6   Zpypdfium2_cli._parsersr   r   r   r   Zpypdfium2_cfg.stlr   r   r   rG   r   r   r   r   Ú<module>   s
   