o
    	ȷe                     @   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 ddlmZ ddl	m
Z
 ddlmZ g dee Zi 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-2022 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
    N)fnmatch)basename)
FORMATTERS)find_plugin_formatters)ClassNotFound)get_formatter_by_nameget_formatter_for_filenameget_all_formattersload_formatter_from_filec                 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cls r   S/var/www/ideatree/venv/lib/python3.10/site-packages/pygments/formatters/__init__.py_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_class-   s   
r   c                 K   s*   t | }|du rtd|  |di |S )zYLookup and instantiate a formatter by alias.

    Raises ClassNotFound if not found.
    Nzno formatter found for name %rr   )r   r   )_aliasoptionsr   r   r   r   r   <   s   r   CustomFormatterc              
   K   s   z6i }t | d}t| | W d   n1 sw   Y  ||vr+td|| f || }|di |W S  tyJ } ztd| |f d}~w tyQ     tyb } ztd| d}~ww )a!  Load a formatter from a file.

    This method expects a file located relative to the current working
    directory, which contains a class named CustomFormatter. By default,
    it expects the Formatter to be named CustomFormatter; you can specify
    your own class name as the second argument to this function.

    Users should be very careful with the input, because this method
    is equivalent to running eval on the input file.

    Raises ClassNotFound if there are any problems importing the Formatter.

    .. versionadded:: 2.2
    rbNzno valid %s class found in %szcannot read %s: %sz'error when loading custom formatter: %sr   )openexecreadr   OSError	Exception)filenameformatternamer    custom_namespacefformatter_classerrr   r   r   r
   G   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| |rI|di |    S q7q2td|  )zdLookup and instantiate a formatter by filename pattern.

    Raises ClassNotFound if not found.
    z#no formatter found for file name %rNr   )	r   r   r   r   r   r   r   	filenamesr   )fnr    modnamer   r   r.   r(   r   r   r   r   r   k   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__r6   r   r   r   r   r1   ~   s    r1   )r!   )r:   resystypesr   os.pathr   pygments.formatters._mappingr   pygments.pluginr   pygments.utilr   listr   r   r   r	   r   r   r
   r   
ModuleTyper1   modulesr7   oldmodnewmod__dict__updater   r   r   r   <module>   s2    

$

