o
    Ñ­jè  ã                   @   sö   d Z ddlZddlZddlZddlZddlmZ ddlmZ ddl	m
Z
 ddlmZ g d¢eeƒ Zi Zi Zdd	„ Zd
d„ Zdd„ Zdd„ Zdd„ Zddd„Zdd„ ZG dd„ dejƒZeje ZeeƒZej ej¡ eeje< e`e`e`e`dS )zÂ
    pygments.formatters
    ~~~~~~~~~~~~~~~~~~~

    Pygments formatters.

    :copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
é    N)Úbasename)Ú
FORMATTERS)Úfind_plugin_formatters)ÚClassNotFound)Úget_formatter_by_nameÚget_formatter_for_filenameÚget_all_formattersÚload_formatter_from_filec                 C   s8   |t vrt t |¡¡ }t |< | | ¡S t |  | ¡S )zBReturn whether the supplied file name fn matches pattern filename.)Ú_pattern_cacheÚreÚcompileÚfnmatchÚ	translateÚmatch)ÚfnÚglobÚpattern© r   úY/var/www/html/CropPilot/venv/lib/python3.10/site-packages/pygments/formatters/__init__.pyÚ_fn_matches   s   
r   c                 C   s4   t | dddgƒ}|jD ]}t||ƒ}|t|j< qdS )z4Load a formatter (and all others in the module too).NÚ__all__)Ú
__import__r   ÚgetattrÚ_formatter_cacheÚname)Úmodule_nameÚmodÚformatter_nameÚclsr   r   r   Ú_load_formatters$   s
   

þr   c                  c   sP   � t  ¡ D ]} | d tvrt| d ƒ t| d  V  qtƒ D ]\}}|V  qdS )z-Return a generator for all formatter classes.é   r   N)r   Úvaluesr   r   r   )ÚinfoÚ_Ú	formatterr   r   r   r   ,   s   €ÿr   c                 C   sb   t  ¡ D ]\}}}}}| |v r|tvrt|ƒ t|   S qtƒ D ]\}}| |jv r.|  S q!dS )zALookup a formatter by alias.

    Returns None if not found.
    N)r   r!   r   r   r   Úaliases)Úaliasr   r   r%   r#   r   r   r   r   Úfind_formatter_class7   s   ý
ÿÿr'   c                 K   s,   t | ƒ}|du rtd| ›�ƒ‚|di |¤ŽS )a  
    Return an instance of a :class:`.Formatter` subclass that has `alias` in its
    aliases list. The formatter is given the `options` at its instantiation.

    Will raise :exc:`pygments.util.ClassNotFound` if no formatter with that
    alias is found.
    Nzno formatter found for name r   )r'   r   )Ú_aliasÚoptionsr   r   r   r   r   F   s   r   ÚCustomFormatterc              
   K   sÐ   z8i }t | dƒ�}t| ¡ |ƒ W d  ƒ n1 sw   Y  ||vr-td|› d| › �ƒ‚|| }|di |¤ŽW S  tyN } z
td| › d|› �ƒ‚d}~w tyU   ‚  tyg } ztd|› �ƒ‚d}~ww )	a#  
    Return a `Formatter` subclass instance loaded from the provided file, relative
    to the current directory.

    The file is expected to contain a Formatter class named ``formattername``
    (by default, CustomFormatter). Users should be very careful with the input, because
    this method is equivalent to running ``eval()`` on the input file. The formatter is
    given the `options` at its instantiation.

    :exc:`pygments.util.ClassNotFound` is raised if there are any errors loading
    the formatter.

    .. versionadded:: 2.2
    ÚrbNz	no valid z class found in zcannot read z: z%error when loading custom formatter: r   )ÚopenÚexecÚreadr   ÚOSErrorÚ	Exception)ÚfilenameÚformatternamer)   Úcustom_namespaceÚfÚformatter_classÚerrr   r   r   r	   T   s$   ÿ€€ÿr	   c           	      K   s¨   t | ƒ} t ¡ D ]&\}}}}}|D ]}t| |ƒr-|tvr t|ƒ t| di |¤Ž    S qqtƒ D ]\}}|jD ]}t| |ƒrK|di |¤Ž    S q9q2td| ›�ƒ‚)a  
    Return a :class:`.Formatter` subclass instance that has a filename pattern
    matching `fn`. The formatter is given the `options` at its instantiation.

    Will raise :exc:`pygments.util.ClassNotFound` if no formatter for that filename
    is found.
    z!no formatter found for file name Nr   )	r   r   r!   r   r   r   r   Ú	filenamesr   )	r   r)   Úmodnamer   r#   r7   r1   Ú_namer   r   r   r   r   v   s    
ýÿ

ÿÿr   c                   @   s   e Zd ZdZdd„ ZdS )Ú_automodulez Automatically import formatters.c                 C   s>   t  |¡}|rt|d ƒ t|d  }t| ||ƒ |S t|ƒ‚)Nr   r    )r   Úgetr   r   ÚsetattrÚAttributeError)Úselfr   r"   r   r   r   r   Ú__getattr__�   s   
z_automodule.__getattr__N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r?   r   r   r   r   r:   Œ   s    r:   )r*   ) rC   r   ÚsysÚtypesr   Úos.pathr   Úpygments.formatters._mappingr   Úpygments.pluginr   Úpygments.utilr   Úlistr   r   r
   r   r   r   r'   r   r	   r   Ú
ModuleTyper:   Úmodulesr@   ÚoldmodÚnewmodÚ__dict__Úupdater   r   r   r   Ú<module>   s6    
ÿ
"

