
    ̆ha                        % S r SSKJr  SSKrSSKrSSKJr  SSKJrJ	r	  \(       a  SSK
JrJr  SrS\S	'   S
rS\S'   SS jrSSS jjrg)z
babel.messages.mofile
~~~~~~~~~~~~~~~~~~~~~

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

:copyright: (c) 2013-2025 by the Babel Team.
:license: BSD, see LICENSE for more details.
    )annotationsN)TYPE_CHECKING)CatalogMessage)SupportsReadSupportsWritel   * intLE_MAGICl   $< BE_MAGICc                L   [        5       n0 n[        U SS5      nU R                  5       n[        U5      n[        R
                  nU" SUSS 5      S   nU[        :X  a  U" SUSS 5      u  ppS	nO)U[        :X  a  U" S
USS 5      u  ppSnO[        SSU5      e[        U	5       GH  nU" XXS-    5      u  pX-   nU" XXS-    5      u  nnUU-   nUU:  a  UU:  a
  XOU nUUU nO[        SSU5      eUS:X  a  S=nnUR                  5        H  nUR                  5       nU(       d  M  SU;   aJ  UR                  SS5      u  nnUR                  5       R                  5       =nnUR                  5       UU'   Ml  U(       d  Mu  UU==   SU-   -  ss'   M     SU;   a  UR                  S5      u  nnOSnSU;   ay  UR                  S5      nUR                  S5      nU Vs/ s H  nUR                  UR                  5      PM      nnU Vs/ s H  nUR                  UR                  5      PM      nnO6UR                  UR                  5      nUR                  UR                  5      n[!        UUUS9UU'   U
S-  n
US-  nGM     UR#                  5       Ul        U$ s  snf s  snf )aI  Read 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   r   z<4I   z<IIz>4Iz>IIzBad magic number   zFile is corrupt   :      
       )context)r   getattrreadlenstructunpackr
   r   OSErrorrange
splitlinesstripsplitlowerdecodecharsetr   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                               M/opt/services/DDDS/venv/lib/python3.13/site-packages/babel/messages/mofile.pyread_morC      s    iGGw+H
,,.CXF]]F 4Ra!!$E/5eS2Y/G,7	(	/5eS2Y/G,7a+X66 HoBGaK 89
{BH\ :;
dd{&=TF]4.CtD>D!.99 19  Gc)zz|4<!%D!!4JC$'IIK$5$5$77Gc#(;;=GCLWG$4$ * c>		'*ID#Dc>))G$C::g&D69:c188GOO,cC:7;<t!AHHW__-tD<D**W__-C;;w/DsD$7 	1AW Z #==?GN ;<s   %J
%J!c                D   [        U5      nUSS  Vs/ s H2  nUR                  (       d  M  U(       d  UR                  (       a  M0  UPM4     snUSS& UR                  5         S=pV/ nU GH  nUR                  (       a  SR                  UR                   V	s/ s H  oR                  UR                  5      PM     sn	5      n	/ n
[        UR                  5       HP  u  pU(       d3  U
R                  UR                  [        [        U5      S5         5        M?  U
R                  U5        MR     SR                  U
 Vs/ s H  oR                  UR                  5      PM     sn5      nOJUR                  R                  UR                  5      n	UR                  R                  UR                  5      nUR                  (       a6  SR                  UR                  R                  UR                  5      U	/5      n	UR                  [        U5      [        U	5      [        U5      [        U5      45        XYS-   -  nXmS-   -  nGM     SS[        U5      -  -   nU[        U5      -   n/ n/ nU H  u  nnnnUUUU-   /-  nUUUU-   /-  nM     UU-   nU R                  [         R"                  " S[$        S	[        U5      SS[        U5      S
-  -   S	S	5      [&        R&                  R)                  [&        R&                  " SU5      5      -   U-   U-   5        gs  snf s  sn	f s  snf )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    r   r         Iiiiiiir   r   i)liststringfuzzysortpluralizablejoinidencoder$   	enumerateappendminr	   r   r   writer   packr
   arraytobytes)r'   r(   	use_fuzzymessagesmidsstrsoffsetsmessagemsgidmsgstrsidxrK   msgstrkeystart
valuestartkoffsetsvoffsetso1l1o2l2s                         rB   write_morl   k   s   ` G}H'| @|!xx %.agg | @HQRLMMOCG LL;B::";E%W__-:" E G(8NN7::c#c(A.>#?@NN6*	  9
 \\=D#=D6goo.W# F JJ%%goo6E^^**7??;F??LL'//"8"8"I"'") *EC#e*c$iVEFw  1 8 rCM))HCH$J HH!BBRh''Rj)) " !GMM&++i&!(m##c(ma&77  #(++"5"5ekk#w6O"PQ TWW Z^^ __@"#s   LLL$L
<$L
)r'   zSupportsRead[bytes]returnr   )F)r'   zSupportsWrite[bytes]r(   r   rY   boolrm   None)__doc__
__future__r   rW   r   typingr   babel.messages.catalogr   r   	_typeshedr   r   r
   __annotations__r   rC   rl    rE   rB   <module>rw      sC    #     35# # Odg_rE   