eric6/Documentation/Source/eric6.Plugins.CheckerPlugins.CodeStyleChecker.PathLib.PathlibChecker.html

changeset 8166
bd5cd5858503
child 8199
f6db89b067e7
equal deleted inserted replaced
8165:61ca9619decb 8166:bd5cd5858503
1 <!DOCTYPE html>
2 <html><head>
3 <title>eric6.Plugins.CheckerPlugins.CodeStyleChecker.PathLib.PathlibChecker</title>
4 <meta charset="UTF-8">
5 <style>
6 body {
7 background: #EDECE6;
8 margin: 0em 1em 10em 1em;
9 color: black;
10 }
11
12 h1 { color: white; background: #85774A; }
13 h2 { color: white; background: #85774A; }
14 h3 { color: white; background: #9D936E; }
15 h4 { color: white; background: #9D936E; }
16
17 a { color: #BA6D36; }
18
19 </style>
20 </head>
21 <body>
22 <a NAME="top" ID="top"></a>
23 <h1>eric6.Plugins.CheckerPlugins.CodeStyleChecker.PathLib.PathlibChecker</h1>
24
25 <p>
26 Module implementing the checker for functions that can be replaced by use of
27 the pathlib module.
28 </p>
29 <h3>Global Attributes</h3>
30
31 <table>
32 <tr><td>None</td></tr>
33 </table>
34 <h3>Classes</h3>
35
36 <table>
37
38 <tr>
39 <td><a href="#NameResolver">NameResolver</a></td>
40 <td>Class to resolve a Name or Attribute node.</td>
41 </tr>
42 <tr>
43 <td><a href="#PathlibChecker">PathlibChecker</a></td>
44 <td>Class implementing a checker for functions that can be replaced by use of the pathlib module.</td>
45 </tr>
46 <tr>
47 <td><a href="#PathlibVisitor">PathlibVisitor</a></td>
48 <td>Class to traverse the AST node tree and check for potential issues.</td>
49 </tr>
50 </table>
51 <h3>Functions</h3>
52
53 <table>
54 <tr><td>None</td></tr>
55 </table>
56 <hr />
57 <hr />
58 <a NAME="NameResolver" ID="NameResolver"></a>
59 <h2>NameResolver</h2>
60
61 <p>
62 Class to resolve a Name or Attribute node.
63 </p>
64 <h3>Derived from</h3>
65 ast.NodeVisitor
66 <h3>Class Attributes</h3>
67
68 <table>
69 <tr><td>None</td></tr>
70 </table>
71 <h3>Class Methods</h3>
72
73 <table>
74 <tr><td>None</td></tr>
75 </table>
76 <h3>Methods</h3>
77
78 <table>
79
80 <tr>
81 <td><a href="#NameResolver.__init__">NameResolver</a></td>
82 <td>Constructor</td>
83 </tr>
84 <tr>
85 <td><a href="#NameResolver.name">name</a></td>
86 <td>Public method to resolve the name.</td>
87 </tr>
88 <tr>
89 <td><a href="#NameResolver.visit_Attribute">visit_Attribute</a></td>
90 <td>Public method to handle the Attribute AST node.</td>
91 </tr>
92 <tr>
93 <td><a href="#NameResolver.visit_Name">visit_Name</a></td>
94 <td>Public method to handle the Name AST node.</td>
95 </tr>
96 </table>
97 <h3>Static Methods</h3>
98
99 <table>
100 <tr><td>None</td></tr>
101 </table>
102
103 <a NAME="NameResolver.__init__" ID="NameResolver.__init__"></a>
104 <h4>NameResolver (Constructor)</h4>
105 <b>NameResolver</b>(<i>importAlias</i>)
106
107 <p>
108 Constructor
109 </p>
110 <dl>
111
112 <dt><i>importAlias</i> (dict)</dt>
113 <dd>
114 reference to the import aliases dictionary
115 </dd>
116 </dl>
117 <a NAME="NameResolver.name" ID="NameResolver.name"></a>
118 <h4>NameResolver.name</h4>
119 <b>name</b>(<i></i>)
120
121 <p>
122 Public method to resolve the name.
123 </p>
124 <dl>
125 <dt>Return:</dt>
126 <dd>
127 resolved name
128 </dd>
129 </dl>
130 <dl>
131 <dt>Return Type:</dt>
132 <dd>
133 str
134 </dd>
135 </dl>
136 <a NAME="NameResolver.visit_Attribute" ID="NameResolver.visit_Attribute"></a>
137 <h4>NameResolver.visit_Attribute</h4>
138 <b>visit_Attribute</b>(<i>node</i>)
139
140 <p>
141 Public method to handle the Attribute AST node.
142 </p>
143 <dl>
144
145 <dt><i>node</i> (ast.Attribute)</dt>
146 <dd>
147 reference to the Attribute AST node
148 </dd>
149 </dl>
150 <a NAME="NameResolver.visit_Name" ID="NameResolver.visit_Name"></a>
151 <h4>NameResolver.visit_Name</h4>
152 <b>visit_Name</b>(<i>node</i>)
153
154 <p>
155 Public method to handle the Name AST node.
156 </p>
157 <dl>
158
159 <dt><i>node</i> (ast.Name)</dt>
160 <dd>
161 reference to the Name AST node
162 </dd>
163 </dl>
164 <div align="right"><a href="#top">Up</a></div>
165 <hr />
166 <hr />
167 <a NAME="PathlibChecker" ID="PathlibChecker"></a>
168 <h2>PathlibChecker</h2>
169
170 <p>
171 Class implementing a checker for functions that can be replaced by use of
172 the pathlib module.
173 </p>
174 <h3>Derived from</h3>
175 object
176 <h3>Class Attributes</h3>
177
178 <table>
179 <tr><td>Codes</td></tr><tr><td>Function2Code</td></tr>
180 </table>
181 <h3>Class Methods</h3>
182
183 <table>
184 <tr><td>None</td></tr>
185 </table>
186 <h3>Methods</h3>
187
188 <table>
189
190 <tr>
191 <td><a href="#PathlibChecker.__init__">PathlibChecker</a></td>
192 <td>Constructor</td>
193 </tr>
194 <tr>
195 <td><a href="#PathlibChecker.__checkForReplacement">__checkForReplacement</a></td>
196 <td>Private method to check the given node for the need for a replacement.</td>
197 </tr>
198 <tr>
199 <td><a href="#PathlibChecker.__error">__error</a></td>
200 <td>Private method to record an issue.</td>
201 </tr>
202 <tr>
203 <td><a href="#PathlibChecker.__generateTree">__generateTree</a></td>
204 <td>Private method to generate an AST for our source.</td>
205 </tr>
206 <tr>
207 <td><a href="#PathlibChecker.__ignoreCode">__ignoreCode</a></td>
208 <td>Private method to check if the message code should be ignored.</td>
209 </tr>
210 <tr>
211 <td><a href="#PathlibChecker.__reportInvalidSyntax">__reportInvalidSyntax</a></td>
212 <td>Private method to report a syntax error.</td>
213 </tr>
214 <tr>
215 <td><a href="#PathlibChecker.run">run</a></td>
216 <td>Public method to check the given source against functions to be replaced by 'pathlib' equivalents.</td>
217 </tr>
218 </table>
219 <h3>Static Methods</h3>
220
221 <table>
222 <tr><td>None</td></tr>
223 </table>
224
225 <a NAME="PathlibChecker.__init__" ID="PathlibChecker.__init__"></a>
226 <h4>PathlibChecker (Constructor)</h4>
227 <b>PathlibChecker</b>(<i>source, filename, selected, ignored, expected, repeat</i>)
228
229 <p>
230 Constructor
231 </p>
232 <dl>
233
234 <dt><i>source</i> (list of str)</dt>
235 <dd>
236 source code to be checked
237 </dd>
238 <dt><i>filename</i> (str)</dt>
239 <dd>
240 name of the source file
241 </dd>
242 <dt><i>selected</i> (list of str)</dt>
243 <dd>
244 list of selected codes
245 </dd>
246 <dt><i>ignored</i> (list of str)</dt>
247 <dd>
248 list of codes to be ignored
249 </dd>
250 <dt><i>expected</i> (list of str)</dt>
251 <dd>
252 list of expected codes
253 </dd>
254 <dt><i>repeat</i> (bool)</dt>
255 <dd>
256 flag indicating to report each occurrence of a code
257 </dd>
258 </dl>
259 <a NAME="PathlibChecker.__checkForReplacement" ID="PathlibChecker.__checkForReplacement"></a>
260 <h4>PathlibChecker.__checkForReplacement</h4>
261 <b>__checkForReplacement</b>(<i>node, name</i>)
262
263 <p>
264 Private method to check the given node for the need for a
265 replacement.
266 </p>
267 <dl>
268
269 <dt><i>node</i> (ast.AST)</dt>
270 <dd>
271 reference to the AST node to check
272 </dd>
273 <dt><i>name</i> (str)</dt>
274 <dd>
275 resolved name of the node
276 </dd>
277 </dl>
278 <a NAME="PathlibChecker.__error" ID="PathlibChecker.__error"></a>
279 <h4>PathlibChecker.__error</h4>
280 <b>__error</b>(<i>lineNumber, offset, code, *args</i>)
281
282 <p>
283 Private method to record an issue.
284 </p>
285 <dl>
286
287 <dt><i>lineNumber</i> (int)</dt>
288 <dd>
289 line number of the issue
290 </dd>
291 <dt><i>offset</i> (int)</dt>
292 <dd>
293 position within line of the issue
294 </dd>
295 <dt><i>code</i> (str)</dt>
296 <dd>
297 message code
298 </dd>
299 <dt><i>args</i> (list)</dt>
300 <dd>
301 arguments for the message
302 </dd>
303 </dl>
304 <a NAME="PathlibChecker.__generateTree" ID="PathlibChecker.__generateTree"></a>
305 <h4>PathlibChecker.__generateTree</h4>
306 <b>__generateTree</b>(<i></i>)
307
308 <p>
309 Private method to generate an AST for our source.
310 </p>
311 <dl>
312 <dt>Return:</dt>
313 <dd>
314 generated AST
315 </dd>
316 </dl>
317 <dl>
318 <dt>Return Type:</dt>
319 <dd>
320 ast.AST
321 </dd>
322 </dl>
323 <a NAME="PathlibChecker.__ignoreCode" ID="PathlibChecker.__ignoreCode"></a>
324 <h4>PathlibChecker.__ignoreCode</h4>
325 <b>__ignoreCode</b>(<i>code</i>)
326
327 <p>
328 Private method to check if the message code should be ignored.
329 </p>
330 <dl>
331
332 <dt><i>code</i> (str)</dt>
333 <dd>
334 message code to check for
335 </dd>
336 </dl>
337 <dl>
338 <dt>Return:</dt>
339 <dd>
340 flag indicating to ignore the given code
341 </dd>
342 </dl>
343 <dl>
344 <dt>Return Type:</dt>
345 <dd>
346 bool
347 </dd>
348 </dl>
349 <a NAME="PathlibChecker.__reportInvalidSyntax" ID="PathlibChecker.__reportInvalidSyntax"></a>
350 <h4>PathlibChecker.__reportInvalidSyntax</h4>
351 <b>__reportInvalidSyntax</b>(<i></i>)
352
353 <p>
354 Private method to report a syntax error.
355 </p>
356 <a NAME="PathlibChecker.run" ID="PathlibChecker.run"></a>
357 <h4>PathlibChecker.run</h4>
358 <b>run</b>(<i></i>)
359
360 <p>
361 Public method to check the given source against functions
362 to be replaced by 'pathlib' equivalents.
363 </p>
364 <div align="right"><a href="#top">Up</a></div>
365 <hr />
366 <hr />
367 <a NAME="PathlibVisitor" ID="PathlibVisitor"></a>
368 <h2>PathlibVisitor</h2>
369
370 <p>
371 Class to traverse the AST node tree and check for potential issues.
372 </p>
373 <h3>Derived from</h3>
374 ast.NodeVisitor
375 <h3>Class Attributes</h3>
376
377 <table>
378 <tr><td>None</td></tr>
379 </table>
380 <h3>Class Methods</h3>
381
382 <table>
383 <tr><td>None</td></tr>
384 </table>
385 <h3>Methods</h3>
386
387 <table>
388
389 <tr>
390 <td><a href="#PathlibVisitor.__init__">PathlibVisitor</a></td>
391 <td>Constructor</td>
392 </tr>
393 <tr>
394 <td><a href="#PathlibVisitor.visit_Call">visit_Call</a></td>
395 <td>Public method to handle the Call AST node.</td>
396 </tr>
397 <tr>
398 <td><a href="#PathlibVisitor.visit_Import">visit_Import</a></td>
399 <td>Public method to handle the Import AST node.</td>
400 </tr>
401 <tr>
402 <td><a href="#PathlibVisitor.visit_ImportFrom">visit_ImportFrom</a></td>
403 <td>Public method handle the ImportFrom AST node.</td>
404 </tr>
405 </table>
406 <h3>Static Methods</h3>
407
408 <table>
409 <tr><td>None</td></tr>
410 </table>
411
412 <a NAME="PathlibVisitor.__init__" ID="PathlibVisitor.__init__"></a>
413 <h4>PathlibVisitor (Constructor)</h4>
414 <b>PathlibVisitor</b>(<i>checkCallback</i>)
415
416 <p>
417 Constructor
418 </p>
419 <dl>
420
421 <dt><i>checkCallback</i> (func)</dt>
422 <dd>
423 callback function taking a reference to the
424 AST node and the resolved name
425 </dd>
426 </dl>
427 <a NAME="PathlibVisitor.visit_Call" ID="PathlibVisitor.visit_Call"></a>
428 <h4>PathlibVisitor.visit_Call</h4>
429 <b>visit_Call</b>(<i>node</i>)
430
431 <p>
432 Public method to handle the Call AST node.
433 </p>
434 <dl>
435
436 <dt><i>node</i> (ast.Call)</dt>
437 <dd>
438 reference to the Call AST node
439 </dd>
440 </dl>
441 <a NAME="PathlibVisitor.visit_Import" ID="PathlibVisitor.visit_Import"></a>
442 <h4>PathlibVisitor.visit_Import</h4>
443 <b>visit_Import</b>(<i>node</i>)
444
445 <p>
446 Public method to handle the Import AST node.
447 </p>
448 <dl>
449
450 <dt><i>node</i> (ast.Import)</dt>
451 <dd>
452 reference to the Import AST node
453 </dd>
454 </dl>
455 <a NAME="PathlibVisitor.visit_ImportFrom" ID="PathlibVisitor.visit_ImportFrom"></a>
456 <h4>PathlibVisitor.visit_ImportFrom</h4>
457 <b>visit_ImportFrom</b>(<i>node</i>)
458
459 <p>
460 Public method handle the ImportFrom AST node.
461 </p>
462 <dl>
463
464 <dt><i>node</i> (ast.ImportFrom)</dt>
465 <dd>
466 reference to the ImportFrom AST node
467 </dd>
468 </dl>
469 <div align="right"><a href="#top">Up</a></div>
470 <hr />
471 </body></html>

eric ide

mercurial