|
1 <!DOCTYPE html> |
|
2 <html><head> |
|
3 <title>eric7.Plugins.CheckerPlugins.CodeStyleChecker.Logging.LoggingVisitor</title> |
|
4 <meta charset="UTF-8"> |
|
5 <link rel="stylesheet" href="styles.css"> |
|
6 </head> |
|
7 <body> |
|
8 <a NAME="top" ID="top"></a> |
|
9 <h1>eric7.Plugins.CheckerPlugins.CodeStyleChecker.Logging.LoggingVisitor</h1> |
|
10 |
|
11 <p> |
|
12 Module implementing a node visitor to check for logging issues. |
|
13 </p> |
|
14 <h3>Global Attributes</h3> |
|
15 |
|
16 <table> |
|
17 <tr><td>_LoggerMethods</td></tr><tr><td>_LogrecordAttributes</td></tr> |
|
18 </table> |
|
19 <h3>Classes</h3> |
|
20 |
|
21 <table> |
|
22 |
|
23 <tr> |
|
24 <td><a href="#LoggingVisitor">LoggingVisitor</a></td> |
|
25 <td>Class implementing a node visitor to check for logging issues.</td> |
|
26 </tr> |
|
27 </table> |
|
28 <h3>Functions</h3> |
|
29 |
|
30 <table> |
|
31 |
|
32 <tr> |
|
33 <td><a href="#_modnamedPlaceholderRe">_modnamedPlaceholderRe</a></td> |
|
34 <td>Function to generate a regular expression object for '%' formatting codes using names.</td> |
|
35 </tr> |
|
36 <tr> |
|
37 <td><a href="#_modposPlaceholderRe">_modposPlaceholderRe</a></td> |
|
38 <td>Function to generate a regular expression object for '%' formatting codes.</td> |
|
39 </tr> |
|
40 </table> |
|
41 <hr /> |
|
42 <hr /> |
|
43 <a NAME="LoggingVisitor" ID="LoggingVisitor"></a> |
|
44 <h2>LoggingVisitor</h2> |
|
45 |
|
46 <p> |
|
47 Class implementing a node visitor to check for logging issues. |
|
48 </p> |
|
49 <h3>Derived from</h3> |
|
50 ast.NodeVisitor |
|
51 <h3>Class Attributes</h3> |
|
52 |
|
53 <table> |
|
54 <tr><td>GetLoggerNames</td></tr> |
|
55 </table> |
|
56 <h3>Class Methods</h3> |
|
57 |
|
58 <table> |
|
59 <tr><td>None</td></tr> |
|
60 </table> |
|
61 <h3>Methods</h3> |
|
62 |
|
63 <table> |
|
64 |
|
65 <tr> |
|
66 <td><a href="#LoggingVisitor.__init__">LoggingVisitor</a></td> |
|
67 <td>Constructor</td> |
|
68 </tr> |
|
69 <tr> |
|
70 <td><a href="#LoggingVisitor.__atModuleLevel">__atModuleLevel</a></td> |
|
71 <td>Private method to check, if we are on the module level.</td> |
|
72 </tr> |
|
73 <tr> |
|
74 <td><a href="#LoggingVisitor.__checkMsgAndArgs">__checkMsgAndArgs</a></td> |
|
75 <td>Private method to check the message and arguments a given Call node.</td> |
|
76 </tr> |
|
77 <tr> |
|
78 <td><a href="#LoggingVisitor.__currentExceptHandler">__currentExceptHandler</a></td> |
|
79 <td>Private method to determine the current exception handler node.</td> |
|
80 </tr> |
|
81 <tr> |
|
82 <td><a href="#LoggingVisitor.__flattenStrChain">__flattenStrChain</a></td> |
|
83 <td>Private method to flatten the given string chain.</td> |
|
84 </tr> |
|
85 <tr> |
|
86 <td><a href="#LoggingVisitor.__isAddChainWithNonStr">__isAddChainWithNonStr</a></td> |
|
87 <td>Private method to check, if the node is an Add with a non string argument.</td> |
|
88 </tr> |
|
89 <tr> |
|
90 <td><a href="#LoggingVisitor.__keywordPos">__keywordPos</a></td> |
|
91 <td>Private method determine line number and column offset of a given keyword node.</td> |
|
92 </tr> |
|
93 <tr> |
|
94 <td><a href="#LoggingVisitor.visit">visit</a></td> |
|
95 <td></td> |
|
96 </tr> |
|
97 <tr> |
|
98 <td><a href="#LoggingVisitor.visit_Attribute">visit_Attribute</a></td> |
|
99 <td>Public method to handle Attribute nodes.</td> |
|
100 </tr> |
|
101 <tr> |
|
102 <td><a href="#LoggingVisitor.visit_Call">visit_Call</a></td> |
|
103 <td>Public method to handle Call nodes.</td> |
|
104 </tr> |
|
105 <tr> |
|
106 <td><a href="#LoggingVisitor.visit_Import">visit_Import</a></td> |
|
107 <td>Public method to handle Import nodes.</td> |
|
108 </tr> |
|
109 <tr> |
|
110 <td><a href="#LoggingVisitor.visit_ImportFrom">visit_ImportFrom</a></td> |
|
111 <td>Public method to handle ImportFrom nodes.</td> |
|
112 </tr> |
|
113 </table> |
|
114 <h3>Static Methods</h3> |
|
115 |
|
116 <table> |
|
117 <tr><td>None</td></tr> |
|
118 </table> |
|
119 |
|
120 <a NAME="LoggingVisitor.__init__" ID="LoggingVisitor.__init__"></a> |
|
121 <h4>LoggingVisitor (Constructor)</h4> |
|
122 <b>LoggingVisitor</b>(<i>errorCallback</i>) |
|
123 |
|
124 <p> |
|
125 Constructor |
|
126 </p> |
|
127 <dl> |
|
128 |
|
129 <dt><i>errorCallback</i> (func)</dt> |
|
130 <dd> |
|
131 callback function to register an error |
|
132 </dd> |
|
133 </dl> |
|
134 <a NAME="LoggingVisitor.__atModuleLevel" ID="LoggingVisitor.__atModuleLevel"></a> |
|
135 <h4>LoggingVisitor.__atModuleLevel</h4> |
|
136 <b>__atModuleLevel</b>(<i></i>) |
|
137 |
|
138 <p> |
|
139 Private method to check, if we are on the module level. |
|
140 </p> |
|
141 <dl> |
|
142 <dt>Return:</dt> |
|
143 <dd> |
|
144 flag indicating the module level |
|
145 </dd> |
|
146 </dl> |
|
147 <dl> |
|
148 <dt>Return Type:</dt> |
|
149 <dd> |
|
150 bool |
|
151 </dd> |
|
152 </dl> |
|
153 <a NAME="LoggingVisitor.__checkMsgAndArgs" ID="LoggingVisitor.__checkMsgAndArgs"></a> |
|
154 <h4>LoggingVisitor.__checkMsgAndArgs</h4> |
|
155 <b>__checkMsgAndArgs</b>(<i>node, msgArg, msg</i>) |
|
156 |
|
157 <p> |
|
158 Private method to check the message and arguments a given Call node. |
|
159 </p> |
|
160 <dl> |
|
161 |
|
162 <dt><i>node</i> (ast.Call)</dt> |
|
163 <dd> |
|
164 reference to the Call node |
|
165 </dd> |
|
166 <dt><i>msgArg</i> (ast.AST)</dt> |
|
167 <dd> |
|
168 message argument nodes |
|
169 </dd> |
|
170 <dt><i>msg</i> (str)</dt> |
|
171 <dd> |
|
172 message |
|
173 </dd> |
|
174 </dl> |
|
175 <a NAME="LoggingVisitor.__currentExceptHandler" ID="LoggingVisitor.__currentExceptHandler"></a> |
|
176 <h4>LoggingVisitor.__currentExceptHandler</h4> |
|
177 <b>__currentExceptHandler</b>(<i></i>) |
|
178 |
|
179 <p> |
|
180 Private method to determine the current exception handler node. |
|
181 </p> |
|
182 <dl> |
|
183 <dt>Return:</dt> |
|
184 <dd> |
|
185 reference to the current exception handler node or None |
|
186 </dd> |
|
187 </dl> |
|
188 <dl> |
|
189 <dt>Return Type:</dt> |
|
190 <dd> |
|
191 ast.ExceptHandler |
|
192 </dd> |
|
193 </dl> |
|
194 <a NAME="LoggingVisitor.__flattenStrChain" ID="LoggingVisitor.__flattenStrChain"></a> |
|
195 <h4>LoggingVisitor.__flattenStrChain</h4> |
|
196 <b>__flattenStrChain</b>(<i>node</i>) |
|
197 |
|
198 <p> |
|
199 Private method to flatten the given string chain. |
|
200 </p> |
|
201 <dl> |
|
202 |
|
203 <dt><i>node</i> (ast.AST)</dt> |
|
204 <dd> |
|
205 reference to the AST node |
|
206 </dd> |
|
207 </dl> |
|
208 <dl> |
|
209 <dt>Return:</dt> |
|
210 <dd> |
|
211 flattened string |
|
212 </dd> |
|
213 </dl> |
|
214 <dl> |
|
215 <dt>Return Type:</dt> |
|
216 <dd> |
|
217 str |
|
218 </dd> |
|
219 </dl> |
|
220 <a NAME="LoggingVisitor.__isAddChainWithNonStr" ID="LoggingVisitor.__isAddChainWithNonStr"></a> |
|
221 <h4>LoggingVisitor.__isAddChainWithNonStr</h4> |
|
222 <b>__isAddChainWithNonStr</b>(<i>node</i>) |
|
223 |
|
224 <p> |
|
225 Private method to check, if the node is an Add with a non string argument. |
|
226 </p> |
|
227 <dl> |
|
228 |
|
229 <dt><i>node</i> (ast.BinOp)</dt> |
|
230 <dd> |
|
231 reference to the binary operator node |
|
232 </dd> |
|
233 </dl> |
|
234 <dl> |
|
235 <dt>Return:</dt> |
|
236 <dd> |
|
237 flag indicating an Add with a non string argument |
|
238 </dd> |
|
239 </dl> |
|
240 <dl> |
|
241 <dt>Return Type:</dt> |
|
242 <dd> |
|
243 bool |
|
244 </dd> |
|
245 </dl> |
|
246 <a NAME="LoggingVisitor.__keywordPos" ID="LoggingVisitor.__keywordPos"></a> |
|
247 <h4>LoggingVisitor.__keywordPos</h4> |
|
248 <b>__keywordPos</b>(<i>node</i>) |
|
249 |
|
250 <p> |
|
251 Private method determine line number and column offset of a given keyword node. |
|
252 </p> |
|
253 <dl> |
|
254 |
|
255 <dt><i>node</i> (ast.keyword)</dt> |
|
256 <dd> |
|
257 reference to the keyword node |
|
258 </dd> |
|
259 </dl> |
|
260 <dl> |
|
261 <dt>Return:</dt> |
|
262 <dd> |
|
263 tuple containing the line number and the column offset |
|
264 </dd> |
|
265 </dl> |
|
266 <dl> |
|
267 <dt>Return Type:</dt> |
|
268 <dd> |
|
269 tuple of (int, int) |
|
270 </dd> |
|
271 </dl> |
|
272 <a NAME="LoggingVisitor.visit" ID="LoggingVisitor.visit"></a> |
|
273 <h4>LoggingVisitor.visit</h4> |
|
274 <b>visit</b>(<i></i>) |
|
275 |
|
276 <a NAME="LoggingVisitor.visit_Attribute" ID="LoggingVisitor.visit_Attribute"></a> |
|
277 <h4>LoggingVisitor.visit_Attribute</h4> |
|
278 <b>visit_Attribute</b>(<i>node</i>) |
|
279 |
|
280 <p> |
|
281 Public method to handle Attribute nodes. |
|
282 </p> |
|
283 <dl> |
|
284 |
|
285 <dt><i>node</i> (ast.Attribute)</dt> |
|
286 <dd> |
|
287 reference to the node to be processed |
|
288 </dd> |
|
289 </dl> |
|
290 <a NAME="LoggingVisitor.visit_Call" ID="LoggingVisitor.visit_Call"></a> |
|
291 <h4>LoggingVisitor.visit_Call</h4> |
|
292 <b>visit_Call</b>(<i>node</i>) |
|
293 |
|
294 <p> |
|
295 Public method to handle Call nodes. |
|
296 </p> |
|
297 <dl> |
|
298 |
|
299 <dt><i>node</i> (ast.Call)</dt> |
|
300 <dd> |
|
301 reference to the node to be processed |
|
302 </dd> |
|
303 </dl> |
|
304 <a NAME="LoggingVisitor.visit_Import" ID="LoggingVisitor.visit_Import"></a> |
|
305 <h4>LoggingVisitor.visit_Import</h4> |
|
306 <b>visit_Import</b>(<i>node</i>) |
|
307 |
|
308 <p> |
|
309 Public method to handle Import nodes. |
|
310 </p> |
|
311 <dl> |
|
312 |
|
313 <dt><i>node</i> (ast.Import)</dt> |
|
314 <dd> |
|
315 reference to the node to be processed |
|
316 </dd> |
|
317 </dl> |
|
318 <a NAME="LoggingVisitor.visit_ImportFrom" ID="LoggingVisitor.visit_ImportFrom"></a> |
|
319 <h4>LoggingVisitor.visit_ImportFrom</h4> |
|
320 <b>visit_ImportFrom</b>(<i>node</i>) |
|
321 |
|
322 <p> |
|
323 Public method to handle ImportFrom nodes. |
|
324 </p> |
|
325 <dl> |
|
326 |
|
327 <dt><i>node</i> (ast.ImportFrom)</dt> |
|
328 <dd> |
|
329 reference to the node to be processed |
|
330 </dd> |
|
331 </dl> |
|
332 <div align="right"><a href="#top">Up</a></div> |
|
333 <hr /> |
|
334 <hr /> |
|
335 <a NAME="_modnamedPlaceholderRe" ID="_modnamedPlaceholderRe"></a> |
|
336 <h2>_modnamedPlaceholderRe</h2> |
|
337 <b>_modnamedPlaceholderRe</b>(<i></i>) |
|
338 |
|
339 <p> |
|
340 Function to generate a regular expression object for '%' formatting codes using |
|
341 names. |
|
342 </p> |
|
343 <dl> |
|
344 <dt>Return:</dt> |
|
345 <dd> |
|
346 regular expression object |
|
347 </dd> |
|
348 </dl> |
|
349 <dl> |
|
350 <dt>Return Type:</dt> |
|
351 <dd> |
|
352 re.Pattern |
|
353 </dd> |
|
354 </dl> |
|
355 <div align="right"><a href="#top">Up</a></div> |
|
356 <hr /> |
|
357 <hr /> |
|
358 <a NAME="_modposPlaceholderRe" ID="_modposPlaceholderRe"></a> |
|
359 <h2>_modposPlaceholderRe</h2> |
|
360 <b>_modposPlaceholderRe</b>(<i></i>) |
|
361 |
|
362 <p> |
|
363 Function to generate a regular expression object for '%' formatting codes. |
|
364 </p> |
|
365 <dl> |
|
366 <dt>Return:</dt> |
|
367 <dd> |
|
368 regular expression object |
|
369 </dd> |
|
370 </dl> |
|
371 <dl> |
|
372 <dt>Return Type:</dt> |
|
373 <dd> |
|
374 re.Pattern |
|
375 </dd> |
|
376 </dl> |
|
377 <div align="right"><a href="#top">Up</a></div> |
|
378 <hr /> |
|
379 </body></html> |