o
    gJ^V  ã                   @   sB   d Z dZddlZddlmZ ddlmZ G dd„ deƒZeƒ Z	dS )zL
This package contains modules for language-dependent features of Docutils.
ÚreStructuredTexté    N)Ú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/dist-packages/docutils/languages/__init__.pyÚ__init__#   s   
zLanguageImporter.__init__Nc              
   C   sv   d}| j D ]3}zt|| ƒ}|  |¡ W  |S  ttfy8   |r+|r+| d| ¡ n|r6| d||  ¡ Y qw |S )z/Try loading module `name` from `self.packages`.Nz+%s is no complete Docutils language module.zModule "%s" 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ÚdictÚbibliographic_fieldsÚauthor_separatorsÚlistr   )r
   r   r   r   r   r   7   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
   Ú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   )
r+   Ú__docformat__ÚsysÚ	importlibr   Údocutils.utilsr   Úobjectr   Úget_languager   r   r   r   Ú<module>   s   
?