U
    ZShi                     @   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.
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
   N/root/rtd-docs/venv/lib/python3.8/site-packages/docutils/languages/__init__.py__init__"   s    zLanguageImporter.__init__Nc              
   C   s   d}| j D ]t}zt|| }| | W nP ttfk
rx   |rV|rV|| d n|rp|d||  d Y q
Y nX  qq
|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k
r    Y nX t|D ](}|dd}| ||}|d k	r* qzq*|rh|| j|  | jrz| | j}|r|dkr|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__)N)N)__name__
__module____qualname____doc__r   r    r!   r   r   r   r#   r
   r
   r
   r   r      s   
r   N)r'   __docformat__	importlibr   Zdocutils.utilsr   r   Zget_languager
   r
   r
   r   <module>   s
   @