%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/LanguageSelector/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/LanguageSelector/__pycache__/macros.cpython-312.pyc

�

k�!f��|�dZddlmZddlZddlZdd�ZGd�d�ZGd�d�Zed	k(r�d
Z	dD]�Z
ee	e
�Zede
d
�dZ
edeje
��edd�j!e
�ej#d�eded�j%��ej&d���yy)z�macros.py: Generate macro values from configuration values and provide
substitution functions.

The following macros are available:

  LCODE CCODE PKGCODE LOCALE
�)�print_functionNc�B�d}t|d�}|D]V}	|j|�\}}|jd�dk\s|jd�dk\r�A||k(s�G|j	�}�X|j�|dk(rt
d|�d|����|S#t$rY��wxYw)z[Look up key in given file ("key value" lines). Throw an exception if
    key was not found.N�r�#rzKey z not found in )�open�split�
ValueError�find�strip�close�KeyError)�file�key�sep�val�f�l�k�vs        �9/usr/lib/python3/dist-packages/LanguageSelector/macros.py�	_file_maprs����C��T�3��A�
�	��	��W�W�S�\�F�Q��
�6�6�#�;�!��q�v�v�c�{�a�/����8��'�'�)�C�	��G�G�I�
�d�{��3��=�>�>��J���	��	�s�B�	B�Bc�(�eZdZdZd�Zd�Zd�Zd�Zy)�LangcodeMacrosz1/usr/share/language-selector/data/langcode2localec�N�i|_i}t|j�D]m}	|j�}|j	d�\}}|j
d�dk\s|j
d�dk\r�Q||vrg||<||j|��o|||d<y#t
$rY��wxYw)N�:rr�LOCALES)�macrosr�LANGCODE_TO_LOCALE�rstriprr	r
�append)�self�langCode�localesrrrs      r�__init__zLangcodeMacros.__init__'s���������d�-�-�.�
	!�A�
��H�H�J���������A��v�v�c�{�a��1�6�6�#�;�!�#3����<����
��A�J���a� �
	!�"�(�+��Y����
��
�s�$B�	B$�#B$c�:�|jj|d�S�N��r�get�r!�items  r�__getitem__zLangcodeMacros.__getitem__7����{�{���t�R�(�(�c�"�||j|<y�N�r�r!r+�values   r�__setitem__zLangcodeMacros.__setitem__;���!����D�r.c�8�|jj|�Sr0�r�__contains__r*s  rr8zLangcodeMacros.__contains__>����{�{�'�'��-�-r.N)�__name__�
__module__�__qualname__rr$r,r4r8�r.rrr#s��L��,� )�"�.r.rc�6�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	y)	�LangpackMacrosc���tjj|dd�|_i|_d|d<d|d<d|d<d|d<d|d<d|d	<|d
k(s|dk(rd}d
|vr|jd
�\}|d<d|vr|jd�d}d|vr|jd�\|d<|d<n||d<t
|d�dkDr|�d
|d��|d<n||d<t
|d�dkDrOt
|d�dkDr|d�d|d�d�|d	<nd|dz|d	<t
|d�dkDr|d	�d
|d��|d	<	t|j|dd�|d<y#t$r|d|d<YywxYw)a9Initialize values of macros.

        This uses information from maps/, config/, some hardcoded aggregate
        strings (such as package names), and some external input:
        
        - locale: Standard locale representation (e. g. pt_BR.UTF-8)
                  Format is: ll[_CC][.UTF-8][@variant]
        �data�locale2langpackr'�LCODE�CCODE�VARIANT�LOCALE�PKGCODE�	SYSLOCALE�C�POSIX�en_US�@�.r�_z.UTF-8z%s.UTF-8rN)	�os�path�join�LOCALE_TO_LANGPACKrr�lenrr
)r!�datadir�locales   rr$zLangpackMacros.__init__Bs���#%�'�'�,�,�w��@Q�"R��������W�
���W�
���Y����X����Y����[���S�=�F�g�-��F��&�=�(.���S�(9�%�V�T�)�_��&�=��\�\�#�&�q�)�F��&�=�-3�\�\�#�->�*�T�'�]�D��M�"�D��M��t�I���!�#�(.��Y��@�D��N�#�D��N��t�G�}���!��4��=�!�A�%�59�'�]�D��M�$R��[�!�$.��g��$>��[�!��4�	�?�#�a�'�/3�K�/@�$�y�/�$R��[�!�	,�'��(?�(?��h��QT�U�D��O���	,�"�7�m�D��O�	,�s�4E�E&�%E&c�:�|jj|d�Sr&r(r*s  rr,zLangpackMacros.__getitem__rr-r.c�"�||j|<yr0r1r2s   rr4zLangpackMacros.__setitem__vr5r.c�8�|jj|�Sr0r7r*s  rr8zLangpackMacros.__contains__yr9r.c���tjd�}	|j|�}|rE|d|jd�dz
||j	d�z||jd�dzdz}n	|S�\)z&Substitute all macros in given string.z
%([A-Z]+)%�N)�re�compile�search�start�group�end)r!�s�re_macro�ms    r�subst_stringzLangpackMacros.subst_string|st���:�:�l�+�������"�A���m�q�w�w�q�z�!�|�$�t�A�G�G�A�J�'7�7�!�A�E�E�!�H�Q�J�K�.�H�����r.c��t|�j�}t|d�j|j|��y)z$Substitute all macros in given file.�wN)r�read�writerd)r!rras   r�
subst_filezLangpackMacros.subst_file�s3��
��J�O�O����T�3����d�/�/��2�3r.c	��tj|�D]=\}}}|D]2}|jtjj	|||���4�?y)z.Substitute all macros in given directory tree.N)rO�walkrirPrQ)r!�rootrP�dirs�filesrs      r�
subst_treezLangpackMacros.subst_tree�sN��"$�����	=��D�$���
=����������T�4�� ;�<�
=�	=r.N)
r:r;r<r$r,r4r8rdriror=r.rr?r?As&��.,�`)�"�.��4�=r.r?�__main__z/usr/share/language-selector)	�de�de_DEzde_DE.UTF-8zde_DE.UTF-8@eurozfr_BE@latinzzh_CN.UTF-8zzh_TW.UTF-8zzh_HK.UTF-8�invalid_Localez-------z---------------z;"%PKGCODE%: %LCODE% %CCODE% %VARIANT% %LOCALE% %SYSLOCALE%"zstring:�testtestrfzfile  :r0)�__doc__�
__future__rrOr[rrr?r:rTrUr�print�templaterdrrhrirg�unlinkr=r.r�<module>rzs����&�	�	��*.�.�<S=�S=�j�z��,�G�S�	���7�F�+��
�i��!2�3�P��
�i�����1�2��Z���#�#�H�-�	���Z� �
�i��j�)�.�.�0�1���	�	�*��	�r.

Zerion Mini Shell 1.0