
    *h7                         % S r SSKrSSKrSSKrSSKrSSKrSSKJrJ	r	  SSK
JrJrJrJrJrJr  SSKJrJr  SSS	.r\\\\S
4   4   \S'   S\\\\   4   S\\\4   4S jr " S S\5      rg)z.Implements parser to parse MySQL option files.    N)ConfigParserMissingSectionHeaderError)AnyDictListOptionalTupleUnion   )CNX_POOL_ARGSDEFAULT_CONFIGURATION)inicnf)r   )ntposix.DEFAULT_EXTENSIONSconfigreturnc                     SU ;   Ga   [        U S   [        5      (       a	  U S   /U S'   U S   nU S	 [        U S   [        5      (       a	  U S   /U S'   [        [	        U S   5      SS9nU S	 UR
                  " U6 n0 nU Hu  n X5   R                  5        H[  u  pgXu4-  n US:X  a  SnUR                  USUS	   5        U[        ;  a  US
:w  a	  [        U   nXd;  d  XF   S   US   ::  a  XtU'   M[  M]     Mw     UR                  5        Ho  u  piU	u  pxn
X`;  d  M  UR                  U
5      (       d  M)  UR                  X5      (       d  MA  US;   a  [        U5      X'   MV   [        R                  " U5      X'   Mq     SU ;   a  U R%                  S5      U S'   U $ ! [         a    SS/n GNvf = f! [         a    US:X  a  [        SU S35      Se GM;  f = f! [         a     GMc  f = f! [        [         ["        4 a    XpU'    M  f = f)z
Read option files for connection parameters.

Checks if connection arguments contain option file arguments, and then
reads option files accordingly.
option_filesoption_groupsclientconnector_pythonF)keep_dashessocketunix_socketr   failoverr   zUnsupported argument ''N)passwordpasswd)
isinstancestrKeyErrorMySQLOptionsParserlist get_groups_as_dict_with_priorityitemssetr   r   AttributeErrorhas_section
has_optionastliteral_eval
ValueError	TypeErrorSyntaxErrorpop)r   groupsoption_parserconfig_from_fileconfig_optionsgroupoptionvalue_valuessections              S/var/www/auris/envauris/lib/python3.13/site-packages/mysql/connector/optionfiles.pyread_option_filesr=   2   sg    	4&1377+1/+B*C'O,F' f^,c22&,^&<%=F>"*'(e
 >" ::FC 	 ;=E%5%<%B%B%DMFX%E(!X-%2F)--e]E!HM!66Z;O 5f =A #8-5a8E!HD5:62  E &E 2 -224NF &Eg$!--g66!,,W==33%(ZFN/),)9)9%)@ 5 v$*JJx$8F=!Mo  	4 23F	4> $ ( $66"0"8 B##'( 7(
   '	;? /).v/sZ   )F G AF,.GG&F)(F), GGGG
G#"G#&HHc            
          \ rS rSrSr SS\\\\   \4      S\	SS4S jjr
S\S\4S	 jrS\\   SS4S
 jr SS\\\\   4   S\\   S\\   4S jjrS\S\\\4   4S jrS\S\\\\\\\4   4   4   4S jrS\S\\\\\4   4   4S jrSrg)r$   y   z9This class implements methods to parse MySQL option filesNfilesr   r   c                    [         R                  " S5      U l        0 U l        [        R
                  " U SS9  [        [        R                     U l	        X l
        U(       d  [        S5      e[        U[        5      (       a  U/OUU l        U R                  [!        U R                  5      5        U R#                  5       U l        g)zInitialize

If defaults is True, default option files are read first

Raises ValueError if defaults is set to True but defaults files
cannot be found.
z>(?P<option>[^:=\s][^:=]*)\s*(?:(?P<vi>[:=])\s*(?P<value>.*))?$F)strictzfiles argument should be givenN)recompileoptcre_options_dictSafeConfigParser__init__r   osnamedefault_extensionr   r.   r!   r"   r@   _parse_optionsr%   get_groups_as_dict	_sections)selfr@   r   s      r<   rH   MySQLOptionsParser.__init__|   s     #%** #
 EG!!$u52DRWW2M!,=>>+5eS+A+Au
D,-484K4K4M    	optionstrc                 h    U R                   (       d  UR                  SS5      nUR                  5       $ )zConverts option strings

Converts option strings to lower case and replaces dashes(-) with
underscores(_) if keep_dashes variable is set.
-r9   )r   replacelower)rO   rR   s     r<   optionxformMySQLOptionsParser.optionxform   s,     !))#s3I  rQ   c           
         USS n/ nSnSnU GH  n XRUS-   S ;   a  [        SU S35      e[        USSS	9 nUR                  5        GHa  nUR                  S
5      (       a  UR	                  SS5      u  pU	R                  5       n	[        R                  " U	5       H  n
[        R                  R                  X5      n
X;   a  [        UR                  X5      5      e[        R                  R                  U
5      (       d  Mg  U
R                  U R                  5      (       d  M  UR                  U
5        M     M  UR                  S5      (       d  GM  UR	                  SS5      u  pUR                  5       nX;   a  [        UR                  X5      5      eUR                  U5        GMd     US-  nUR                  U5        SSS5        GM     U R!                  U5      n[#        U5      [#        U5      -
  nU(       a  [        SSR                  U5       S35      eg! , (       d  f       GM"  = f! [         a  n[        SU SU 35      UeSnAff = f)a  Parse options from files given as arguments.
 This method checks for !include or !inculdedir directives and if there
 is any, those files included by these directives are also parsed
 for options.

Raises ValueError if any of the included or file given in arguments
is not readable.
Nr   z4Option file '{0}' being included again in file '{1}'r   zSame option file 'z&' occurring more than once in the listrutf-8encodingz!includedir!includezFailed reading file 'z': zFile(s) z, z could not be read.)r.   open	readlines
startswithsplitstriprI   listdirpathjoinformatisfileendswithrK   appendIOErrorreadr(   )rO   r@   initial_filesindexerr_msgfile_op_fileliner9   dir_pathentryfilenameerr
read_filesnot_read_filess                  r<   rL   !MySQLOptionsParser._parse_options   s    aH"ES%!)+66$,UG 40 0  %w77 ' 1 1 3??=99*.**T1*=KA'/~~'7H)+H)=(*X(E#(>*4W^^E5Q*R$R#%77>>%#8#8U^^$($:$:>" >" %*LL$7 *> "__Z88*.**T1*=KA'/~~'7H'0&01P&Q Q!LL2% !4( QJELL'- 87 #B YYu%
Uc*o5x		.(A'BBUVWW 9 87.  S #8s3%!HIsRSsH   %H3CH H &+H A/H H3 
H0	*H30H33
I=II	filenamesr]   c                    [        U[        5      (       a  U/n/ n[        U5       GH  u  pE [        R                  " 5       n[
        R                  " USS9 nU H  nUR                  5       nUR                  S5      (       a  M+  U R                  R                  U5      n	U R                  R                  U5      (       d^  U	(       aW  U	R                  SSS5      u  pnU
(       a$  U(       d  U(       d  UR                  U S35        M  UR                  U S35        M  UR                  U S35        M     S	S	S	5        UR                  S
5         U R!                  Xe5        U R"                  R%                  5        HL  n U R&                  U     U R"                  U   R+                  5        H  u  pX4U R&                  U   U'   M     MN     U R-                  5       U l        UR1                  5         UR3                  U5        GM     U$ ! , (       d  f       N= f! [         a     GM  f = f! [(         a    0 U R&                  U'    Nf = f! [.         a    U R!                  Xe5         Nf = f)zRead and parse a filename or a list of filenames.

Overridden from ConfigParser and modified so as to allow options
which are not inside any section header

Return list of successfully read files.
r[   r\   r^   r7   vir8   z=

Nr   )r!   r"   	enumerateioStringIOcodecsr_   rc   ra   rE   matchSECTCREr6   writeseekrk   _readrN   keysrF   r#   r'   _dictr   closerj   )rO   rz   r]   read_okpriorityru   out_filein_filerr   	match_objoptname	delimiteroptvalr6   r7   r8   s                   r<   rl   MySQLOptionsParser.read   s
    i%%"I"+I"6H;;=[[G< '#zz|??:66$$(KK$5$5d$;	#||11$77I9B ($:6G  'vi ($s| < ($r{ ;$NNdV2;7! !( =$ a /

8.!^^002E7**51 *.)>)D)D)F=B<M**51&9 *G 3 "& NNNN8$O #7P K =<&   $ 746**517 - /

8./sa   *HCH6H.I
?H+AI

H	H
H('H(+II
II

I('I(argsc                    U(       d#  [        U R                  R                  5       5      n0 n0 nU H  n U R                  U   R                  5        VVs/ s H)  u  pVUS:w  d  M  UR	                  S5      (       a  M%  UU4PM+     snn H%  u  pvXr;  d  X7   US   ::  d  M  US   X7'   US   X''   M'     M     U$ s  snnf ! [
         a     M  f = f)zReturns options as a dictionary.

Returns options from all the groups specified as arguments, returns
the options from all groups if no argument provided. Options are
overridden when they are found in the next group.

Returns a dictionary
__name__!r   r   )tuplerF   r   r'   ra   r#   )rO   r   optionsr   r6   keyr8   r7   s           r<   
get_groupsMySQLOptionsParser.get_groups  s     ++0023D#%E '+&8&8&?&E&E&G&
 'H
j(
 251D 'H&MF ,0@E!H0L+08(*/(&   &  s5    B>B8%B8=B8B> B>8B>>
CCc                     U(       d#  [        U R                  R                  5       5      n0 nU H3  n [        S U R                  U   R	                  5        5       5      X#'   M5     U$ ! [
         a     MF  f = f)a  Returns options as dictionary of dictionaries.

Returns options from all the groups specified as arguments. For each
group the option are contained in a dictionary. The order in which
the groups are specified is unimportant. Also options are not
overridden in between the groups.

The value is a tuple with two elements, first being the actual value
and second is the priority of the value which is higher for a value
read from a higher priority file.

Returns an dictionary of dictionaries
c              3   n   #    U  H+  u  pUS :w  d  M  UR                  S5      (       a  M%  UU4v   M-     g7f)r   r   Nra   .0r   r8   s      r<   	<genexpr>FMySQLOptionsParser.get_groups_as_dict_with_priority.<locals>.<genexpr>H  sE      &
 'H
j(
 251D 'Hs   555r   rF   r   dictr'   r#   rO   r   r   r6   s       r<   r&   3MySQLOptionsParser.get_groups_as_dict_with_priority2  s~      ++0023DE
!% &
 '+&8&8&?&E&E&G& "       /A((
A65A6c                     U(       d#  [        U R                  R                  5       5      n0 nU H3  n [        S U R                  U   R	                  5        5       5      X#'   M5     U$ ! [
         a     MF  f = f)a?  Returns options as dictionary of dictionaries.

Returns options from all the groups specified as arguments. For each
group the option are contained in a dictionary. The order in which
the groups are specified is unimportant. Also options are not
overridden in between the groups.

Returns an dictionary of dictionaries
c              3   t   #    U  H.  u  pUS :w  d  M  UR                  S5      (       a  M%  UUS   4v   M0     g7f)r   r   r   Nr   r   s      r<   r   8MySQLOptionsParser.get_groups_as_dict.<locals>.<genexpr>d  sI      &
 'H
j(
 251Da 'Hs   888r   r   s       r<   rM   %MySQLOptionsParser.get_groups_as_dictT  s~     ++0023DE
!% &
 '+&8&8&?&E&E&G& "    r   )rF   rN   rK   r@   r   rE   )NT)N)r   
__module____qualname____firstlineno____doc__r   r
   r   r"   boolrH   rW   rL   rl   r   r   r	   intr&   rM   __static_attributes__ rQ   r<   r$   r$   y   s   C RVNeDIsN34NJNN	NB!S !S !2XDI 2X$ 2Xj KO5sDI~.5:B3-5	c5n S#X @  	c4U38_,--	. D S$sCx.5H0I rQ   r$   )r   r,   r   r   rI   rC   configparserr   rG   r   typingr   r   r   r   r	   r
   	constantsr   r   r   r"   __annotations__r=   r$   r   rQ   r<   <module>r      s   > 5 
  	 	 	 T : : ; 2 DeCHo-. Dc49n 5 D$sCx. DNv) vrQ   