o
    N=&bi                     @   s8   d Z dZddlmZ ddlmZ G dd dZe ZdS )zL
This package contains modules for language-dependent features of Docutils.
ZreStructuredText    )import_module)normalize_language_tagc                   @   s@   e Zd ZdZdZdZdZdd Zddd	Zd
d Z	dddZ
dS )LanguageImportera  Import language modules.

    When called with a BCP 47 language tag, instances return a module
    with localisations from `docutils.languages` or the PYTHONPATH.

    If there is no matching module, warn (if a `reporter` is passed)
    and fall back to English.
    )zdocutils.languages. zHLanguage "%s" not supported: Docutils-generated text will be in English.enc                 C   s
   i | _ d S N)cache)self r
   ?usr/lib/python3.10/site-packages/docutils/languages/__init__.py__init__"   s   
zLanguageImporter.__init__Nc              
   C   s|   d}| j D ]6}zt|| }| | W  |S  ttfy;   |r,|r,|| d n|r9|d||  d Y qw |S )z/Try loading module `name` from `self.packages`.Nz) is no complete Docutils language module.zModule "z" not found.)packagesr   check_contentImportErrorAttributeErrorinfo)r	   namereportermodulepackager
   r
   r   import_from_packages%   s   
z%LanguageImporter.import_from_packagesc                 C   s,   t |jtrt |jtrt |jtstdS )z+Check if we got a Docutils language module.N)
isinstancelabelsdictZbibliographic_fieldsZauthor_separatorslistr   )r	   r   r
   r
   r   r   6   s   

zLanguageImporter.check_contentc                 C   s   z| j | W S  ty   Y nw t|D ]}|dd}| ||}|d ur( nq|r3|| j|  | jr<| | j}|rK|dkrK|d||f  || j |< |S )N-_r   zUsing %s for language "%s".)	r   KeyErrorr   replacer   warningwarn_msgfallbackr   )r	   Zlanguage_coder   tagr   r
   r
   r   __call__=   s*   
zLanguageImporter.__call__r   )__name__
__module____qualname____doc__r   r    r!   r   r   r   r#   r
   r
   r
   r   r      s    
r   N)r'   Z__docformat__	importlibr   Zdocutils.utilsr   r   Zget_languager
   r
   r
   r   <module>   s   
@