o a@sdZddlZddlZddlZddlZddlmZddlmZddl m Z ddl m Z gde eZiZiZdd Zd d Zd d ZddZddZdddZddZGdddejZejeZeeZejejeeje<e`e`e`e`dS)z pygments.formatters ~~~~~~~~~~~~~~~~~~~ Pygments formatters. :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. N)basename) FORMATTERS)find_plugin_formatters) ClassNotFound)get_formatter_by_nameget_formatter_for_filenameget_all_formattersload_formatter_from_filecCs8|tvrtt|}t|<||St||S)zBReturn whether the supplied file name fn matches pattern filename.)_pattern_cacherecompilefnmatch translatematch)fnglobpatternr>/usr/lib/python3/dist-packages/pygments/formatters/__init__.py _fn_matchess rcCs4t|dddg}|jD] }t||}|t|j<q dS)z4Load a formatter (and all others in the module too).N__all__) __import__rgetattr_formatter_cachename) module_namemodformatter_nameclsrrr_load_formatters$s    rccsPtD]}|dtvrt|dt|dVqtD]\}}|VqdS)z-Return a generator for all formatter classes.rN)rvaluesrrr)info_ formatterrrrr,s   rcCsbtD]\}}}}}||vr|tvrt|t|SqtD] \}}||jvr.|Sq!dS)zALookup a formatter by alias. Returns None if not found. N)rr!rrraliases)aliasrrr%r#rrrrfind_formatter_class7s  r'cKs*t|}|durtd||di|S)zYLookup and instantiate a formatter by alias. Raises ClassNotFound if not found. Nzno formatter found for name %rr)r'r)_aliasoptionsrrrrrFs rCustomFormatterc Ksz6i}t|d}t||Wdn1swY||vr+td||f||}|di|WStyJ}ztd||fd}~wtyQtyb}ztd|d}~ww)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 rbNzno valid %s class found in %szcannot read %s: %sz'error when loading custom formatter: %sr)openexecreadrOSError Exception)filename formatternamer)custom_namespacefformatter_classerrrrrr Qs(   r cKst|}tD]&\}}}}}|D]}t||r-|tvr t|t|di|SqqtD]}|jD]}t||rI|di|Sq7q2td|)zdLookup and instantiate a formatter by filename pattern. Raises ClassNotFound if not found. z#no formatter found for file name %rNr) rrr!rrrr filenamesr)rr)modnamerr#r7r1rrrrrus      rc@seZdZdZddZdS) _automodulez Automatically import formatters.cCs>t|}|rt|dt|d}t||||St|)Nrr )rgetrrsetattrAttributeError)selfrr"rrrr __getattr__s    z_automodule.__getattr__N)__name__ __module__ __qualname____doc__r>rrrrr9s r9)r*) rBr systypesr os.pathrpygments.formatters._mappingrpygments.pluginr pygments.utilrlistrrr rrrr'rr r ModuleTyper9modulesr?oldmodnewmod__dict__updaterrrrs6       $