zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
U
£ý°dÁ5ã@sÀUdZddlZddlZddlZddlZddlmZmZddl    m
Z
m Z m Z m Z mZmZddlmZmZddd    œZe eeed
ffed <eee efe ee
fd œd d„ZGdd„deƒZdS)z.Implements parser to parse MySQL option files.éN)Ú ConfigParserÚMissingSectionHeaderError)ÚAnyÚDictÚListÚOptionalÚTupleÚUnioné)Ú CNX_POOL_ARGSÚDEFAULT_CONFIGURATION)ZiniÚcnf)r )ÚntÚposix.ÚDEFAULT_EXTENSIONS)ÚconfigÚreturnc
 
KsÖd|krÒz.t|dtƒr(|dg|d<|d}|d=Wntk
rTddg}YnXt|dtƒrr|dg|d<tt|dƒdd}|d=|j|Ž}i}|D]¼}zœ|| ¡D]Š\}}zN|dkrÆd}|tkrÞ|d    krÞt|}||ksü||d
|d
kr|||<Wq°tk
r8|dkr4t    d |›d ƒd ‚Yq°Xq°Wqžtk
rXYqžYqžXqžd}    | ¡D]h\}}||krhz,||    kr”|d||<nt
|dƒ||<Wn&t t fk
rÌ|d||<YnXqh|S)z¦
    Read option files for connection parameters.
 
    Checks if connection arguments contain option file arguments, and then
    reads option files accordingly.
    Z option_filesÚ option_groupsÚclientZconnector_pythonF)Ú keep_dashesÚsocketZ unix_socketZfailoverr
zUnsupported argument 'ú'N)ÚpasswordÚpasswdr) Ú
isinstanceÚstrÚKeyErrorÚMySQLOptionsParserÚlistÚ get_groups_as_dict_with_priorityÚitemsr r ÚAttributeErrorÚevalÚ    NameErrorÚ SyntaxError)
rÚgroupsZ option_parserZconfig_from_fileZconfig_optionsÚgroupÚoptionÚvalueÚ_Z not_evaluate©r*úRd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\mysql/connector/optionfiles.pyÚread_option_files1sb
 
 
ÿ
ÿþ 
 
ÿþ 
 
r,c@sàeZdZdZdeeeeefeddœdd„Z    eedœdd    „Z
eedd
œd d „Z deeeefeeeed œdd„Z ee eefdœdd„Zee ee eeeefffdœdd„Zee ee eeffdœdd„ZdS)rz9This class implements methods to parse MySQL option filesNT)ÚfilesrrcCsrt d¡|_i|_tj|ddttj|_    ||_
|s>t dƒ‚t |t ƒrN|gn||_| t|jƒ¡| ¡|_dS)z·Initialize
 
        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)Ústrictzfiles argument should be givenN)ÚreÚcompileÚoptcreÚ _options_dictÚSafeConfigParserÚ__init__rÚosÚnameÚdefault_extensionrÚ
ValueErrorrrr-Ú_parse_optionsrÚget_groups_as_dictÚ    _sections)Úselfr-rr*r*r+r4rs ÿ zMySQLOptionsParser.__init__)Ú    optionstrrcCs|js| dd¡}| ¡S)z¢Converts option strings
 
        Converts option strings to lower case and replaces dashes(-) with
        underscores(_) if keep_dashes variable is set.
        ú-r))rÚreplaceÚlower)r<r=r*r*r+Ú optionxform“s zMySQLOptionsParser.optionxform)r-rc CsÀ|dd…}g}d}d}|D]f}z$|||dd…krJtd|›dƒ‚t|ddd    è}| ¡D]Æ}| d
¡râ| dd¡\}}    |     ¡}    t |    ¡D]L}
tj     |    |
¡}
|
|kr¼t| 
|
|¡ƒ‚tj  |
¡r’|
  |j ¡r’| |
¡q’qb| d ¡rb| dd¡\}} |  ¡} | |krt| 
| |¡ƒ‚| | ¡qb|d7}| |¡W5QRXWqtk
r‚} ztd |›d | ›ƒ| ‚W5d} ~ XYqXq| |¡} t|ƒt| ƒ}|r¼tdd     |¡›dƒ‚dS)aKParse 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.
        Nrz4Option file '{0}' being included again in file '{1}'r
zSame option file 'z&' occurring more than once in the listÚrúutf-8©Úencodingz !includedirú!includezFailed reading file 'z': zFile(s) z, z could not be read.)r8ÚopenÚ    readlinesÚ
startswithÚsplitÚstripr5ÚlistdirÚpathÚjoinÚformatÚisfileÚendswithr7ÚappendÚIOErrorÚreadÚset)r<r-Z initial_filesÚindexÚerr_msgÚfile_Zop_fileÚliner)Zdir_pathÚentryÚfilenameÚerrZ
read_filesZnot_read_filesr*r*r+r9sJ     
 
ÿ 
ÿ
 
 *
z!MySQLOptionsParser._parse_options)Ú    filenamesrErc
CsÂt|tƒr|g}g}t|ƒD]ž\}}z¾t ¡}tj|dd”}|D]ˆ}| ¡}| d¡r\qD|j     
|¡}    |j  
|¡s¼|    r¼|      ddd¡\}
} } |
rª| sª| sª|  |›d¡qÌ|  |›d¡qD|  |›d¡qDW5QRX| d    ¡Wntk
rüYqYnXzˆ| ||¡|j ¡D]b} z|j| Wn tk
rHi|j| <YnX|j|  ¡D]\}}||f|j| |<qXq| ¡|_Wn"tk
r¨| ||¡YnX| ¡| |¡q|S)
zåRead 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.
        rCrDrFr'Úvir(z=
Ú
r)rrÚ    enumerateÚioÚStringIOÚcodecsrGrKrIr1ÚmatchÚSECTCREr&ÚwriteÚseekrSÚ_readr;Úkeysr2rr Ú_dictrÚcloserR)r<r]rEÚread_okÚpriorityr[Úout_fileÚin_filerYZ    match_objÚoptnameÚ    delimiterÚoptvalr&r'r(r*r*r+rTÑsP
 
 
 ÿ
 
  zMySQLOptionsParser.read)Úargsrc    Gs”|st|j ¡ƒ}i}i}|D]p}zVdd„|j| ¡DƒD]8\}}||ks\|||dkr<|d||<|d||<q<Wqtk
rŒYqXq|S)aReturns 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
        cSs*g|]"\}}|dkr| d¡s||f‘qS)Ú__name__ú!©rI©Ú.0Úkeyr(r*r*r+Ú
<listcomp>s 
üþz1MySQLOptionsParser.get_groups.<locals>.<listcomp>r
r)Útupler2rir r)r<rsÚoptionsrmr&r'r(r*r*r+Ú
get_groupss     û zMySQLOptionsParser.get_groupsc    Gs^|st|j ¡ƒ}i}|D]>}z$tdd„|j| ¡Dƒƒ||<Wqtk
rVYqXq|S)a3Returns 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
        css,|]$\}}|dkr| d¡s||fVqdS)rtruNrvrwr*r*r+Ú    <genexpr>>s 
üþzFMySQLOptionsParser.get_groups_as_dict_with_priority.<locals>.<genexpr>©r{r2riÚdictr r©r<rsr|r&r*r*r+r(s ûz3MySQLOptionsParser.get_groups_as_dict_with_priorityc    Gs^|st|j ¡ƒ}i}|D]>}z$tdd„|j| ¡Dƒƒ||<Wqtk
rVYqXq|S)aoReturns 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
        css0|](\}}|dkr| d¡s||dfVqdS)rtrurNrvrwr*r*r+r~Zs 
üþz8MySQLOptionsParser.get_groups_as_dict.<locals>.<genexpr>rrr*r*r+r:Js
 ûz%MySQLOptionsParser.get_groups_as_dict)NT)N)rtÚ
__module__Ú __qualname__Ú__doc__rr    rrÚboolr4rAr9rTrr}rÚintrr:r*r*r*r+ros*ÿþ !
5ÿþ 7!þ "r)r„rcrar5r/Ú configparserrr3rÚtypingrrrrrr    Ú    constantsr r rrÚ__annotations__r,rr*r*r*r+Ú<module>s þ$>