%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/babel/messages/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/babel/messages/__pycache__/mofile.cpython-312.pyc

�

ƪb���>�dZddlZddlZddlmZmZdZdZd�Zdd�Z	y)	z�
    babel.messages.mofile
    ~~~~~~~~~~~~~~~~~~~~~

    Writing of files in the ``gettext`` MO (machine object) format.

    :copyright: (c) 2013-2022 by the Babel Team.
    :license: BSD, see LICENSE for more details.
�N)�Catalog�Messagel�*l�$<c�V�t�}i}t|dd�}|j�}t|�}tj
}|d|dd�d}|tk(r|d|dd�\}}	}
}d	}n*|tk(r|d
|dd�\}}	}
}d}n
tdd|��td|	�D�]�}
||||
|
d
z�\}}||z}|||||d
z�\}}||z}||kr||kr|||}|||}n
tdd|��|dk(r�dx}}|j�D]u}|j�}|s�d|vrI|jdd�\}}|j�j�x}}|j�||<�c|s�f||xxd|zz
cc<�wd|vr|jd�\}}nd}d|vr|jd�}|jd�}|jr�|D�cgc]}|j|j���}}|D�cgc]}|j|j���}}nB|jr6|j|j�}|j|j�}t!|||��||<|
d
z
}
|d
z
}���|j#�|_|Scc}wcc}w)aaRead a binary MO file from the given file-like object and return a
    corresponding `Catalog` object.

    :param fileobj: the file-like object to read the MO file from

    :note: The implementation of this function is heavily based on the
           ``GNUTranslations._parse`` method of the ``gettext`` module in the
           standard library.
    �name�z<IN�rz<4I�z<IIz>4Iz>IIzBad magic number�zFile is corrupt�:��
��)�context)r�getattr�read�len�struct�unpack�LE_MAGIC�BE_MAGIC�OSError�range�
splitlines�strip�split�lower�charset�decoder�items�mime_headers)�fileobj�catalog�headers�filename�buf�buflenr�magic�version�msgcount�origidx�transidx�ii�i�mlen�moff�mend�tlen�toff�tend�msg�tmsg�lastkey�key�item�value�ctxt�xs                            �7/usr/lib/python3/dist-packages/babel/messages/mofile.py�read_mor>s����i�G��G��w���+�H�
�,�,�.�C�
��X�F�
�]�]�F�
�4��R�a��!�!�$�E����/5�e�S��2�Y�/G�,���7�H�
��	�(�	�/5�e�S��2�Y�/G�,���7�H�
���a�+�X�6�6��1�h�
�-���B��G�G�a�K� 8�9�
��d��d�{���B��H�X��\� :�;�
��d��d�{���&�=�T�F�]��d�4�.�C��t�D�>�D��!�.��9�9��1�9� � �G�c����)�	
5���z�z�|�����4�<�!%���D�!�!4�J�C��$'�I�I�K�$5�$5�$7�7�G�c�#(�;�;�=�G�C�L���G�$����4�$�	
5��c�>��	�	�'�*�I�D�#��D��c�>��)�)�G�$�C��:�:�g�&�D����:=�>�Q�q�x�x����0�>��>�;?�@�a�������1�@��@�����j�j����1���{�{�7�?�?�3���s�D�$�7����	�1����A�
��[-�^#�=�=�?�G���N��?��@s�"J!�"J&c
���t|�}|ddD�cgc]}|jr|s|js|�� c}|dd|j�dx}}g}|D�]�}|jr�dj|jD�	cgc]}	|	j|j���c}	�}	g}
t|j�D]J\}}|s2|
j|jtt|�d���:|
j|��Ldj|
D�
cgc]}
|
j|j���c}
�}
nJ|jj|j�}	|jj|j�}
|jr6dj|jj|j�|	g�}	|jt|�t|	�t|�t|
�f�||	dzz
}||
dzz
}���ddt|�zz}|t|�z}g}g}|D]\}}}}||||zgz
}||||zgz
}�||z}|jt!j"dt$d	t|�ddt|�d
zzd	d	�t&j&j)t'j&d|��z|z|z�ycc}wcc}	wcc}
w)a�Write a catalog to the specified file-like object using the GNU MO file
    format.

    >>> import sys
    >>> from babel.messages import Catalog
    >>> from gettext import GNUTranslations
    >>> from io import BytesIO

    >>> catalog = Catalog(locale='en_US')
    >>> catalog.add('foo', 'Voh')
    <Message ...>
    >>> catalog.add((u'bar', u'baz'), (u'Bahr', u'Batz'))
    <Message ...>
    >>> catalog.add('fuz', 'Futz', flags=['fuzzy'])
    <Message ...>
    >>> catalog.add('Fizz', '')
    <Message ...>
    >>> catalog.add(('Fuzz', 'Fuzzes'), ('', ''))
    <Message ...>
    >>> buf = BytesIO()

    >>> write_mo(buf, catalog)
    >>> x = buf.seek(0)
    >>> translations = GNUTranslations(fp=buf)
    >>> if sys.version_info[0] >= 3:
    ...     translations.ugettext = translations.gettext
    ...     translations.ungettext = translations.ngettext
    >>> translations.ugettext('foo')
    u'Voh'
    >>> translations.ungettext('bar', 'baz', 1)
    u'Bahr'
    >>> translations.ungettext('bar', 'baz', 2)
    u'Batz'
    >>> translations.ugettext('fuz')
    u'fuz'
    >>> translations.ugettext('Fizz')
    u'Fizz'
    >>> translations.ugettext('Fuzz')
    u'Fuzz'
    >>> translations.ugettext('Fuzzes')
    u'Fuzzes'

    :param fileobj: the file-like object to write to
    :param catalog: the `Catalog` instance
    :param use_fuzzy: whether translations marked as "fuzzy" should be included
                      in the output
    rN�rr���Iiiiiiirr
r.)�list�string�fuzzy�sort�pluralizable�join�id�encoder�	enumerate�append�min�intrr�writer�packr�array�tobytes)r"r#�	use_fuzzy�messages�m�ids�strs�offsets�message�msgid�msgstrs�idxrE�msgstr�keystart�
valuestart�koffsets�voffsets�o1�l1�o2�l2s                      r=�write_morgis���`�G�}�H�'���|�@�!��x�x�Y�a�g�g��@�H�Q�R�L��M�M�O���C�$��G��!������L�L�;B�:�:�"�27����W�_�_�-�"��E��G�(����8�
+���V���N�N�7�:�:�c�#�c�(�A�.>�#?�@��N�N�6�*�	
+�
�\�\�=D�#�39��
�
�g�o�o�.�#��F��J�J�%�%�g�o�o�6�E��^�^�*�*�7�?�?�;�F��?�?��L�L�'�/�/�"8�"8����"I�"'�")�*�E�����C��#�e�*�c�$�i��V��E�F��u�w������� � ��1!�8�r�C��M�)�)�H��C��H�$�J��H��H�!�*���B��B��R��h��'�'���R��j��)�)��*���!�G��M�M�&�+�+�i�&��!�(�m�#�#�c�(�m�a�&7�7���
 �#(�+�+�"5�"5�e�k�k�#�w�6O�"P�Q�TW�W�Z^�^�_��_@��"��#s�#K%�="K*
�"K/
)F)
�__doc__rRr�babel.messages.catalogrrrrr>rg�r@r=�<module>rks/���
�
�3�����Q�hg_r@

Zerion Mini Shell 1.0