+
     hץ c                   s  a  Re t`0 t R t^ RIHt ^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RI	t	^ RI
t^ RIHt ]	P                  ! R. RfO4      tR. /t] ^ k RtRtRt]P(                  ! Rg4      tR	R
RR
RRRR/t/ t/ t/ t/ t/ t ! R R4      t ! R R4      t ! R R4      t ! R R4      t ! R R4      t  ! R R]4      t! ! R R]!4      t" ! R R]!4      t# ! R  R!]!4      t$ ! R" R#]!4      t% ! R$ R%]!4      t&R& t'R' t(R( t)R) t*R* t+R+ t,R, t-R- t.RhR. lt/R/ t0RiR0 lt1RjR1 lt2R2 t3RkR3 lt4RlR4 lt5RlR5 lt6RmR6 lt7RmR7 lt8RnR8 lt9RnR9 lt:RoR: lt;RpR; lt<RpR< lt=R=t>RqR> lt?R? t@RqR@ ltARqRA ltBRqRB ltCRrRC ltDRrRD ltERqRE ltFRqRF ltGRG RH ltHRI RJ ltIRK RL ltJRM RN ltKRO RP ltLRQ RR ltMRS RT ltNRU RV ltORsRW ltPRX tQRY tRRZ tSRtR[ ltTRuR\ R] lltU ! R^ R_4      tV]V! 4       tW]XR`8X  dr   ^ RIYtY^ RIZtZ]U! 4        ]YP                  ! 4       w  t\t]]^! ]] Ra]]]\,
           Rb]\ Rc24       ]\'       d   ]ZP                  ! ]\4       ]^! Rd4       ]ZP                  ! ^ 4       R# R# )vu 
  
Guessing reasonable defaults for locale, keyboard layout, territory, and language.

langtable is used to guess reasonable defaults for locale, keyboard,
territory, …, if part of that information is already known. For example,
guess the territory and the keyboard layout if the language is known or guess
the language and keyboard layout if the territory is already known.

Public API:

    parse_locale()
    list_locales()
    list_keyboards()
    list_common_languages()
    list_common_locales()
    list_common_keyboards()
    list_consolefonts()
    list_inputmethods()
    list_timezones()
    list_scripts()
    language_name()
    territory_name()
    timezone_name()
    languageId()
    territoryId()
    supports_ascii()
    list_all_languages()
    list_all_locales()
    list_all_keyboards()
    list_all_territories()
    list_all_timezones()
    list_all_scripts()
    list_all_input_methods()
    list_all_console_fonts()

These are the functions which do not start with an “_” in their name.
All global functions and global variables whose name starts with an
“_” are internal and should not be used by a user of langtable.py.

Many of the above public functions have named parameters like

   languageId
   scriptId
   territoryId

and

   languageIdQuery
   scriptIdQuery
   territoryIdQuery

languageId and languageIdQuery may contain a full locale name,
specifying the script and the territory as well.

For example:

    language_name(languageId="sr_Latn_RS")

behaves the same as

    language_name(languageId="sr", scriptId="Latn", territoryId="RS")

If languageId contains a script or a territory, the values found there
are preferred over those given as extra parameters. For example:

    language_name(languageId="sr_Latn_RS", scriptId="Cyrl", territoryId="ME")

behaves the same as

    language_name(languageId="sr", scriptId="Latn", territoryId="RS")

scriptId="Cyrl" and territoryId="ME" are overridden by the values found
in languageId.

It is also possible to put a full locale name in the spelling used by glibc
into languageId. For example:

    language_name(languageId="sr_RS.utf8@latin")

or

    language_name(languageId="sr_RS.UTF-8@latin")

also behave the same as:

    language_name(languageId="sr_Latn_RS")

which is the same as:

    language_name(languageId="sr", scriptId="Latn", territoryId="RS")

langtable always parses languageId, cuts out the encoding and translates
script names in glibc spelling like "latin" to the official
ISO 15924 script codes, see: https://en.wikipedia.org/wiki/ISO_15924
)List)DictN)ContentHandlerLocaledata_files_readz/usr/share/langtablei  ZlatinZLatnZiqtelifZcyrillicZCyrlZ
devanagariZDevac                   s.   a  ] tR t^t o RtRR ltRtV tR# )territory_db_itemz#Holds information for one territoryNc	                sf    Wn         W n        W0n        W@n        WPn        W`n        Wpn        Wn        R # Nnamesscriptslocales	languages	keyboardsinputmethodsconsolefonts	timezones)	selfr   r	   r
   r   r   r   r   r   s	   &&&&&&&&&8/usr/lib/python3.14/site-packages/langtable/langtable.py__init__Zterritory_db_item.__init__   s,    
""(("    )r   r   r   r   r
   r   r	   r   )NNNNNNNN__name__
__module____qualname____firstlineno____doc__r   __static_attributes____classdictcell____classdict__   @r   r   r      s     -# #r   r   c                   s.   a  ] tR t^t o RtRR ltRtV tR# )language_db_itemz"Holds information for one languageNc                s    Wn         W n        W0n        W@n        WPn        W`n        Wpn        Wn        Wn        Wn	        Wn
        R # r   iso639_1
iso639_2_t
iso639_2_br   r	   r
   territoriesr   r   r   r   )r   r!   r"   r#   r   r	   r
   r$   r   r   r   r   s   &&&&&&&&&&&&r   r   Zlanguage_db_item.__init__   s<     $$
&"(("r   )r   r   r!   r#   r"   r   r
   r   r	   r$   r   )NNNNNNNNNNNr   r   r   r   r   r      s     ,# #r   r   c                   s.   a  ] tR t^t o RtRR ltRtV tR# )keyboard_db_itemz)Holds information for one keyboard layoutNc                sB    Wn         W n        WPn        W0n        W@n        R # r   descriptionasciicommentr   r$   )r   r'   r(   r   r$   r)   s   &&&&&&r   r   Zkeyboard_db_item.__init__   s    &
"&r   )r(   r)   r'   r   r$   )NTNNNr   r   r   r   r%   r%      s     3' 'r   r%   c                   s.   a  ] tR t^t o RtRR ltRtV tR# )timezone_db_itemz"Holds information for one timezoneNc                    Wn         R # r   r   r   r      &&r   r   Ztimezone_db_item.__init__       
r   r,   r   r   r   r   r   r*   r*      s     , r   r*   c                   s.   a  ] tR t^t o RtRR ltRtV tR# )timezoneIdPart_db_itemz'Holds information for one timezone partNc                r+   r   r,   r-   r.   r   r   ZtimezoneIdPart_db_item.__init__   r/   r   r,   r   r   r   r   r   r0   r0      s     1 r   r0   c                   s<   a a ] tR t^t oRtV 3R ltR tRtVtV ;t	# )LangtableContentHandlerz
A base class inherited from the xml.sax.handler.ContentHandler class
providing handling for SAX events produced when parsing the langtable data
files.

c                s2   < \         SV `  4        R V n        R # r   )superr   _save_tor   	__class__   &r   r   Z LangtableContentHandler.__init__   s     r   c                s    V P                   f   R# \        W P                   4      pV'       d
   W!,           pMTp\        W P                   V4       R# )z Handler for the text data event.N)r3   ZgetattrZsetattr)r   ZcontentZ	old_valueZ	new_values   &&  r   
charactersZ"LangtableContentHandler.characters   s?     ==  D--0	!+IImmY/r   )r3   )
r   r   r   r   r   r   r7   r   r   __classcell__r5   r      @@r   r1   r1      s     0 0r   r1   c                   H   a a ] tR tRt oRtV 3R ltR tR tR tRt	Vt
V ;t# )TerritoriesContentHandleri  zFHandler for SAX events produced when parsing the territories.xml file.c                s   < \         SV `  4        R V n        R V n        R V n        R V n        R V n        R V n        R V n        R V n	        R V n
        R V n        R V n        R V n        R # r   )r2   r   _territoryId_item_id
_item_rank
_item_name_names_scripts_locales
_languages
_keyboards_inputmethods_consolefonts
_timezonesr4   r6   r   r   Z"TerritoriesContentHandler.__init__  sk     !  !!r   c                s   VR 8X  d;   / V n         / V n        / V n        / V n        / V n        / V n        / V n        / V n        R# VR8X  d
   RV n        R# VR	9   d
   RV n        R# VR8X  d
   RV n        R# VR8X  d
   RV n        R# R# )
	territoryterritoryIdr=   r>   trNamer@   rankr?   N)
languageIdscriptIdlocaleId
keyboardIdinputmethodIdconsolefontId
timezoneId)	rA   rB   rC   rD   rE   rF   rG   rH   r3   r   nameZattrs   &&&r   startElementZ&TerritoriesContentHandler.startElement  s    ;DKDMDM DO DO!#D!#D DO ]"*DM  5 5&DMX(DMV^(DM r   c                sl   R V n         VR8X  d   \        V P                  V P                  V P                  V P
                  V P                  V P                  V P                  V P                  R7      \        \        V P                  4      &   R V n        R V n        R V n        R V n        R V n        R V n        R V n        R V n        R V n	        R # VR8X  d?   V P                  V P                  \        V P                  4      &   V P                  4        R # VR8X  dH   \!        V P"                  4      V P                  \        V P                  4      &   V P                  4        R # VR8X  dH   \!        V P"                  4      V P                  \        V P                  4      &   V P                  4        R # VR8X  dH   \!        V P"                  4      V P
                  \        V P                  4      &   V P                  4        R # VR8X  dH   \!        V P"                  4      V P                  \        V P                  4      &   V P                  4        R # VR8X  dH   \!        V P"                  4      V P                  \        V P                  4      &   V P                  4        R # VR	8X  dH   \!        V P"                  4      V P                  \        V P                  4      &   V P                  4        R # VR
8X  dH   \!        V P"                  4      V P                  \        V P                  4      &   V P                  4        R # R # )NrI   r   rU   scriptlocalelanguagekeyboardinputmethodconsolefonttimezone)r3   r   rA   rB   rC   rD   rE   rF   rG   rH   _territories_dbstrr=   r@   r>   _clear_itemintr?   r   rU   r.   r   
endElementZ$TerritoriesContentHandler.endElement1  sR    ;6G---- OO OO#11#11 OO7-OC 1 123 !%DDK DM DM"DO"DO!%D!%D"DO V^.2ooDKKDMM*+X03DOO0DDMM#dmm,-X03DOO0DDMM#dmm,-Z25doo2FDOOC./Z25doo2FDOOC./]"585IDs4==12]"585IDs4==12Z25doo2FDOOC./  r   c                0    R V n         R V n        R V n        R # r   r>   r@   r?   r      &r   ra   Z%TerritoriesContentHandler._clear_itemf      r   )rG   rF   r>   r@   r?   rE   rD   rC   rA   r3   rB   r=   rH   r   r   r   r   r   r   rW   rd   ra   r   r   r8   r9   r:   r   r<   r<     s"     P*)03j r   r<   c                   r;   )KeyboardsContentHandlerik  zDHandler for SAX events produced when parsing the keyboards.xml file.c                s   < \         SV `  4        R V n        R V n        R V n        R V n        R V n        R V n        R V n        R V n	        R # r   )
r2   r   _keyboardId_description_ascii_commentr>   r?   rD   _territoriesr4   r6   r   r   Z KeyboardsContentHandler.__init__n  sO          r   c                s    VR 8X  d   / V n         / V n        R# VR8X  d
   RV n        R# VR8X  d
   RV n        R# VR8X  d
   RV n        R# VR8X  d
   RV n        R# VR9   d
   R	V n        R# VR
8X  d
   RV n        R# R# )r[   rP   rl   r'   rm   r(   rn   r)   ro   r>   rL   r?   N)rM   rJ   )rD   rp   r3   rT   rV   r   rW   Z$KeyboardsContentHandler.startElement  s{    : DO "D \!)DM]"*DMW_$DMY&DM 22&DMV^(DM r   c                sp   R V n         VR8X  d   \        V P                  V P                  R8H  V P                  V P
                  V P                  R7      \        \        V P                  4      &   R V n	        R V n        R V n        R V n        R V n        R V n        R # VR8X  dH   \        V P                  4      V P
                  \        V P                  4      &   V P                  4        R # VR8X  dH   \        V P                  4      V P                  \        V P                  4      &   V P                  4        R # R # )Nr[   ZTruer&   rZ   rI   )r3   r%   rm   rn   ro   rD   rp   _keyboards_dbr`   rl   rb   r?   r>   ra   rc   r.   r   rd   Z"KeyboardsContentHandler.endElement  s     :3C"//v--- OO"//41M#d../0  $D $DDK DM"DO $D Z25doo2FDOOC./[ 474HDc$--01 !r   c                "    R V n         R V n        R # r   )r>   r?   rg   rh   r   ra   Z#KeyboardsContentHandler._clear_item      r   )	rn   ro   rm   r>   r?   rl   rD   r3   rp   rj   r9   r:   r   rk   rk   k  s!     N!")*: r   rk   c                   r;   )LanguagesContentHandleri  zDHandler for SAX events produced when parsing the languages.xml file.c                s  < \         SV `  4        R V n        R V n        R V n        R V n        R V n        R V n        R V n        RV n	        R V n
        R V n        R V n        R V n        R V n        R V n        R V n        R V n        R # )NF)r2   r   _languageId	_iso639_1_iso639_2_t_iso639_2_br>   r?   r@   	_in_namesrA   rB   rC   rp   rE   rF   rG   rH   r4   r6   r   r   Z LanguagesContentHandler.__init__  s        !!r   c                s   VR 8X  d;   / V n         / V n        / V n        / V n        / V n        / V n        / V n        / V n        R# VR8X  d   V P                  '       g
   RV n	        R# VR8X  d
   RV n	        R# VR8X  d
   RV n	        R# VR8X  d
   RV n	        R# VR	8X  d
   R
V n        R# VR9   d
   RV n	        R# VR8X  d   V P                  '       d
   RV n	        R# VR8X  d
   RV n	        R# VR8X  d
   RV n	        R# R# )rZ   rM   ru   ziso639-1rv   z
iso639-2-trw   z
iso639-2-brx   r   Tr>   rK   r@   rL   r?   N)rN   rO   rJ   rP   rQ   rR   rS   )
rA   rB   rC   rp   rE   rF   rG   rH   ry   r3   rT   rV   r   rW   Z$LanguagesContentHandler.startElement  s    :DKDMDM "D DO!#D!#D DO \!$...)DMZ'DM\!)DM\!)DMW_!DN  5 5&DM\!dnnn&DMX(DMV^(DM r   c                s   R V n         VR8X  d   \        V P                  V P                  V P                  V P
                  V P                  V P                  V P                  V P                  V P                  V P                  V P                  R7      \        \        V P                  4      &   R V n        R V n        R V n        R V n        R V n        R V n        R V n        R V n        R V n	        R V n
        R V n        R V n        R # VR8X  d
   RV n        R # VR8X  d?   V P"                  V P
                  \        V P$                  4      &   V P'                  4        R # VR8X  dH   \)        V P*                  4      V P                  \        V P$                  4      &   V P'                  4        R # VR8X  dH   \)        V P*                  4      V P                  \        V P$                  4      &   V P'                  4        R # VR8X  dH   \)        V P*                  4      V P                  \        V P$                  4      &   V P'                  4        R # VR	8X  dH   \)        V P*                  4      V P                  \        V P$                  4      &   V P'                  4        R # VR
8X  dH   \)        V P*                  4      V P                  \        V P$                  4      &   V P'                  4        R # VR8X  dH   \)        V P*                  4      V P                  \        V P$                  4      &   V P'                  4        R # VR8X  dH   \)        V P*                  4      V P                  \        V P$                  4      &   V P'                  4        R # R # )NrZ   r    r   FrU   rX   rY   rI   r[   r\   r]   r^   )r3   r   rv   rw   rx   rA   rB   rC   rp   rE   rF   rG   rH   _languages_dbr`   ru   ry   r@   r>   ra   rb   r?   rc   r.   r   rd   Z"LanguagesContentHandler.endElement  s    :3C>>!--!------"// OO#11#11 OO4-M#d../0  $D!DN#D#DDK DM DM $D"DO!%D!%D"DO W_"DN V^.2ooDKKDMM*+X03DOO0DDMM#dmm,-X03DOO0DDMM#dmm,-[ 474HDc$--01Z25doo2FDOOC./]"585IDs4==12]"585IDs4==12Z25doo2FDOOC./  r   c                re   r   rf   rg   rh   r   ra   Z#LanguagesContentHandler._clear_item6  ri   r   )rG   ry   rF   rv   rx   rw   r>   r@   r?   rE   ru   rC   rA   r3   rB   rp   rH   rj   r9   r:   r   rt   rt     s#     N6")H=~ r   rt   c                   r;   )TimezonesContentHandleri;  zDHandler for SAX events produced when parsing the timezones.xml file.c                \   < \         SV `  4        R V n        R V n        R V n        R V n        R # r   )r2   r   _timezoneIdr>   r@   rA   r4   r6   r   r   Z TimezonesContentHandler.__init__>  s/      r   c                    VR 8X  d
   / V n         R# VR8X  d
   RV n        R# VR8X  d
   RV n        R# VR8X  d
   RV n        R# R# )r^   rS   r}   rM   r>   rK   r@   NrA   r3   rT   rV   r   rW   Z$TimezonesContentHandler.startElementJ  sG    :DK \!)DM \!&DMX(DM r   c                ,   R V n         VR8X  dA   \        V P                  R7      \        \	        V P
                  4      &   R V n        R V n        R # VR8X  d?   V P                  V P                  \	        V P                  4      &   V P                  4        R # R # )Nr^   r,   rU   )	r3   r*   rA   _timezones_dbr`   r}   r@   r>   ra   rc   r.   r   rd   Z"TimezonesContentHandler.endElementZ  sz     :3C4%M#d../0  $DDK V^.2ooDKKDMM*+ r   c                rr   r   r>   r@   rg   rh   r   ra   Z#TimezonesContentHandler._clear_iteml  rs   r   )r>   r@   rA   r3   r}   rj   r9   r:   r   r{   r{   ;  s!     N
) $ r   r{   c                   r;   )TimezoneIdPartsContentHandlerip  zJHandler for SAX events produced when parsing the timezoneidparts.xml file.c                r|   r   )r2   r   _timezoneIdPartIdr>   r@   rA   r4   r6   r   r   Z&TimezoneIdPartsContentHandler.__init__s  s/    !%  r   c                r~   )timezoneIdParttimezoneIdPartIdr   rM   r>   rK   r@   Nr   rT   rV   r   rW   Z*TimezoneIdPartsContentHandler.startElement  sI    ##DK ''/DM \!&DMX(DM r   c                r   )Nr   r,   rU   )	r3   r0   rA   _timezoneIdParts_dbr`   r   r@   r>   ra   rc   r.   r   rd   Z(TimezoneIdPartsContentHandler.endElement  s}     ##?U@%D$:$: ;< &*D"DK V^.2ooDKKDMM*+ r   c                rr   r   r   rg   rh   r   ra   Z)TimezoneIdPartsContentHandler._clear_item  rs   r   )r>   r@   rA   r3   r   rj   r9   r:   r   r   r   p  s!     T
) $ r   r   c           	     s6   V P                  R4       V P                  R4       \        \        4       EFQ  pV P                  R4       V P                  RV,           R,           4       \        V,          P                  pV P                  R4       \        V4       FT  pV P                  R6V,           R,           R,           W#,          P	                  R	R
4      ,           R,           R,           4       KV  	  V P                  R4       \        V,          P
                  pV P                  R4       \        VP                  4       R R7       FI  w  rVV P                  R7V,           R,           R,           \        V4      ,           R,           R,           4       KK  	  V P                  R4       \        V,          P                  pV P                  R4       \        VP                  4       R R7       FI  w  rV P                  R8V,           R,           R,           \        V4      ,           R,           R,           4       KK  	  V P                  R4       \        V,          P                  p	V P                  R4       \        V	P                  4       R R7       FI  w  rV P                  R9V
,           R,           R,           \        V4      ,           R,           R,           4       KK  	  V P                  R4       \        V,          P                  pV P                  R4       \        VP                  4       R  R7       FI  w  rV P                  R:V,           R!,           R,           \        V4      ,           R,           R",           4       KK  	  V P                  R#4       \        V,          P                  pV P                  R$4       \        VP                  4       R% R7       FI  w  rV P                  R;V,           R&,           R,           \        V4      ,           R,           R',           4       KK  	  V P                  R(4       \        V,          P                  pV P                  R)4       \        VP                  4       R* R7       FJ  w  ppV P                  R<V,           R+,           R,           \        V4      ,           R,           R,,           4       KL  	  V P                  R-4       \        V,          P                  pV P                  R.4       \        VP                  4       R/ R7       FJ  w  ppV P                  R=V,           R0,           R,           \        V4      ,           R,           R1,           4       KL  	  V P                  R24       V P                  R34       EKT  	  V P                  R44       R5# )>
Only for internal use
'<?xml version="1.0" encoding="UTF-8"?>
z<territories>
z  <territory>
z    <territoryId>z</territoryId>
    <names>
</languageId><trName>Z&z&amp;	</trName></name>
    </names>
    <scripts>
c                 4    RV ^,          ,          V ^ ,          3#    i xrh   r   <lambda>)_write_territories_file.<locals>.<lambda>      R!WQqTNr   key</scriptId><rank></rank>
</script>
    </scripts>
    <locales>
c                 r   r   r   r   rh   r   r   r     r   r   </localeId>
</locale>
    </locales>
    <languages>
c                 r   r   r   r   rh   r   r   r         AaDQRSTQUr   </language>
    </languages>
    <keyboards>
c                 r   r   r   r   rh   r   r   r     r   r   </keyboardId></keyboard>
    </keyboards>
    <inputmethods>
c                 r   r   r   r   rh   r   r   r         rRSTURVwWXYZW[nr   </inputmethodId></inputmethod>
    </inputmethods>
    <consolefonts>
c                 r   r   r   r   rh   r   r   r     r   r   </consolefontId></consolefont>
    </consolefonts>
    <timezones>
c                 r   r   r   r   rh   r   r   r     r   r   </timezoneId></timezone>
    </timezones>
z  </territory>
z</territories>
N      <name><languageId>      <script><scriptId>      <locale><localeId>      <language><languageId>      <keyboard><keyboardId>"      <inputmethod><inputmethodId>"      <consolefont><consolefontId>      <timezone><timezoneId>)writesortedr_   r   replacer	   itemsr`   r
   r   r   r   r   r   )filerJ   r   rU   r	   rN   rL   r
   rO   r   rM   r   rP   r   rQ   r   rR   r   rS      &                  r   _write_territories_filer     s    	JJ9:JJ !o.

$%

&{23EEF,22

?#5MDJJ  $%%45!K//W=>>IJ  " 	

#$!+.66

$%$W]]_:RSNHJJ&''45d)$$-.   T 	

%&!+.66

$%$W]]_:RSNHJJ&''45d)$$-.   T 	

%&#K0::	

&' &y'8>V WJJJ  *++:;d)$$-. !!" !X 	

'(#K0::	

&' &y'8>V WJJJ  *++:;d)$$-. !!" !X 	

'(&{3@@

)*#),*<*<*>D\#]MJJ##011CDd)$$-. $$% $^ 	

*+&{3@@

)*#),*<*<*>D\#]M4JJ##011CDd)$$-. $$% $^ 	

*+#K0::	

&' &y'8>V WJJJ  *++:;d)$$-. !!" !X 	

'(

%&W /X 	JJ!"r   c                s   V P                  R4       V P                  R4       \        \        4       EF  pV P                  R4       V P                  RV,           R,           4       V P                  R\        \        V,          P                  4      ,           R,           4       V P                  R\        \        V,          P
                  4      ,           R	,           4       V P                  R
\        \        V,          P                  4      ,           R,           4       \        V,          P                  pV P                  R4       \        V4       FD  pV P                  R;V,           R,           R,           W#,          ,           R,           R,           4       KF  	  V P                  R4       \        V,          P                  pV P                  R4       \        VP                  4       R R7       FI  w  rVV P                  R<V,           R,           R,           \        V4      ,           R,           R,           4       KK  	  V P                  R4       \        V,          P                  pV P                  R4       \        VP                  4       R R7       FI  w  rV P                  R=V,           R,           R,           \        V4      ,           R,           R,           4       KK  	  V P                  R4       \        V,          P                  p	V P                  R4       \        V	P                  4       R  R7       FI  w  rV P                  R>V
,           R!,           R,           \        V4      ,           R,           R",           4       KK  	  V P                  R#4       \        V,          P                  pV P                  R$4       \        VP                  4       R% R7       FI  w  rV P                  R?V,           R&,           R,           \        V4      ,           R,           R',           4       KK  	  V P                  R(4       \        V,          P                  pV P                  R)4       \        VP                  4       R* R7       FI  w  rV P                  R@V,           R+,           R,           \        V4      ,           R,           R,,           4       KK  	  V P                  R-4       \        V,          P                  pV P                  R.4       \        VP                  4       R/ R7       FJ  w  ppV P                  RAV,           R0,           R,           \        V4      ,           R,           R1,           4       KL  	  V P                  R24       \        V,          P                  pV P                  R34       \        VP                  4       R4 R7       FJ  w  ppV P                  RBV,           R5,           R,           \        V4      ,           R,           R6,           4       KL  	  V P                  R74       V P                  R84       EK  	  V P                  R94       R:# )Cr   r   z<languages>
z  <language>
z    <languageId>z</languageId>
z    <iso639-1>z</iso639-1>
z    <iso639-2-t>z</iso639-2-t>
z    <iso639-2-b>z</iso639-2-b>
r   r   r   r   r   r   r   c                 r   r   r   r   rh   r   r   '_write_languages_file.<locals>.<lambda>  r   r   r   r   r   r   r   r   r   c                 r   r   r   r   rh   r   r   r     r   r   r   r   r       <territories>
c                 r   r   r   r   rh   r   r   r   "      BqQRtGTUVWTX>r   </territoryId></territory>
    </territories>
r   c                 r   r   r   r   rh   r   r   r   +  r   r   r   r   r   r   c                 r   r   r   r   rh   r   r   r   4  r   r   r   r   r   r   c                 r   r   r   r   rh   r   r   r   =  r   r   r   r   r   r   c                 r   r   r   r   rh   r   r   r   F  r   r   r   r   r   z  </language>
z</languages>
Nr   r   r         <territory><territoryId>r   r   r   r   )r   r   rz   r`   r!   r"   r#   r   r	   r   r
   r$   r   r   r   r   )r   rM   r   rU   r	   rN   rL   r
   rO   r$   rJ   r   rP   r   rQ   r   rR   r   rS   r   r   _write_languages_filer     s\    	JJ9:JJ]+


#$

%j01BBC

#Cj(A(J(J$KKO[\

%c-
*C*N*N&OOPaab

%c-
*C*N*N&OOPaabj)//

?#5MDJJ  $%%45!K((34  " 	

#$
+33

$%$W]]_:RSNHJJ&''45d)$$-.   T 	

%&
+33

$%$W]]_:RSNHJJ&''45d)$$-.   T 	

%&#J/;;

()!'(9(9(;AY!ZKJJ!!,--=>d)$$-. ""# "[ 	

)*!*-77	

&' &y'8>V WJJJ  *++:;d)$$-. !!" !X 	

'($Z0==

)*#),*<*<*>D\#]MJJ##011CDd)$$-. $$% $^ 	

*+$Z0==

)*#),*<*<*>D\#]M4JJ##011CDd)$$-. $$% $^ 	

*+!*-77	

&' &y'8>V WJJJ  *++:;d)$$-. !!" !X 	

'(

$%] ,^ 	JJ r   c                s"   V P                  R4       V P                  R4       \        \        4       EFG  pV P                  R4       V P                  RV,           R,           4       V P                  R\        V,          P                  ,           R,           4       V P                  R\	        \        V,          P
                  4      ,           R	,           4       \        V,          P                  e5   V P                  R\        V,          P                  ,           R,           4       \        V,          P                  pV P                  R4       \        VP                  4       R R7       FI  w  r4V P                  RV,           R,           R,           \	        V4      ,           R,           R,           4       KK  	  V P                  R4       \        V,          P                  pV P                  R4       \        VP                  4       R R7       FI  w  rdV P                  RV,           R,           R,           \	        V4      ,           R,           R,           4       KK  	  V P                  R4       V P                  R4       EKJ  	  V P                  R4       R
# )r   r   z<keyboards>
z  <keyboard>
z    <keyboardId>z</keyboardId>
z    <description>z</description>
z    <ascii>z	</ascii>
Nz    <comment>z</comment>
r   c                 r   r   r   r   rh   r   r   '_write_keyboards_file.<locals>.<lambda>_  r   r   r   r   r   r   r   r   r   c                 r   r   r   r   rh   r   r   r   h  r   r   r   r   r   z  </keyboard>
z</keyboards>
r   r   )
r   r   rq   r'   r`   r(   r)   r   r   r$   )r   rP   r   rM   rL   r$   rJ   s   &      r   _write_keyboards_filer   P  s
    	JJ9:JJ]+


#$

%j01BBC

&}Z'@'L'LLM__`

=]:%>%D%D!EElRS$,,8JJ}Z'@'H'HHWX!*-77	

&' &y'8>V WJJJ  *++:;d)$$-. !!" !X 	

'(#J/;;

()!'(9(9(;AY!ZKJJ!!,--=>d)$$-. ""# "[ 	

)*

$%3 ,4 	JJ r   c                2   V P                  R4       V P                  R4       \        \        4       F  pV P                  R4       V P                  RV,           R,           4       \        V,          P                  pV P                  R4       \        V4       FD  pV P                  RV,           R,           R,           W#,          ,           R	,           R
,           4       KF  	  V P                  R4       V P                  R4       K  	  V P                  R4       R# )r   r   z<timezones>
z  <timezone>
z    <timezoneId>z</timezoneId>
r   r   r   r   r   r   z  </timezone>
z</timezones>
Nr   )r   r   r   r   )r   rS   r   rU      &   r   _write_timezones_filer   r  s     	JJ9:JJ]+


#$

%j01BBCj)//

?#5MDJJ  $%%45!K((34  " 	

#$

$% , 	JJ r   c                r   )r   r   z<timezoneIdParts>
z  <timezoneIdPart>
z    <timezoneIdPartId>z</timezoneIdPartId>
r   r   r   r   r   r   z  </timezoneIdPart>
z</timezoneIdParts>
Nr   )r   r   r   r   )r   r   r   rU   r   r   _write_timezoneIdParts_filer     s     	JJ9:JJ$%"#67

)*

+,<<=TTU#$45;;

?#5MDJJ  $%%45!K((34  " 	

#$

*+ 8 	JJ%&r   c                s    \         P                  P                  P                  4       pVP                  Vn        VP                  Vn        VP                  Vn	        VP                  V 4       R# )zc
Only for internal use. Parses a given file object with a given SAX handler
using an expat parser.
N)xmlZparsersZexpatZParserCreaterW   ZStartElementHandlerrd   ZEndElementHandlerr7   ZCharacterDataHandlerZ	ParseFile)r   sax_handlerZparser   && r   _expat_parser     sT     [[++-F!,!9!9F*55F"-"8"8F
Tr   c                sJ   \         P                  P                  \         P                  P                  \         P                  P	                  \
        4      4      R4      \         P                  P                  \        R4      3 EF[  p\         P                  P                  W 4      p\         P                  P                  V4      '       d`   \        VRR7      ;_uu_ 4       p\        P                  ! RV4       \        WA4       \        R,          P                  V4       RRR4        R# \         P                  P                  W R,           4      p\         P                  P                  V4      '       g   K  \        P                  ! VRR7      ;_uu_ 4       p\        P                  ! RV4       \        WA4       \        R,          P                  V4       RRR4        R# 	  \        P                  ! R4       R#   + '       g   i      R# ; i  + '       g   i      R# ; i)	r   ZdataZrb)Zmodezreading file=%sr   Nz.gzzno readable file found.)ospathjoinZdirnamerealpath__file___DATADIRZisfileopenlogginginfor   _INFOappendgzip)filenamer   Z	directoryr   r   s   &&   r   
_read_filer     sW   
 GGLL)9)9()CDfMGGLL6*,	 ww||I077>>$d&&$.5T/'(//5 ' ww||I~677>>$4d++t.5T/'(//5 , !," LL*+ '&  ,+ s    ?G;?H;HH"c                s   \        V RRR7      ;_uu_ 4       p\        P                  ! RV4       \        V4       RRR4       \        VRRR7      ;_uu_ 4       p\        P                  ! RV4       \	        V4       RRR4       \        VRRR7      ;_uu_ 4       p\        P                  ! RV4       \        V4       RRR4       \        VRRR7      ;_uu_ 4       p\        P                  ! RV4       \        V4       RRR4       \        VRRR7      ;_uu_ 4       p\        P                  ! RV4       \        V4       RRR4       \        VRRR7      ;_uu_ 4       p	\        P                  ! R	V	4       \        V	4       RRR4       R#   + '       g   i     ELX; i  + '       g   i     EL+; i  + '       g   i     L; i  + '       g   i     L; i  + '       g   i     L; i  + '       g   i     R# ; i)
r   wUTF-8)encodingzwriting territories file=%sNzwriting languages file=%szwriting keyboards file=%szwriting timezones file=%szwriting timezoneidparts file=%s)r   r   r   r   r   r   r   r   )
ZterritoriesfilenameZlanguagesfilenameZkeyboardsfilenameZtimezonesfilenameZtimezoneidpartsfilenameZterritoriesfileZlanguagesfileZkeyboardsfileZtimezonesfileZtimezoneidpartsfile
   &&&&&     r   _write_filesr     sg    
!3	9	9_2OD0 
: 
w	7	7=0-@m, 
8 
w	7	7=0-@m, 
8 
w	7	7=0-@m, 
8 
w	7	7=0-@m, 
8 
%sW	=	=AT68KL#$78 
>	= 
:	9	9 
8	7	7 
8	7 
8	7 
8	7 
>	=	=sG   #F	#F#F1#G#G#G*	F	F.	1G	G	G'	*G;	c                 s   a  . p\        S V 3R  lVR7       F-  pS V,          ^ 8w  g   K  VP                  VS V,          .4       K/  	  V# )c                 s*   < SP                  V 4      V 3# r   )get)r   
dictionaryr6   r   r   Z,_dictionary_to_ranked_list.<locals>.<lambda>  s    *..2CQ1Gr   )r   reverse)r   r   )r   r   Zsorted_listitems   f&  r   _dictionary_to_ranked_listr     sK    Kz'GQXYdq j&678 Z r   c                 s.    \        \        R  V 4      4      # )c                 s    V ^ ,          # )i    r   r   rh   r   r   Z&_ranked_list_to_list.<locals>.<lambda>  s    adr   )listmap)ranked_listrh   r   _ranked_list_to_listr     s    NK011r   c                 s    \        V 4      ^8  g   V # \        ^ \        V 4      ^,
          4       FA  pW,          ^,          W^,           ,          ^,          ,          V8  g   K4  V ^ V^,            p  V # 	  V # r   )lenZrange)r   Zcut_off_factorZir   r   _make_ranked_list_conciser     sq    {a1S%a'(>![1-a00>A%a!,K	 ) r   c                s   V '       d   V ^ ,          P                  4       '       d   V # V'       g   TpV'       g   RpR F'  p\        P                  ! RV 2V4      '       g   K%  V u # 	  V ^ ,          P                  4       V R,          ,           # )u;  
Title cases the first letter of “text”

But make exceptions for certain languages where always upper casing the first
letter does not make sense even for standalone strings.

:param text: The text which may need its first letter uppercased to be
             used standalone
:type text: string
:param languageId: identifier for the language
:type languageId: string
:param scriptId: identifier for the script
:type scriptId: string
:param territoryId: identifier for the territory
:type territoryId: string
:param languageIdQuery: identifier for the language used in the result
:type languageIdQuery: string
:param scriptIdQuery: identifier for the script used in the result
:type scriptIdQuery: string
:param territoryIdQuery: identifier for the territory used in the result
:type territoryIdQuery: string
:rtype: string
enZ^:r   NN)ZkaZnrZssZxhZyoZzu)ZistitlerematchZ
capitalize)ZtextrM   rN   rJ   languageIdQueryscriptIdQueryterritoryIdQuerylangs   &&&&&&& r   _capitalize_namer    sp    0 47??$$$488qK11K 5 7$r(**r   c                s   RpRpRpRpRpV '       df   V P                  R4      pV P                  R4      p^ Tu;8:  d   V8  d   M MW^,           V pV RV WR ,           p MV^ 8  d   W^,           R pV RV p V '       dT   V P                  4       P                  R4      pV^ 8  d    V P                  4       P                  R4      pV^ 8  d   RpV RV p V '       d   V R9   d	   R	pR
pRpRp V '       dj   \        P	                  4        FQ  w  rV P                  W4      p V P                  RV
,           4      '       g   K6  T
pV P                  RV
,           R4      p KS  	  V '       d7   V P                  R4      pV^ 8  d   W^,           R P                  4       pV RV p V '       d   \        P                  V 4      pV'       dc   VP                  R4      pVP                  R4      '       d   VP                  R4      pVP                  R4      '       d   VP                  R4      pM\        P                  ! RV 4       \        VVVVVR7      # )u  
Parses a locale name in glibc or CLDR format and returns
language, script, territory, variant, and encoding

:param localeId: The name of the locale
:type localeId: string
:return: The parts of the locale: language, script, territory, variant, encoding
:rtype: A namedtuple of strings
        Locale(language=string,
               script=string,
               territory=string,
               variant=string,
               encoding=string)

It replaces glibc names for scripts like “latin”
with the iso-15924 script names like “Latn”.
I.e. these inputs all give the same result:

    “sr_latin_RS”
    “sr_Latn_RS”
    “sr_RS@latin”
    “sr_RS@Latn”

Examples:

>>> parse_locale('de_DE')
Locale(language='de', script='', territory='DE', variant='', encoding='')

>>> parse_locale('de_DE.UTF-8')
Locale(language='de', script='', territory='DE', variant='', encoding='UTF-8')

>>> parse_locale('de_DE.utf8')
Locale(language='de', script='', territory='DE', variant='', encoding='utf8')

>>> parse_locale('de_DE@euro')
Locale(language='de', script='', territory='DE', variant='EURO', encoding='')

>>> parse_locale('de_DE.ISO-8859-15')
Locale(language='de', script='', territory='DE', variant='', encoding='ISO-8859-15')

>>> parse_locale('de_DE.ISO-8859-15@euro')
Locale(language='de', script='', territory='DE', variant='EURO', encoding='ISO-8859-15')

>>> parse_locale('de_DE.iso885915@euro')
Locale(language='de', script='', territory='DE', variant='EURO', encoding='iso885915')

>>> parse_locale('gez_ER.UTF-8@abegede')
Locale(language='gez', script='', territory='ER', variant='ABEGEDE', encoding='UTF-8')

>>> parse_locale('ar_ER.UTF-8@saaho')
Locale(language='ar', script='', territory='ER', variant='SAAHO', encoding='UTF-8')

>>> parse_locale('zh_Hant_TW')
Locale(language='zh', script='Hant', territory='TW', variant='', encoding='')

>>> parse_locale('zh_TW')
Locale(language='zh', script='', territory='TW', variant='', encoding='')

>>> parse_locale('es_419')
Locale(language='es', script='', territory='419', variant='', encoding='')

>>> parse_locale('sr_latin_RS')
Locale(language='sr', script='Latn', territory='RS', variant='', encoding='')

>>> parse_locale('sr_Latn_RS')
Locale(language='sr', script='Latn', territory='RS', variant='', encoding='')

>>> parse_locale('sr_RS@latin')
Locale(language='sr', script='Latn', territory='RS', variant='', encoding='')

>>> parse_locale('sr_RS@Latn')
Locale(language='sr', script='Latn', territory='RS', variant='', encoding='')

>>> parse_locale('sr_RS.UTF-8@latin')
Locale(language='sr', script='Latn', territory='RS', variant='', encoding='UTF-8')

>>> parse_locale('ca_ES')
Locale(language='ca', script='', territory='ES', variant='', encoding='')

>>> parse_locale('ca_ES.UTF-8')
Locale(language='ca', script='', territory='ES', variant='', encoding='UTF-8')

>>> parse_locale('ca_ES_VALENCIA')
Locale(language='ca', script='', territory='ES', variant='VALENCIA', encoding='')

>>> parse_locale('ca_Latn_ES_VALENCIA')
Locale(language='ca', script='Latn', territory='ES', variant='VALENCIA', encoding='')

>>> parse_locale('ca_ES.UTF-8@valencia')
Locale(language='ca', script='', territory='ES', variant='VALENCIA', encoding='UTF-8')

>>> parse_locale('ca_ES@valencia')
Locale(language='ca', script='', territory='ES', variant='VALENCIA', encoding='')

>>> parse_locale('en_US_POSIX')
Locale(language='en', script='', territory='US', variant='POSIX', encoding='')

>>> parse_locale('POSIX')
Locale(language='en', script='', territory='US', variant='POSIX', encoding='')

>>> parse_locale('C')
Locale(language='en', script='', territory='US', variant='POSIX', encoding='')

>>> parse_locale('C.UTF-8')
Locale(language='en', script='', territory='US', variant='POSIX', encoding='UTF-8')
 Z.Z@Nz	@valenciaZ	_VALENCIAVALENCIAPOSIXr   ZUSrZ   rX   rI   z&localeId contains invalid locale id=%srZ   rX   rI   variantr   )ZCr  Zen_US_POSIX)ZfindlowerZupper_glibc_script_idsr   r   Zendswith_cldr_locale_patternr   groupr   r   r   )rO   rZ   rX   rI   r  r   Z	dot_indexZat_indexZvalencia_indexr   Zscript_id_isor      &           r   parse_localer    s$   V HFIGHMM#&	==%	$H$ Qx8H
+hy.AAH!^A/H
+H!)..{;A%^^-22;?NQ G0H44HIGH"3"9"9";C'';H  }!455&#++C-,?D	 #<
 ==%q=
 !|}-335G	*H$**84{{:.H{{8$$X.{{;''!KK4	LLA8L8%!#	% %r   c                sD   \        V 4      pVP                  R8X  d9   \        VP                  VP                  VP
                  RVP                  R7      pVP                  R8X  d9   \        RVP                  VP
                  VP                  VP                  R7      pVP                  '       gV   V'       dN   \        P                  W4      p\        VP                  VVP
                  VP                  VP                  R7      pVP
                  '       gA   V'       d9   \        VP                  VP                  VVP                  VP                  R7      pVP                  R9   d   VP
                  '       d   VP                  '       g   VP
                  R	9   d;   \        VP                  RVP
                  VP                  VP                  R7      pV# VP
                  R
9   d9   \        VP                  RVP
                  VP                  VP                  R7      pV# )u  
Parses languageId and if it contains a valid ICU locale id,
returns the values for language, script, and territory found
in languageId instead of the original values given.

Before parsing, it replaces glibc names for scripts like “latin”
with the iso-15924 script names like “Latn”, both in the
languageId and the scriptId parameter. I.e.  language id like
“sr_latin_RS” is accepted as well and treated the same as
“sr_Latn_RS”.

Examples:

>>> _parse_and_split_languageId(languageId='de_DE')
Locale(language='de', script='', territory='DE', variant='', encoding='')

>>> _parse_and_split_languageId(languageId='de_DE.UTF-8')
Locale(language='de', script='', territory='DE', variant='', encoding='UTF-8')

>>> _parse_and_split_languageId(languageId='de_DE.utf8')
Locale(language='de', script='', territory='DE', variant='', encoding='utf8')

>>> _parse_and_split_languageId(languageId='de_DE@euro')
Locale(language='de', script='', territory='DE', variant='EURO', encoding='')

>>> _parse_and_split_languageId(languageId='de_DE.ISO-8859-15')
Locale(language='de', script='', territory='DE', variant='', encoding='ISO-8859-15')

>>> _parse_and_split_languageId(languageId='de_DE.ISO-8859-15@euro')
Locale(language='de', script='', territory='DE', variant='EURO', encoding='ISO-8859-15')

>>> _parse_and_split_languageId(languageId='de_DE.iso885915@euro')
Locale(language='de', script='', territory='DE', variant='EURO', encoding='iso885915')

>>> _parse_and_split_languageId(languageId='gez_ER.UTF-8@abegede')
Locale(language='gez', script='', territory='ER', variant='ABEGEDE', encoding='UTF-8')

>>> _parse_and_split_languageId(languageId='ar_ER.UTF-8@saaho')
Locale(language='ar', script='', territory='ER', variant='SAAHO', encoding='UTF-8')

>>> _parse_and_split_languageId(languageId='zh_Hant_TW')
Locale(language='zh', script='Hant', territory='TW', variant='', encoding='')

>>> _parse_and_split_languageId(languageId='zh_TW')
Locale(language='zh', script='Hant', territory='TW', variant='', encoding='')

>>> _parse_and_split_languageId(languageId='zh_Hans_CN')
Locale(language='zh', script='Hans', territory='CN', variant='', encoding='')

>>> _parse_and_split_languageId(languageId='zh_CN')
Locale(language='zh', script='Hans', territory='CN', variant='', encoding='')

>>> _parse_and_split_languageId(languageId='es_419')
Locale(language='es', script='', territory='419', variant='', encoding='')

>>> _parse_and_split_languageId(languageId='sr_latin_RS')
Locale(language='sr', script='Latn', territory='RS', variant='', encoding='')

>>> _parse_and_split_languageId(languageId='sr_Latn_RS')
Locale(language='sr', script='Latn', territory='RS', variant='', encoding='')

>>> _parse_and_split_languageId(languageId='ca_ES')
Locale(language='ca', script='', territory='ES', variant='', encoding='')

>>> _parse_and_split_languageId(languageId='ca_ES.UTF-8')
Locale(language='ca', script='', territory='ES', variant='', encoding='UTF-8')

>>> _parse_and_split_languageId(languageId='ca_ES_VALENCIA')
Locale(language='ca_ES_VALENCIA', script='', territory='ES', variant='VALENCIA', encoding='')

>>> _parse_and_split_languageId(languageId='ca_Latn_ES_VALENCIA')
Locale(language='ca_ES_VALENCIA', script='Latn', territory='ES', variant='VALENCIA', encoding='')

>>> _parse_and_split_languageId(languageId='ca_Latn_ES_valencia')
Locale(language='ca_ES_VALENCIA', script='Latn', territory='ES', variant='VALENCIA', encoding='')

>>> _parse_and_split_languageId(languageId='ca_ES.UTF-8@valencia')
Locale(language='ca_ES_VALENCIA', script='', territory='ES', variant='VALENCIA', encoding='UTF-8')

>>> _parse_and_split_languageId(languageId='ca_ES@valencia')
Locale(language='ca_ES_VALENCIA', script='', territory='ES', variant='VALENCIA', encoding='')

>>> _parse_and_split_languageId(languageId='ca_Latn_ES@valencia')
Locale(language='ca_ES_VALENCIA', script='Latn', territory='ES', variant='VALENCIA', encoding='')

>>> _parse_and_split_languageId(languageId='ca_Latn_ES@VALENCIA')
Locale(language='ca_ES_VALENCIA', script='Latn', territory='ES', variant='VALENCIA', encoding='')
r  r  r  r  Zca_ES_VALENCIAZHansZHant)ZzhZcmn)ZCNZSG)ZHKZMOZTW)	r  r  r   rZ   rX   rI   r   r  r   )rM   rN   rJ   rY   s   &&& r   _parse_and_split_languageIdr    s   r *%F~~ %}}"("2"2 "!'	2
 ~~#!1%}}"("2"2 &!'	2
 ===X$((<'"("2"2 &!'	2
 %}}"- &!'	2 -'F,<,<,<V]]]|+V__#)&,&6&6$*NN%+__	6F M !33V__#)&,&6&6$*NN%+__	6F
 Mr   c           
     s>    \        \        V VVVVR7      V VVVR7      # )u  Query translations of territory names

:param territoryId: identifier for the territory
:type territoryId: string
:param languageIdQuery: identifier for the language used in the result
:type languageIdQuery: string
:param scriptIdQuery: identifier for the script used in the result
:type scriptIdQuery: string
:param territoryIdQuery: identifier for the territory used in the result
:type territoryIdQuery: string
:param fallback: Whether a fallback to English should be returned if the
                 name cannot be found in the requested language.
:type fallback: Boolean
:rtype: string

**Examples:**

Switzerland is called “Schweiz” in German:

>>> print(territory_name(territoryId="CH", languageIdQuery="de"))
Schweiz

And it is called “Svizzera” in Italian:

>>> print(territory_name(territoryId="CH", languageIdQuery="it"))
Svizzera

And it is called “スイス” in Japanese:

>>> print(territory_name(territoryId="CH", languageIdQuery="ja"))
スイス
rJ   r   r   r   fallbackrJ   r   r   r   )r  _territory_namer  s   &&&&&r   territory_namer  5  s6    B K)8'4*:"*		,
  '#)	+ 	+r   c                sr   \        VVVR7      pVP                  pVP                  pVP                  pV \        9   Ed   V'       di   V'       da   V'       dY   VR,           V,           R,           V,           pV\        V ,          P
                  9   d   \        V ,          P
                  V,          # V'       dS   V'       dK   VR,           V,           pV\        V ,          P
                  9   d   \        V ,          P
                  V,          # V'       dS   V'       dK   VR,           V,           pV\        V ,          P
                  9   d   \        V ,          P
                  V,          # RpV'       d=   \        VR,           V,           R7      R,          p\        VR7      R,          p	W8w  d   RpV'       dE   V'       g=   TpV\        V ,          P
                  9   d   \        V ,          P
                  V,          # V'       d;   R\        V ,          P
                  9   d   \        V ,          P
                  R,          # R# )	ad  Internal function to query translations of territory names

:param territoryId: identifier for the territory
:type territoryId: string
:param languageIdQuery: identifier for the language used in the result
:type languageIdQuery: string
:param scriptIdQuery: identifier for the script used in the result
:type scriptIdQuery: string
:param territoryIdQuery: identifier for the territory used in the result
:type territoryIdQuery: string
:param fallback: Whether a fallback to English should be returned if the
                 name cannot be found in the requested language.
:type fallback: Boolean
:rtype: string
rM   rN   rJ   _FrM   Nr   NTr   r  )r  rZ   rX   rI   r_   r   list_scripts)
rJ   r   r   r   r  rY   icuLocaleIdQueryfallback_changes_main_scriptold_main_scriptnew_main_scriptr   r   r  r  a  s     )O2?5EGF ooOMMM''o%}1A.s2=@DEUU?;#?#E#EE&{399:JKK}.s2=@?;#?#E#EE&{399:JKK/.s23CC?;#?#E#EE&{399:JKK',$**3.}<>>@BO**,,.0O1/3,#?.?;#?#E#EE&{399:JKK < B BB";/55d;;r   c                sF    \        \        V VVVVVVR7      V VVVVVR7      # )u  Query translations of language names

:param languageId: identifier for the language
:type languageId: string
:param scriptId: identifier for the script
:type scriptId: string
:param territoryId: identifier for the territory
:type territoryId: string
:param languageIdQuery: identifier for the language used in the result
:type languageIdQuery: string
:param scriptIdQuery: identifier for the script used in the result
:type scriptIdQuery: string
:param territoryIdQuery: identifier for the territory used in the result
:type territoryIdQuery: string
:param fallback: Whether a fallback to English should be returned if the
                 name cannot be found in the requested language.
:type fallback: Boolean
:rtype: string

**Examples:**

>>> print(language_name(languageId="sr"))
Српски

I.e. the endonym for “Serbian” in the default Cyrillic script is
“српски”.

If the script “Cyrl” is supplied as well, the name of the
script is added for clarity:

>>> print(language_name(languageId="sr", scriptId="Cyrl"))
Српски (Ћирилица)

And in Latin script the endonym is:

>>> print(language_name(languageId="sr", scriptId="Latn"))
Srpski (Latinica)

And “Serbian” translated to English is:

>>> print(language_name(languageId="sr", languageIdQuery="en"))
Serbian

And with adding the script information:

>>> print(language_name(languageId="sr", scriptId="Cyrl", languageIdQuery="en"))
Serbian (Cyrillic)

>>> print(language_name(languageId="sr", scriptId="Latn", languageIdQuery="en"))
Serbian (Latin)

>>> print(language_name(languageId="de_DE", languageIdQuery="en"))
German (Germany)

>>> print(language_name(languageId="es_419", languageIdQuery="en"))
Spanish (Latin America)

>>> print(language_name(languageId="ca_ES"))
Català (Espanya)

>>> print(language_name(languageId="ca_ES.UTF-8"))
Català (Espanya)

>>> print(language_name(languageId="ca_ES@valencia"))
Valencià (Espanya)

>>> print(language_name(languageId="ca_ES.utf8@valencia"))
Valencià (Espanya)

>>> print(language_name(languageId="ca_ES.utf8@valencia"))
Valencià (Espanya)

>>> print(language_name(languageId="ca_ES.utf8@valencia", languageIdQuery='de'))
Valencianisch (Spanien)

>>> print(language_name(languageId="ca_ES.utf8@valencia", languageIdQuery='en'))
Valencian (Spain)
rM   rN   rJ   r   r   r   r  )rM   rN   rJ   r   r   r   )r  _language_namer  s   &&&&&&&r   language_namer    sB    ^ *!)$/(7&3)9!)	+ '#)+ +r   c                s   V '       g   R# Rp\        V VVR7      pVP                  p VP                  pVP                  p\        VVVR7      p	V	P                  pV	P                  pV	P                  pV'       g   T pTpTpV '       Ed   V'       Ed   V'       Ed   V R,           V,           R,           V,           pV\        9   Edi   V'       di   V'       da   V'       dY   VR,           V,           R,           V,           p
V
\        V,          P
                  9   d   \        V,          P
                  V
,          # V'       dS   V'       dK   VR,           V,           p
V
\        V,          P
                  9   d   \        V,          P
                  V
,          # V'       dS   V'       dK   VR,           V,           p
V
\        V,          P
                  9   d   \        V,          P
                  V
,          # V'       d=   Tp
V
\        V,          P
                  9   d   \        V,          P
                  V
,          # V '       Ed!   V'       Ed   V R,           V,           pV\        9   Ed   \        VVVVR7      pV'       d   V'       d   V'       dz   VR,           V,           R,           V,           p
V
\        V,          P
                  9   d@   \        V,          P
                  V
,          pV'       d   VR,           V,           R,           # V# V'       dt   V'       dl   VR,           V,           p
V
\        V,          P
                  9   d@   \        V,          P
                  V
,          pV'       d   VR,           V,           R,           # V# V'       dt   V'       dl   VR,           V,           p
V
\        V,          P
                  9   d@   \        V,          P
                  V
,          pV'       d   VR,           V,           R,           # V# V'       d^   Tp
V
\        V,          P
                  9   d@   \        V,          P
                  V
,          pV'       d   VR,           V,           R,           # V# V '       Ed   V'       Ed   V R,           V,           pV\        9   Edi   V'       di   V'       da   V'       dY   VR,           V,           R,           V,           p
V
\        V,          P
                  9   d   \        V,          P
                  V
,          # V'       dS   V'       dK   VR,           V,           p
V
\        V,          P
                  9   d   \        V,          P
                  V
,          # V'       dS   V'       dK   VR,           V,           p
V
\        V,          P
                  9   d   \        V,          P
                  V
,          # V'       d=   Tp
V
\        V,          P
                  9   d   \        V,          P
                  V
,          # VP                  R9  dF   \        V VVVR7      p\        VVVVR7      pV'       d    V'       d   VR,           V,           R,           # T pV\        9   Ed   V'       di   V'       da   V'       dY   VR,           V,           R,           V,           p
V
\        V,          P
                  9   d   \        V,          P
                  V
,          # V'       dS   V'       dK   VR,           V,           p
V
\        V,          P
                  9   d   \        V,          P
                  V
,          # V'       dS   V'       dK   VR,           V,           p
V
\        V,          P
                  9   d   \        V,          P
                  V
,          # RpV'       d=   \        VR,           V,           R	7      R
,          p\        VR	7      R
,          pW8w  d   RpV'       dE   V'       g=   Tp
V
\        V,          P
                  9   d   \        V,          P
                  V
,          # V'       dN   V'       dF   V\        9   d;   R\        V,          P
                  9   d   \        V,          P
                  R,          # R# )a  Internal function to query translations of language names

:param languageId: identifier for the language
:type languageId: string
:param scriptId: identifier for the script
:type scriptId: string
:param territoryId: identifier for the territory
:type territoryId: string
:param languageIdQuery: identifier for the language used in the result
:type languageIdQuery: string
:param scriptIdQuery: identifier for the script used in the result
:type scriptIdQuery: string
:param territoryIdQuery: identifier for the territory used in the result
:type territoryIdQuery: string
:param fallback: Whether a fallback to English should be returned if the
                 name cannot be found in the requested language.
:type fallback: Boolean
:rtype: string
r  r  r  r  z (Z))rM   r   r   r   Fr  r  Tr   )r  )
r  rZ   rX   rI   rz   r   r  r  r  r  )rM   rN   rJ   r   r   r   r  ZicuLocaleIdrY   ZlocaleQueryr  ZcnameZlnamer  r  r  s   &&&&&&&         r   r  r    se   ( K(J2:5@BF J}}H""K-7D:JLK "**O&&M",,$ &zhh;; nX-c1+=-'=5E#23#6}#DS#HIY#Y #}['A'G'GG(5;;<LMM=#23#6}#D #}['A'G'GG(5;;<LMM%5#23#67G#G #}['A'G'GG(5;;<LMM#2 #}['A'G'GG(5;;<LMMzhh nX--'"{3B1>4DFE M6F#23#6}#DS#HIY#Y #}['A'G'GG)+6<<=MNE$t|E1#55 LM#23#6}#D #}['A'G'GG)+6<<=MNE$t|E1#55 L%5#23#67G#G #}['A'G'GG)+6<<=MNE$t|E1#55 L#2 #}['A'G'GG)+6<<=MNE$t|E1#55 Lzkk n[0-'M6F#23#6}#DS#HIY#Y #}['A'G'GG(5;;<LMMM#23#6}#D #}['A'G'GG(5;;<LMM%5#23#67G#G #}['A'G'GG(5;;<LMM#2 #}['A'G'GG(5;;<LMM>>. "Z2A0=3CEE #{1@/<2BDE t|E)#--Km#2B.s2=@DEUU=#=#C#CC$[1778HII.s2=@=#=#C#CC$[1778HII/.s23CC=#=#C#CC$[1778HII',$**3.}<>>@BO**,,.0O1/3,#?.=#=#C#CC$[1778HII=(M+.444[)//55r   c                s   V '       d	   V'       g   R# V P                  R4      p. pV F  pV\        9  d   VP                  V4       K!  V\        V,          P                  9   d<   \        V,          P                  V,          pV'       d   VP                  V4       Kv  Kx  VR8X  g   K  VP	                  RR4      pVP                  V4       K  	  \        V4      \        V4      8X  d   RP                  V4      # R# )zQuery translation of timezone IDs by querying translations
for each part of the ID seperately and putting the results together
r  Z/r   r  Z )Zsplitr   r   r   r   r   r   )rS   r  ZtimezoneId_partsZ
part_namesZtimezoneId_partrU   s   &&    r   _timezone_name_from_id_partsr    s     +!'',J+"55o.2?CIII&7==>NOD!!$' %"**34Dd# , :#.//xx
##r   c                s    V '       d	   V'       g   R# V \         9   d;   V\         V ,          P                  9   d   \         V ,          P                  V,          # \        WR7      pV'       d   V# R# )z4
Internal helper function to translate timezone IDs
r  rS   r  )r   r   r  )rS   r  Zname_from_partsr   r   _timezone_namer!    sY     +]"}Z8>>> ,223CDD2BOr   c                s   \        VVVR7      pVP                  pVP                  pVP                  pV'       dD   V'       d<   V'       d4   \	        V VR,           V,           R,           V,           R7      pV'       d   V# V'       d.   V'       d&   \	        V VR,           V,           R7      pV'       d   V# V'       d.   V'       d&   \	        V VR,           V,           R7      pV'       d   V# V'       d   \	        V VR7      pV'       d   V# V # )u  Query translations of timezone IDs

:param timezoneId: identifier for the time zone
:type timezoneId: string
:param languageIdQuery: identifier for the language used in the result
:type languageIdQuery: string
:param scriptIdQuery: identifier for the script used in the result
:type scriptIdQuery: string
:param territoryIdQuery: identifier for the territory used in the result
:type territoryId: string
:rtype: string

**Examples:**

>>> print(timezone_name(timezoneId='US/Pacific', languageIdQuery='ja'))
アメリカ合衆国/太平洋時間

If no translation can be found, the timezone ID is returned
unchanged:

>>> print(timezone_name(timezoneId='Pacific/Pago_Pago', languageIdQuery='xxx'))
Pacific/Pago_Pago
r  r  r   )r  rZ   rX   rI   r!  )rS   r   r   r   rY   rU   s   &&&&  r   timezone_namer"    s    0 )O2?5EGF ooOMMM''=-=!,S0>sBCSSU K=!,S0>@ K+!,S01AAC K!,. Kr   c                s    V '       g   R# \        V \        4      '       g   V P                  R4      p \        P	                  4        F2  w  rVP
                  P                  4        F  pW8X  g   K  Vu u # 	  K4  	  R# )u4  Query the territoryId from a translated name of a territory.

:param territoryName: the translated name of a language
:type territoryName: string
:rtype: string

The translated name given should be a Python Unicode string or an
UTF-8 encoded string.

The translated name can be in any language. But there will be only
a result if the translation matches exactly.

**Examples:**

>>> territoryId("India")
'IN'

>>> territoryId("भारत")
'IN'

>>> territoryId("インド")
'IN'

>>> territoryId("Latin America")
'419'

>>> territoryId("Latinoamérica")
'419'

r  r   )
isinstancer`   decoder_   r   r   values)ZterritoryNamerJ   territory_itemrU   r   r   rJ   rJ     sg    > mS))%,,W5'6'<'<'>#"((//1D$"" 2 (? r   c                s   V '       g   R# \        V \        4      '       g   V P                  R4      p \        P	                  4        FO  w  rVP
                  P                  4        F,  pV P                  4       VP                  4       8X  g   K(  Vu u # 	  KQ  	  \        P                  ! R\        P                  \        P                  ,          4      pVP                  V 4      pV'       d   VP                  R4      pVP                  R4      p\        P	                  4        F  w  rVP
                  P                  4        F  pVP                  4       VP                  4       8X  g   K(  \        P	                  4        Fa  w  rV
P
                  P                  4        F>  pVP                  4       VP                  4       8X  g   K(  VR,           V	,           u u u u # 	  Kc  	  K  	  K  	  R# )u  Query the languageId from a translated name of a language.

:param languageName: the translated name of a language
:type languageName: string
:rtype: string

The translated name given should be a Python Unicode string or an
UTF-8 encoded string.

The translated name can be in any language. But there will be only
a result if the translation matches exactly.

**Examples:**

>>> languageId("Marathi")
'mr'

>>> languageId("मराठी")
'mr'

>>> languageId("マラーティー語")
'mr'

r  r   z?^(?P<language_name>[^()]+)[\s]+[(](?P<territory_name>[^()]+)[)]r  r  r  )r#  r`   r$  rz   r   r   r%  r  r   compileZ	MULTILINEZUNICODEZsearchr
  r_   )ZlanguageNamerM   Zlanguage_itemrU   Zlanguage_territory_patternr   r  r  Zlanguage_item_namerJ   r&  Zterritory_item_namer  r   rM   rM     sy   2 lC((#**73%2%8%8%:!
!''..0D!!#tzz|3!! 1 &; "$J
RZZ"! '--l;EO4%56)6)<)<)>%J&3&9&9&@&@&B" &&(,>,D,D,FF7F7L7L7N33A3G3G3N3N3P/-3359L9R9R9TT'1#~k'A A A 4Q 8O 'C *? r   i@B c                s   / pRp\        VVVR7      pVP                  pVP                  pVP                  pV'       dY   V'       dQ   V'       dI   VR,           V,           R,           V,           \        9   d"   VR,           V,           R,           V,           pRpMuV'       d3   V'       d+   VR,           V,           \        9   d   VR,           V,           pM;V'       d4   V'       d,   VR,           V,           \        9   d   VR,           V,           pRp^dpV\        9   d   \        V,          P
                   F  p\        V,          P
                  V,          ^ 8w  g   K(  Wu9  d"   \        V,          P
                  V,          WW&   MHWW;;,          \        V,          P
                  V,          ,          uu&   WW;;,          \        ,          uu&   WW;;,          V,          uu&   K  	  ^p	V\        9   d   V'       g   \        V,          P
                   F  p\        V,          P
                  V,          ^ 8w  g   K(  Wu9  d"   \        V,          P
                  V,          WW&   MHWW;;,          \        V,          P
                  V,          ,          uu&   WW;;,          \        ,          uu&   WW;;,          V	,          uu&   K  	  \        V4      p
V '       d   \        V
4      p
V'       d   V
# \        V
4      # )u  List suitable glibc locales

:param concise: if True, return only to highly ranked results
:type concise: boolean
:param show_weights: Also return the weights used in the ranking
:type show_weights: boolean
:param languageId: identifier for the language
:type languageId: string
:param scriptId: identifier for the script
:type scriptId: string
:param territoryId: identifier for the territory
:type territoryId: string
:rtype: a list of strings

**Examples:**

List the suitable locales for the language “German”:

>>> list_locales(languageId="de")
['de_DE.UTF-8', 'de_AT.UTF-8', 'de_CH.UTF-8', 'de_IT.UTF-8', 'de_LI.UTF-8', 'de_BE.UTF-8', 'de_LU.UTF-8']

So this returns a list of locales for German. These lists are
sorted in order of decreasing likelyhood, i.e. the most common
value comes first.

One can also list the possible locales for the territory “Switzerland”:

>>> list_locales(territoryId="CH")
['de_CH.UTF-8', 'fr_CH.UTF-8', 'it_CH.UTF-8', 'wae_CH.UTF-8']


If one knows both, the language “German” and the territory
“Switzerland”, the result is unique:

>>> list_locales(languageId="de", territoryId="CH")
['de_CH.UTF-8']

Fr  r  T)r  rZ   rX   rI   rz   r
   extra_bonusr_   r   r   r   )conciseshow_weightsrM   rN   rJ   Zranked_localesskipTerritoryrY   language_bonusterritory_bonusr   s   &&&&&      r   list_localesr.  L  s#   N NM(J2:5@BF J}}H""Kh;:c>(3J33N{3Z^k3k^H,S0<
	Z^H%<%M^H,
	
3{(Bm(S^K/
N]"#J/77FZ(008A=/-::-F-N-Nv-VN*"*mJ.G.O.OPV.WW*"*k9*&.8& 8 Oo%m%k2::F{+33F;q@/-<[-I-Q-QRX-YN*"*ok.J.R.RSY.ZZ*"*k9*&/9& ; -^<K/<,,r   c                 sv   . p V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       \        \        V 4      pV Uu. uF  q"P                  NK  	  up# u upi )	a  List common languages

derived from GNOME/gnome-control-center
    panels/common/cc-common-language.c
    cc_common_language_get_initial_languages

which is based on number of speakers.

**Examples:**

>>> list_common_languages()
['ar', 'en', 'fr', 'de', 'ja', 'zh', 'ru', 'es']

zar_EG.UTF-8zen_US.UTF-8zfr_FR.UTF-8zde_DE.UTF-8zja_JP.UTF-8zzh_CN.UTF-8zru_RU.UTF-8zes_ES.UTF-8)r   r   r  rZ   )common_localesr   r         r   list_common_languagesr1    s      N-(-(-(-(-(-(-(-(L.1I&/0idMMi000s   B6c                s   / pRp\        VVVR7      pVP                  pVP                  pVP                  pV'       d   V.# V'       d4   V'       d,   VR,           V,           \        9   d   VR,           V,           pRp^dpV\        9   d   \        V,          P
                   F  p	\        V,          P
                  V	,          ^ 8w  g   K(  W9  d"   \        V,          P
                  V	,          WY&   MHWY;;,          \        V,          P
                  V	,          ,          uu&   WY;;,          \        ,          uu&   WY;;,          V,          uu&   K  	  ^p
V\        9   d   V'       g   \        V,          P
                   F  p	\        V,          P
                  V	,          ^ 8w  g   K(  W9  d"   \        V,          P
                  V	,          WY&   MHWY;;,          \        V,          P
                  V	,          ,          uu&   WY;;,          \        ,          uu&   WY;;,          V
,          uu&   K  	  \        V4      pV '       d   \        V4      pV'       d   V# \        V4      # )u  List scripts used for a language and/or in a territory

:param concise: if True, return only to highly ranked results
:type concise: boolean
:param show_weights: Also return the weights used in the ranking
:type show_weights: boolean
:param languageId: identifier for the language
:type languageId: string
:param scriptId: identifier for the script
:type scriptId: string
:param territoryId: identifier for the territory
:type territoryId: string
:rtype: a list of strings

Returns a list of ISO-15924 script ids:

https://en.wikipedia.org/wiki/ISO_15924

**Examples:**

List the suitable scripts for the language “Serbian”:

>>> list_scripts(languageId="sr")
['Cyrl', 'Latn']

So this returns a list of scripts which are in use for
Serbian. These lists are sorted in order of decreasing likelyhood,
i.e. the most common value comes first.

List the suitable scripts for the language “Punjabi”:

>>> list_scripts(languageId="pa")
['Guru', 'Arab']

One can also list the possible scripts for a territory like
“Pakistan”:

>>> list_scripts(territoryId="PK")
['Arab']

If one knows both, the language “Punjabi” and the territory
“Pakistan” or “India”, one can find out which script is the
preferred one:

>>> list_scripts(languageId="pa", territoryId="PK")
['Arab']

So the preferred script for Punjabi in Pakistan is “Arab”

>>> list_scripts(languageId="pa", territoryId="IN")
['Guru', 'Arab']

and the preferred script for Punjabi in India is “Guru”.

Fr  r  T)r  rZ   rX   rI   rz   r	   r(  r_   r   r   r   )r)  r*  rM   rN   rJ   Zranked_scriptsr+  rY   r,  rX   r-  r      &&&&&       r   r  r    s   p NM(J2:5@BF J}}H""Kzkjn[&@M&Q^K/
N]"#J/77FZ(008A=/-::-F-N-Nv-VN*"*mJ.G.O.OPV.WW*"*k9*&.8& 8 Oo%m%k2::F{+33F;q@/-<[-I-Q-QRX-YN*"*ok.J.R.RSY.ZZ*"*k9*&/9& ; -^<K/<,,r   c                s   / pRp\        VVVR7      pVP                  pVP                  pVP                  pV'       dY   V'       dQ   V'       dI   VR,           V,           R,           V,           \        9   d"   VR,           V,           R,           V,           pRpMwV'       d5   V'       d-   VR,           V,           \        9   d   VR,           V,           pRpM;V'       d4   V'       d,   VR,           V,           \        9   d   VR,           V,           pRp^dpV\        9   d   \        V,          P
                   F  p	\        V,          P
                  V	,          ^ 8w  g   K(  W9  d"   \        V,          P
                  V	,          WY&   MHWY;;,          \        V,          P
                  V	,          ,          uu&   WY;;,          \        ,          uu&   WY;;,          V,          uu&   K  	  ^p
V\        9   d   V'       g   \        V,          P
                   F  p	\        V,          P
                  V	,          ^ 8w  g   K(  W9  d"   \        V,          P
                  V	,          WY&   MHWY;;,          \        V,          P
                  V	,          ,          uu&   WY;;,          \        ,          uu&   WY;;,          V
,          uu&   K  	  \        V4      pV '       d   \        V4      pV'       d   V# \        V4      # )u|  List suitable input methods

:param concise: if True, return only to highly ranked results
:type concise: boolean
:param show_weights: Also return the weights used in the ranking
:type show_weights: boolean
:param languageId: identifier for the language
:type languageId: string
:param scriptId: identifier for the script
:type scriptId: string
:param territoryId: identifier for the territory
:type territoryId: string
:rtype: a list of strings

**Examples:**

List the suitable input methods for the language “Japanese”:

>>> list_inputmethods(languageId="ja")
['ibus/anthy', 'ibus/kkc']

So this returns a list of input methods for Japanese. These lists are
sorted in order of decreasing likelyhood, i.e. the most common
value comes first.

One can also list the possible input methods for the territory “Japan”:

>>> list_inputmethods(territoryId="JP")
['ibus/anthy', 'ibus/kkc']
Fr  r  T)r  rZ   rX   rI   rz   r   r(  r_   r   r   r   )r)  r*  rM   rN   rJ   Zranked_inputmethodsr+  rY   r,  r\   r-  r   r2  r   list_inputmethodsr3    s.   > M(J2:5@BF J}}H""Kh;:c>(3J33N{3Z^k3k^H,S0<
	Z^H%<%M^H,
	
3{(Bm(S^K/
N]"(4AAKZ(55kBaG97DZ7P7]7]^i7j'4'4j8Q8^8^_j8kk4'4C4#0NB0 B Oo%m*;7DDK{+88EJ97F{7S7`7`al7m'4'48T8a8abm8nn4'4C4#0OC0 E --@AK/<,,r   c                s   / pRp\        VVVR7      pVP                  pVP                  pVP                  pV'       dY   V'       dQ   V'       dI   VR,           V,           R,           V,           \        9   d"   VR,           V,           R,           V,           pRpMuV'       d3   V'       d+   VR,           V,           \        9   d   VR,           V,           pM;V'       d4   V'       d,   VR,           V,           \        9   d   VR,           V,           pRp^pV\        9   d   \        V,          P
                   F  p	\        V,          P
                  V	,          ^ 8w  g   K(  W9  d"   \        V,          P
                  V	,          WY&   MHWY;;,          \        V,          P
                  V	,          ,          uu&   WY;;,          \        ,          uu&   WY;;,          V,          uu&   K  	  ^p
V\        9   d   V'       g   \        V,          P
                   F  p	\        V,          P
                  V	,          ^ 8w  g   K(  W9  d"   \        V,          P
                  V	,          WY&   MHWY;;,          \        V,          P
                  V	,          ,          uu&   WY;;,          \        ,          uu&   WY;;,          V
,          uu&   K  	  \        V4      pV '       d   \        V4      pV'       d   V# \        V4      # )u  List likely X11 keyboard layouts

:param concise: if True, return only to highly ranked results
:type concise: boolean
:param show_weights: Also return the weights used in the ranking
:type show_weights: boolean
:param languageId: identifier for the language
:type languageId: string
:param scriptId: identifier for the script
:type scriptId: string
:param territoryId: identifier for the territory
:type territoryId: string
:rtype: a list of strings

**Examples:**

Listing likely X11 keyboard layouts for “German”:

>>> list_keyboards(languageId="de")
['de(nodeadkeys)', 'de(deadacute)', 'at(nodeadkeys)', 'ch', 'be(oss)']

Listing likely X11 keyboard layouts for “Switzerland”:

>>> list_keyboards(territoryId="CH")
['ch', 'ch(fr)', 'it']

When specifying both “German” *and* “Switzerland”, the
returned X11 keyboard layout is unique:

>>> list_keyboards(languageId="de", territoryId="CH")
['ch']
Fr  r  T)r  rZ   rX   rI   rz   r   r(  r_   r   r   r   )r)  r*  rM   rN   rJ   Zranked_keyboardsr+  rY   r,  r[   r-  r   r2  r   list_keyboardsr4  g  s(   B M(J2:5@BF J}}H""Kh;:c>(3J33N{3Z^k3k^H,S0<
	Z^H%<%M^H,
	
3{(Bm(S^K/
N]"%j1;;HZ(228<A31>z1J1T1TU]1^$.$.-
2K2U2UV^2__.$.+=. *n<* < Oo%m'4>>H{+55h?1D31@1M1W1WX`1a$.$./+2N2X2XYa2bb.$.+=. *o=* ? --=>K/<,,r   c                s   . pV '       g   V'       g   V'       g   \         P                  4        F\  w  rEVP                  pVP                  4        UUu. uF  w  rxV\        8  g   K  VNK  	  p	ppV	'       g   KK  VP	                  V	4       K^  	  \        \        V4      4      p/ p
\        WVR7      pVP                  '       d   V
P                  RVP                  /4       VP                  '       d   V
P                  RVP                  /4       VP                  '       d   V
P                  RVP                  /4       \        R/ V
B pV'       d   VP                  V^ ,          4       \        V4      # u uppi )a  Returns highest ranked keyboard layout(s)
2
    :param languageId: identifier for the language
    :type languageId: string
    :param scriptId: identifier for the script
    :type scriptId: string
    :param territoryId: identifier for the territory
    :type territoryId: string
    :return: list of keyboard layouts
    :rtype: list of str(s)

    **Examples:**

    >>> list_common_keyboards()
    ['af(ps)', 'al', 'am', 'ara', 'au', 'az', 'ba', 'be(oss)', 'bg', 'br', 'bt', 'by', 'ca(eng)', 'ca(ike)', 'ch', 'cn', 'cn(ug)', 'cz', 'de(nodeadkeys)', 'dk', 'ee', 'es', 'es(ast)', 'es(cat)', 'et', 'fi', 'fo', 'fr(bre)', 'fr(oss)', 'gb', 'ge', 'gr', 'hr', 'hu', 'ie(CloGaelach)', 'il', 'in(eng)', 'ir', 'is', 'it', 'jp', 'ke', 'kg', 'kh', 'kr', 'kz', 'la', 'latam', 'lt', 'lv', 'ma(tifinagh)', 'mk', 'mm', 'mn', 'mt', 'mv', 'ng', 'ng(hausa)', 'ng(igbo)', 'ng(yoruba)', 'no', 'np', 'ph', 'pk', 'pl', 'pt', 'ro', 'rs', 'rs(latin)', 'ru', 'ru(bak)', 'ru(chm)', 'ru(cv)', 'ru(kom)', 'ru(os_winkeys)', 'ru(sah)', 'ru(tt)', 'ru(udm)', 'ru(xal)', 'se', 'si', 'sk', 'sn', 'syc', 'th', 'tj', 'tm', 'tr', 'tr(crh)', 'tr(ku)', 'tw', 'ua', 'us', 'us(altgr-intl)', 'us(euro)', 'us(intl)', 'uz', 'vn', 'za']
    >>> list_common_keyboards(languageId='fr')
    ['fr(oss)']
    >>> list_common_keyboards(territoryId='CA')
    ['ca(eng)']
    >>> list_common_keyboards(territoryId='FR')
    ['fr(oss)']
    >>> list_common_keyboards(languageId='fr', territoryId='CA')
    ['ca']
    >>> list_common_keyboards(languageId='de', territoryId='FR')
    ['fr(oss)']
    >>> list_common_keyboards(languageId='sr', scriptId='Latn')
    ['rs(latin)']
    >>> list_common_keyboards(languageId='zh', scriptId='Hans')
    ['cn']
    >>> list_common_keyboards(languageId='zh', scriptId='Hans', territoryId='TW')
    ['tw']
    r  rM   rN   rJ   r   )rz   r   r   _KEYBOARD_LAYOUT_RANK_THRESHOLDextendr   setr  rZ   updaterX   rI   r4  r   r   )rM   rN   rJ   Zhigh_ranked_keyboardsr  rZ   Zkeyboard_layoutsZlayoutrL   Zselected_layoutskwargsrY   Zcommon_layoutss   &&&          r   list_common_keyboardsr:    s;   F h{(..0KA'11;K;Q;Q;S  L;S<6#'+J#J !';S  L%,,-=> 1 !%S)>%? @F(kF |V__56}}}z6==12}f&6&678#-f-N$$^A%67'((+ Ls   E5'E5c                s   . pV '       g   V'       g   V'       g   \        4        Fq  p\        V,          P                  p\        VP	                  4       R R7       UUu. uF  w  rgV\
        8  g   K  VNK  	  pppV'       g   K`  VP                  V4       Ks  	  V# / p	\        WVR7      pVP                  '       d   V	P                  RVP                  /4       VP                  '       d   V	P                  RVP                  /4       VP                  '       d   V	P                  RVP                  /4       \        R/ V	B p
V
'       d   VP                  V
^ ,          4       V# u uppi )a  Returns highest ranked locales

:param languageId: identifier for the language
:type languageId: string
:param scriptId: identifier for the script
:type scriptId: string
:param territoryId: identifier for the territory
:type territoryId: string
:return: list of locales
:rtype: list of strings

**Examples:**

>>> list_common_locales()
['ar_EG.UTF-8', 'en_US.UTF-8', 'en_GB.UTF-8', 'fr_FR.UTF-8', 'de_DE.UTF-8', 'ja_JP.UTF-8', 'zh_CN.UTF-8', 'ru_RU.UTF-8', 'es_ES.UTF-8']

>>> list_common_locales(languageId='fr')
['fr_FR.UTF-8']

>>> list_common_locales(territoryId='CA')
['en_CA.UTF-8']

>>> list_common_locales(territoryId='FR')
['fr_FR.UTF-8']

>>> list_common_locales(languageId='fr', territoryId='CA')
['fr_CA.UTF-8']

>>> list_common_locales(languageId='de', territoryId='FR')
['de_DE.UTF-8']

>>> list_common_locales(languageId='sr', scriptId='Latn')
['sr_RS.UTF-8@latin']

>>> list_common_locales(languageId='sr', scriptId='Cyrl')
['sr_RS.UTF-8']

>>> list_common_locales(languageId='zh', scriptId='Hans')
['zh_CN.UTF-8']

>>> list_common_locales(languageId='zh', scriptId='Hant')
['zh_TW.UTF-8']

>>> list_common_locales(languageId='zh', territoryId='TW')
['zh_TW.UTF-8']
c                 s    V ^,          ) # r   r   r   rh   r   r   Z%list_common_locales.<locals>.<lambda>&	  s
    !A$r   r   r  rM   rN   rJ   r   )r1  rz   r
   r   r   _LOCALE_RANK_THRESHOLDr6  r  rZ   r8  rX   rI   r.  r   )rM   rN   rJ   Zhigh_ranked_localesrZ   r
   rY   rL   Zselected_localesr9  r/  s   &&&        r   list_common_localesr<    s=   ^ h{-/H#H-55G#)'--/.?$A C$A ,86 $(+A#A !'$A   C  #**+;< 0 #"F(kF |V__56}}}z6==12}f&6&678!+F+N"">!#45- Cs   E%2E%c                s   / pRp\        VVVR7      pVP                  pVP                  pVP                  pV'       dY   V'       dQ   V'       dI   VR,           V,           R,           V,           \        9   d"   VR,           V,           R,           V,           pRpMuV'       d3   V'       d+   VR,           V,           \        9   d   VR,           V,           pM;V'       d4   V'       d,   VR,           V,           \        9   d   VR,           V,           pRp^dpV\        9   d   \        V,          P
                   F  p	\        V,          P
                  V	,          ^ 8w  g   K(  W9  d"   \        V,          P
                  V	,          WY&   MHWY;;,          \        V,          P
                  V	,          ,          uu&   WY;;,          \        ,          uu&   WY;;,          V,          uu&   K  	  ^p
V\        9   d   V'       g   \        V,          P
                   F  p	\        V,          P
                  V	,          ^ 8w  g   K(  W9  d"   \        V,          P
                  V	,          WY&   MHWY;;,          \        V,          P
                  V	,          ,          uu&   WY;;,          \        ,          uu&   WY;;,          V
,          uu&   K  	  \        V4      pV '       d   \        V4      pV'       d   V# \        V4      # )a  List likely Linux Console fonts

:param concise: if True, return only to highly ranked results
:type concise: boolean
:param show_weights: Also return the weights used in the ranking
:type show_weights: boolean
:param languageId: identifier for the language
:type languageId: string
:param scriptId: identifier for the script
:type scriptId: string
:param territoryId: identifier for the territory
:type territoryId: string
:rtype: a list of strings

**Examples:**

Listing likely console fonts  for English:

>>> list_consolefonts(languageId="en")
['eurlatgr']

Listing likely console fonts for Greek:

>>> list_consolefonts(languageId="el")
['eurlatgr', 'iso07u-16', 'LatGrkCyr-8x16']

Listing likely console fonts for Greece:

>>> list_consolefonts(territoryId="GR")
['eurlatgr', 'iso07u-16', 'LatGrkCyr-8x16']

Listing likely console fonts for Greek in Greece:

list_consolefonts(languageId="el", territoryId="GR")
['eurlatgr']

Listing likely console fonts for Greek in a non-Greek country like
the UK (the language has higher weight):

>>> list_consolefonts(languageId="el", territoryId="GB")
['eurlatgr']

Listing likely console fonts for Russian in Russia:

>>> list_consolefonts(languageId="ru", territoryId="RU")
['latarcyrheb-sun16']

Listing likely console fonts for Russian in a non-Russian country like
the UK (the language has higher weight):

>>> list_consolefonts(languageId="ru", territoryId="GB")
['latarcyrheb-sun16', 'eurlatgr']

Fr  r  T)r  rZ   rX   rI   rz   r   r(  r_   r   r   r   )r)  r*  rM   rN   rJ   Zranked_consolefontsr+  rY   r,  r]   r-  r   r2  r   list_consolefontsr=  <	  s*   n M(J2:5@BF J}}H""Kh;:c>(3J33N{3Z^k3k^H,S0<
	Z^H%<%M^H,
	
3{(Bm(S^K/
N]"(4AAKZ(55kBaG97DZ7P7]7]^i7j'4'4j8Q8^8^_j8kk4'4C4#0NB0 B Oo%m*;7DDK{+88EJ97F{7S7`7`al7m'4'48T8a8abm8nn4'4C4#0OC0 E --@AK/<,,r   c                s   / pRp\        VVVR7      pVP                  pVP                  pVP                  pV'       dY   V'       dQ   V'       dI   VR,           V,           R,           V,           \        9   d"   VR,           V,           R,           V,           pRpMuV'       d3   V'       d+   VR,           V,           \        9   d   VR,           V,           pM;V'       d4   V'       d,   VR,           V,           \        9   d   VR,           V,           pRp^pV\        9   d   \        V,          P
                   F  p	\        V,          P
                  V	,          ^ 8w  g   K(  W9  d"   \        V,          P
                  V	,          WY&   MHWY;;,          \        V,          P
                  V	,          ,          uu&   WY;;,          \        ,          uu&   WY;;,          V,          uu&   K  	  ^dp
V\        9   d   V'       g   \        V,          P
                   F  p	\        V,          P
                  V	,          ^ 8w  g   K(  W9  d"   \        V,          P
                  V	,          WY&   MHWY;;,          \        V,          P
                  V	,          ,          uu&   WY;;,          \        ,          uu&   WY;;,          V
,          uu&   K  	  \        V4      pV '       d   \        V4      pV'       d   V# \        V4      # )a  List likely timezones

:param concise: if True, return only to highly ranked results
:type concise: boolean
:param show_weights: Also return the weights used in the ranking
:type show_weights: boolean
:param languageId: identifier for the language
:type languageId: string
:param scriptId: identifier for the script
:type scriptId: string
:param territoryId: identifier for the territory
:type territoryId: string
:rtype: a list of strings

**Examples:**

>>> list_timezones(territoryId="DE")
['Europe/Berlin']

>>> list_timezones(languageId="de")
['Europe/Berlin', 'Europe/Vienna', 'Europe/Zurich', 'Europe/Brussels', 'Europe/Luxembourg']

>>> list_timezones(territoryId="CH")
['Europe/Zurich']

>>> list_timezones(languageId="fr", territoryId="CH")
['Europe/Zurich']

>>> list_timezones(languageId="fr")
['Europe/Paris', 'America/Montreal', 'Europe/Brussels', 'Europe/Zurich', 'Europe/Luxembourg']

The territory gets more weight than the language:

>>> list_timezones(languageId="ja", territoryId="CH")
['Europe/Zurich', 'Asia/Tokyo']
Fr  r  T)r  rZ   rX   rI   rz   r   r(  r_   r   r   r   )r)  r*  rM   rN   rJ   Zranked_timezonesr+  rY   r,  r^   r-  r   r2  r   list_timezonesr>  	  s(   J M(J2:5@BF J}}H""Kh;:c>(3J33N{3Z^k3k^H,S0<
	Z^H%<%M^H,
	
3{(Bm(S^K/
N]"%j1;;HZ(228<A31>z1J1T1TU]1^$.$.-
2K2U2UV^2__.$.+=. *n<* < Oo%m'4>>H{+55h?1D31@1M1W1WX`1a$.$./+2N2X2XYa2bb.$.+=. *o=* ? --=>K/<,,r   c                :    V ^8  d   QhR\         \        ,          /#    returnr    r`   format   "r   __annotate__rG  	       ( (DI (r   c                 <    \        \        P                  4       4      # )z7
List all language ids langtable knows something about
)r   rz   keysr   r   r   list_all_languagesrK  	       -$$&''r   c                r?  r@  rC  rD  rF  r   rG  rG  	       	 	$s) 	r   c                    \        4       p \        P                  4        F   w  rV P                  VP                  4       K"  	  \
        P                  4        F   w  rV P                  VP                  4       K"  	  \        V 4      # )z@
List all (glibc style) locales langtable knows something about
)r7  rz   r   r8  r
   r_   r   )Zall_locales_keyr   r0  r   list_all_localesrP  	  d     %K%++-4<<( .'--/4<<( 0+r   c                r?  r@  rC  rD  rF  r   rG  rG  	  rH  r   c                 rI  )z4
List all keyboards langtable knows something about
)r   rq   rJ  r   r   r   list_all_keyboardsrR  	  rL  r   c                r?  r@  rC  rD  rF  r   rG  rG  
  s     * *d3i *r   c                 rI  )z8
List all territory ids langtable knows something about
)r   r_   rJ  r   r   r   list_all_territoriesrS  
  s     /&&())r   c                r?  r@  rC  rD  rF  r   rG  rG  
  s     
! 
!DI 
!r   c                 sd   \        4       p V P                  \        \        P	                  4       4      4       \
        P                  4        F   w  rV P                  VP                  4       K"  	  \        P                  4        F   w  rV P                  VP                  4       K"  	  \        V 4      # )z7
List all timezone ids langtable knows something about
)
r7  r8  r   r   rJ  rz   r   r   r_   r   )Zall_timezonesrO  r   r0  r   list_all_timezonesrT  
  s     EMm00234%++-T^^, .'--/T^^, 0-  r   c                r?  r@  rC  rD  rF  r   rG  rG  
  rM  r   c                 rN  )z5
List all script ids langtable knows something about
)r7  rz   r   r8  r	   r_   r   )Zall_scriptsrO  r   r0  r   list_all_scriptsrU  
  rQ  r   c                r?  r@  rC  rD  rF  r   rG  rG  "
       	$ 	$S	 	$r   c                 rN  )z8
List all input methods langtable knows something about
)r7  rz   r   r8  r   r_   r   )Zall_inputmethodsrO  r   r0  r   list_all_input_methodsrW  "
  j     u%++- 1 12 .'--/ 1 12 0"##r   c                r?  r@  rC  rD  rF  r   rG  rG  -
  rV  r   c                 rN  )z8
List all console fonts langtable knows something about
)r7  rz   r   r8  r   r_   r   )Zall_consolefontsrO  r   r0  r   list_all_console_fontsrY  -
  rX  r   c                sJ    V \         9   d   \         V ,          P                  # R# )a  Check whether a keyboard layout supports ASCII

:param keyboardId: identifier for the keyboard
:type keyboardId: string
:rtype: string

Returns True if the keyboard layout with that id can be used to
type ASCII, returns false if the keyboard layout can not be used
to type ASCII or if typing ASCII with that keyboard layout is
difficult.

**Examples:**

>>> supports_ascii("jp")
True
>>> supports_ascii("ru")
False
T)rq   r(   )rP   rh   r   supports_asciirZ  8
  s     & ]"Z(...r   c                 sN    ^ RI p V P                  R4      ^ ,          P                  # )z
Return version of langtable
N	langtable)pkg_resourcesrequireversion)r\  s    r   r^  r^  O
  s#    
   -a0888r   c                 s   ^ RI p V P                  R4      ^ ,          P                  pV P                  R4      ^ ,          P                  pV P                  R4      ^ ,          P                  p\        RV 24       \        RV 24       \        RV 24       \        R\        P                  P                  \        4       24       \        R\        R,           24       R# )	z!
Print some info about langtable
Nr[  zProject name: = zVersion: = zModule path: = zLoaded from: zData files read: r   )r\  r]  project_namer^  module_pathprintr   r   r   r   r   )r\  r_  r^  r`  s       r   r   r   W
  s    
  ((5a8EEL##K03;;G''4Q7CCK	\N
+,	Ky
!"	OK=
)*	M"''**845
67	e$567
89r   c                s    \         P                  V 4      pV'       d9   RVP                  R4      3RVP                  R4      3RVP                  R4      3.# . # )*
Internal test function, do not use this.
rZ   rX   rI   )r	  r   r
  )rO   r   s   & r   _test_cldr_locale_patternrc  f
  sf     !&&x0EU[[45%++hBW7X[fhmhshst  iA  [B  C  	CIr   c                sd   \        \        V4      R,           \        \        WR7      4      ,           R,           \        V4      ,           R,           \        \        WR7      4      ,           R,           R,           \        \        WW#R7      4      ,           R,           \        V4      ,           R,           \        \	        WR7      4      ,           R,           \        V4      ,           R,           \        \	        WR7      4      ,           R,           R,           \        \	        WW#R7      4      ,           4       R# )rb  z: )r*  rM   Z
)r*  rJ   z +: r*  rM   rN   rJ   N)ra  r`   Zreprr.  r4  rd  s   &&&&r   _test_language_territoryre  o
  s'    
#j/$
,MNO { !! ,OP	Q
   ,V^wxy  z?	  	  LOP
Q  { !! LQRS    LX`yz!{ r   c                s    V ^8  d   QhRR/# rA  rB  Nr   rD  rF  r   rG  rG  
  s     G G4 Gr   c                 sR   \         P                  pV '       d   \         P                  p\         P                  ! VR RVR7       \	        R\        4       4       \	        R\        4       4       \	        R\        4       4       \	        R\        4       4       \	        R\        4       4       R# )	r   z%(levelname)s: %(message)s)r   ZfilemoderE  Zlevelzterritories.xmlzlanguages.xmlzkeyboards.xmlztimezones.xmlztimezoneidparts.xmlN)
r   ZINFOZDEBUGZbasicConfigr   r<   rt   rk   r{   r   )ZdebugZlogfilenameZ	log_levelr   r   _initrg  
  sz    IMM	!$;')
  ";"=> 7 9: 7 9: 7 9:$&C&EFr   c                   sD   a  ] tR tRt o V 3R lR ltV 3R lR ltRtV tR# )__ModuleInitializeri
  c                   < V ^8  d   QhRR/# rf  r   rE  r      "r   rG   __ModuleInitializer.__annotate__
  s      $ r   c                s    \        4        R # r   )rg  rg   rh   r   r   Z__ModuleInitializer.__init__
  s    r   c                ri  rf  r   rj  rk  r   rG  rl  
  s       r   c                s    R # r   r   rg   rh   r   __del__Z__ModuleInitializer.__del__
  s    r   r   N)r   r   r   r   r   rm  r   r   r   r   r   rh  rh  
  s       r   rh  Z__main__z tests run. z passed and z failed.zAll tests passed.c                sx    V ^8  d   Qh/ ^ \         9   d&   \        \        \        \        ,          3,          ;R&   # )rA  r   )__conditional_annotations__r   r`   r    rD  rF  r   rG  rG     s0     ^ ^b 6 5tCcN 5c^r   r  z^(?P<language>[a-z]{2,3}(?=$|@|_[A-Z][a-z]{3}(?=$|@|_[A-Z0-9]{2,3}(?=$|@))|_[A-Z0-9]{2,3}(?=$|@)))(?:_(?P<script>[A-Z][a-z]{3})(?=$|@|_[A-Z0-9]{2,3}(?=$|@))){0,1}(?:_(?P<territory>[A-Z0-9]{2,3})(?=$|@)){0,1})T)i  )r  r  r  r  r  r  )r  r  r  )NNNNT)NNNNNNT)NN)NNNN)r  )TFNNN)NNNr   )FNNN)Fz	/dev/null)arn  r   Ztypingr    r   r   r   r   r   ZcollectionsZxml.parsers.expatr   Zxml.sax.handlerr   Z
namedtupler   r   r   r5  r;  r'  r	  r  r_   rz   rq   r   r   r   r   r%   r*   r0   r1   r<   rk   rt   r{   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r  r  r  r  r!  r"  rJ   rM   r(  r.  r1  r  r3  r4  r:  r<  r=  r>  rK  rP  rR  rS  rT  rU  rW  rY  rZ  r^  r   rc  re  rg  rh  Z__module_initr   ZdoctestZsysZtestmodZFAILEDZ	ATTEMPTEDra  ZexitrG  )rn  r   r   <module>ro     s   ^D   	 	     *			>
@  1"5 5 " #&    zz . Vv&	   
# 
## #' ' 
 0n 0<h 7 hTH5 HTD5 DL35 3j3$; 3jR#hU!n !D!*'*
,.9.2!+Fc%JBH*+X1f\+|]~.6p'R0d P-d1:_-BI-VJ-X<)|IV`-DN-`(	(*
!		$	$.9:.G$  $%z	G!//+VY	YK|I$6#7|F88
TU	
HHQK r   