
    Vhq                    j    d Z ddlmZ ddlZddlZddlZdZ	 dZ	  G d de	      Z
d	dZ e       \  ZZy)
zUInitialize locale settings. This must be imported very early in ansible-test startup.    )annotationsNzen_US.UTF-8zC.UTF-8c                  $     e Zd ZdZd fdZ xZS )LocaleErrorz4Exception to raise when locale related errors occur.c                *    t         |   d|        y )NzERROR: )super__init__)selfmessage	__class__s     R/home/dcms/DCMS/lib/python3.12/site-packages/ansible_test/_internal/locale_util.pyr   zLocaleError.__init__   s    77),-    )r
   strreturnNone)__name__
__module____qualname____doc__r   __classcell__)r   s   @r   r   r      s    >. .r   r   c                    t        j                         x} j                         dk7  rt        d|  d      t        t
        f}i }d}d}|D ]>  }	 t        j                  t        j                  |       t        j                          |} n |s2t        ddj                  d |j                         D              z         |t        k7  rd| d	t         d
}||fS # t        j                  t        f$ r}t        |      ||<   Y d}~d}~ww xY w)zLConfigure the locale, returning the selected locale and an optional warning.zutf-8z@ansible-test requires the filesystem encoding to be UTF-8, but "z" was detected.Nz6ansible-test could not initialize a supported locale:

c              3  0   K   | ]  \  }}| d |   yw)z: N ).0keyvalues      r   	<genexpr>z#configure_locale.<locals>.<genexpr>5   s     #W*#use2eW$5#Ws   zUsing locale "z" instead of "z<". Tests which depend on the locale may behave unexpectedly.)sysgetfilesystemencodinglowerr   STANDARD_LOCALEFALLBACK_LOCALElocale	setlocaleLC_ALL	getlocaleError
ValueErrorr   joinitems)fs_encodingcandidate_localeserrorswarningconfigured_localecandidate_localeexs          r   configure_localer2      s,    002299;wF\]h\iixyzz'8F#G)-- 	V]],<= !1 S))#W#WWX Y 	Y O+#$5#6n_DU VO O g%% j) 	/'*2wF#$	/s   8CD3DD)r   ztuple[str, t.Optional[str]])r   
__future__r   r#   r   typingtr!   r"   
SystemExitr   r2   CONFIGURED_LOCALELOCALE_WARNINGr   r   r   <module>r9      sL    [ "  
  .* .&B %5$6 ! >r   