5 <link rel="stylesheet" href="styles.css"> |
5 <link rel="stylesheet" href="styles.css"> |
6 </head> |
6 </head> |
7 <body> |
7 <body> |
8 <a NAME="top" ID="top"></a> |
8 <a NAME="top" ID="top"></a> |
9 <h1>eric7.Plugins.CheckerPlugins.CodeStyleChecker.PathLib.PathlibChecker</h1> |
9 <h1>eric7.Plugins.CheckerPlugins.CodeStyleChecker.PathLib.PathlibChecker</h1> |
10 |
|
11 <p> |
10 <p> |
12 Module implementing the checker for functions that can be replaced by use of |
11 Module implementing the checker for functions that can be replaced by use of |
13 the pathlib module. |
12 the pathlib module. |
14 </p> |
13 </p> |
|
14 |
15 <h3>Global Attributes</h3> |
15 <h3>Global Attributes</h3> |
16 |
16 <table> |
17 <table> |
17 <tr><td>None</td></tr> |
18 <tr><td>None</td></tr> |
18 </table> |
19 </table> |
19 |
20 <h3>Classes</h3> |
20 <h3>Classes</h3> |
21 |
21 <table> |
22 <table> |
|
23 |
|
24 <tr> |
22 <tr> |
25 <td><a href="#NameResolver">NameResolver</a></td> |
23 <td><a href="#NameResolver">NameResolver</a></td> |
26 <td>Class to resolve a Name or Attribute node.</td> |
24 <td>Class to resolve a Name or Attribute node.</td> |
27 </tr> |
25 </tr> |
28 <tr> |
26 <tr> |
32 <tr> |
30 <tr> |
33 <td><a href="#PathlibVisitor">PathlibVisitor</a></td> |
31 <td><a href="#PathlibVisitor">PathlibVisitor</a></td> |
34 <td>Class to traverse the AST node tree and check for potential issues.</td> |
32 <td>Class to traverse the AST node tree and check for potential issues.</td> |
35 </tr> |
33 </tr> |
36 </table> |
34 </table> |
|
35 |
37 <h3>Functions</h3> |
36 <h3>Functions</h3> |
38 |
37 <table> |
39 <table> |
38 <tr><td>None</td></tr> |
40 <tr><td>None</td></tr> |
39 </table> |
41 </table> |
40 |
42 <hr /> |
41 <hr /> |
43 <hr /> |
42 <hr /> |
44 <a NAME="NameResolver" ID="NameResolver"></a> |
43 <a NAME="NameResolver" ID="NameResolver"></a> |
45 <h2>NameResolver</h2> |
44 <h2>NameResolver</h2> |
46 |
|
47 <p> |
45 <p> |
48 Class to resolve a Name or Attribute node. |
46 Class to resolve a Name or Attribute node. |
49 </p> |
47 </p> |
|
48 |
50 <h3>Derived from</h3> |
49 <h3>Derived from</h3> |
51 ast.NodeVisitor |
50 ast.NodeVisitor |
52 <h3>Class Attributes</h3> |
51 <h3>Class Attributes</h3> |
53 |
52 <table> |
54 <table> |
53 <tr><td>None</td></tr> |
55 <tr><td>None</td></tr> |
54 </table> |
56 </table> |
55 |
57 <h3>Class Methods</h3> |
56 <h3>Class Methods</h3> |
58 |
57 <table> |
59 <table> |
58 <tr><td>None</td></tr> |
60 <tr><td>None</td></tr> |
59 </table> |
61 </table> |
60 |
62 <h3>Methods</h3> |
61 <h3>Methods</h3> |
63 |
62 <table> |
64 <table> |
|
65 |
|
66 <tr> |
63 <tr> |
67 <td><a href="#NameResolver.__init__">NameResolver</a></td> |
64 <td><a href="#NameResolver.__init__">NameResolver</a></td> |
68 <td>Constructor</td> |
65 <td>Constructor</td> |
69 </tr> |
66 </tr> |
70 <tr> |
67 <tr> |
78 <tr> |
75 <tr> |
79 <td><a href="#NameResolver.visit_Name">visit_Name</a></td> |
76 <td><a href="#NameResolver.visit_Name">visit_Name</a></td> |
80 <td>Public method to handle the Name AST node.</td> |
77 <td>Public method to handle the Name AST node.</td> |
81 </tr> |
78 </tr> |
82 </table> |
79 </table> |
|
80 |
83 <h3>Static Methods</h3> |
81 <h3>Static Methods</h3> |
84 |
82 <table> |
85 <table> |
83 <tr><td>None</td></tr> |
86 <tr><td>None</td></tr> |
84 </table> |
87 </table> |
85 |
88 |
86 |
89 <a NAME="NameResolver.__init__" ID="NameResolver.__init__"></a> |
87 <a NAME="NameResolver.__init__" ID="NameResolver.__init__"></a> |
90 <h4>NameResolver (Constructor)</h4> |
88 <h4>NameResolver (Constructor)</h4> |
91 <b>NameResolver</b>(<i>importAlias</i>) |
89 <b>NameResolver</b>(<i>importAlias</i>) |
92 |
|
93 <p> |
90 <p> |
94 Constructor |
91 Constructor |
95 </p> |
92 </p> |
|
93 |
96 <dl> |
94 <dl> |
97 |
95 |
98 <dt><i>importAlias</i> (dict)</dt> |
96 <dt><i>importAlias</i> (dict)</dt> |
99 <dd> |
97 <dd> |
100 reference to the import aliases dictionary |
98 reference to the import aliases dictionary |
101 </dd> |
99 </dd> |
102 </dl> |
100 </dl> |
103 <a NAME="NameResolver.name" ID="NameResolver.name"></a> |
101 <a NAME="NameResolver.name" ID="NameResolver.name"></a> |
104 <h4>NameResolver.name</h4> |
102 <h4>NameResolver.name</h4> |
105 <b>name</b>(<i></i>) |
103 <b>name</b>(<i></i>) |
106 |
|
107 <p> |
104 <p> |
108 Public method to resolve the name. |
105 Public method to resolve the name. |
109 </p> |
106 </p> |
|
107 |
110 <dl> |
108 <dl> |
111 <dt>Return:</dt> |
109 <dt>Return:</dt> |
112 <dd> |
110 <dd> |
113 resolved name |
111 resolved name |
114 </dd> |
112 </dd> |
120 </dd> |
118 </dd> |
121 </dl> |
119 </dl> |
122 <a NAME="NameResolver.visit_Attribute" ID="NameResolver.visit_Attribute"></a> |
120 <a NAME="NameResolver.visit_Attribute" ID="NameResolver.visit_Attribute"></a> |
123 <h4>NameResolver.visit_Attribute</h4> |
121 <h4>NameResolver.visit_Attribute</h4> |
124 <b>visit_Attribute</b>(<i>node</i>) |
122 <b>visit_Attribute</b>(<i>node</i>) |
125 |
|
126 <p> |
123 <p> |
127 Public method to handle the Attribute AST node. |
124 Public method to handle the Attribute AST node. |
128 </p> |
125 </p> |
|
126 |
129 <dl> |
127 <dl> |
130 |
128 |
131 <dt><i>node</i> (ast.Attribute)</dt> |
129 <dt><i>node</i> (ast.Attribute)</dt> |
132 <dd> |
130 <dd> |
133 reference to the Attribute AST node |
131 reference to the Attribute AST node |
134 </dd> |
132 </dd> |
135 </dl> |
133 </dl> |
136 <a NAME="NameResolver.visit_Name" ID="NameResolver.visit_Name"></a> |
134 <a NAME="NameResolver.visit_Name" ID="NameResolver.visit_Name"></a> |
137 <h4>NameResolver.visit_Name</h4> |
135 <h4>NameResolver.visit_Name</h4> |
138 <b>visit_Name</b>(<i>node</i>) |
136 <b>visit_Name</b>(<i>node</i>) |
139 |
|
140 <p> |
137 <p> |
141 Public method to handle the Name AST node. |
138 Public method to handle the Name AST node. |
142 </p> |
139 </p> |
|
140 |
143 <dl> |
141 <dl> |
144 |
142 |
145 <dt><i>node</i> (ast.Name)</dt> |
143 <dt><i>node</i> (ast.Name)</dt> |
146 <dd> |
144 <dd> |
147 reference to the Name AST node |
145 reference to the Name AST node |
150 <div align="right"><a href="#top">Up</a></div> |
148 <div align="right"><a href="#top">Up</a></div> |
151 <hr /> |
149 <hr /> |
152 <hr /> |
150 <hr /> |
153 <a NAME="PathlibChecker" ID="PathlibChecker"></a> |
151 <a NAME="PathlibChecker" ID="PathlibChecker"></a> |
154 <h2>PathlibChecker</h2> |
152 <h2>PathlibChecker</h2> |
155 |
|
156 <p> |
153 <p> |
157 Class implementing a checker for functions that can be replaced by use of |
154 Class implementing a checker for functions that can be replaced by use of |
158 the pathlib module. |
155 the pathlib module. |
159 </p> |
156 </p> |
|
157 |
160 <h3>Derived from</h3> |
158 <h3>Derived from</h3> |
161 None |
159 None |
162 <h3>Class Attributes</h3> |
160 <h3>Class Attributes</h3> |
163 |
161 <table> |
164 <table> |
162 <tr><td>Codes</td></tr> |
165 <tr><td>Codes</td></tr><tr><td>Function2Code</td></tr> |
163 <tr><td>Function2Code</td></tr> |
166 </table> |
164 </table> |
|
165 |
167 <h3>Class Methods</h3> |
166 <h3>Class Methods</h3> |
168 |
167 <table> |
169 <table> |
168 <tr><td>None</td></tr> |
170 <tr><td>None</td></tr> |
169 </table> |
171 </table> |
170 |
172 <h3>Methods</h3> |
171 <h3>Methods</h3> |
173 |
172 <table> |
174 <table> |
|
175 |
|
176 <tr> |
173 <tr> |
177 <td><a href="#PathlibChecker.__init__">PathlibChecker</a></td> |
174 <td><a href="#PathlibChecker.__init__">PathlibChecker</a></td> |
178 <td>Constructor</td> |
175 <td>Constructor</td> |
179 </tr> |
176 </tr> |
180 <tr> |
177 <tr> |
192 <tr> |
189 <tr> |
193 <td><a href="#PathlibChecker.run">run</a></td> |
190 <td><a href="#PathlibChecker.run">run</a></td> |
194 <td>Public method to check the given source against functions to be replaced by 'pathlib' equivalents.</td> |
191 <td>Public method to check the given source against functions to be replaced by 'pathlib' equivalents.</td> |
195 </tr> |
192 </tr> |
196 </table> |
193 </table> |
|
194 |
197 <h3>Static Methods</h3> |
195 <h3>Static Methods</h3> |
198 |
196 <table> |
199 <table> |
197 <tr><td>None</td></tr> |
200 <tr><td>None</td></tr> |
198 </table> |
201 </table> |
199 |
202 |
200 |
203 <a NAME="PathlibChecker.__init__" ID="PathlibChecker.__init__"></a> |
201 <a NAME="PathlibChecker.__init__" ID="PathlibChecker.__init__"></a> |
204 <h4>PathlibChecker (Constructor)</h4> |
202 <h4>PathlibChecker (Constructor)</h4> |
205 <b>PathlibChecker</b>(<i>source, filename, tree, selected, ignored, expected, repeat</i>) |
203 <b>PathlibChecker</b>(<i>source, filename, tree, selected, ignored, expected, repeat</i>) |
206 |
|
207 <p> |
204 <p> |
208 Constructor |
205 Constructor |
209 </p> |
206 </p> |
|
207 |
210 <dl> |
208 <dl> |
211 |
209 |
212 <dt><i>source</i> (list of str)</dt> |
210 <dt><i>source</i> (list of str)</dt> |
213 <dd> |
211 <dd> |
214 source code to be checked |
212 source code to be checked |
239 </dd> |
237 </dd> |
240 </dl> |
238 </dl> |
241 <a NAME="PathlibChecker.__checkForReplacement" ID="PathlibChecker.__checkForReplacement"></a> |
239 <a NAME="PathlibChecker.__checkForReplacement" ID="PathlibChecker.__checkForReplacement"></a> |
242 <h4>PathlibChecker.__checkForReplacement</h4> |
240 <h4>PathlibChecker.__checkForReplacement</h4> |
243 <b>__checkForReplacement</b>(<i>node, name</i>) |
241 <b>__checkForReplacement</b>(<i>node, name</i>) |
244 |
|
245 <p> |
242 <p> |
246 Private method to check the given node for the need for a |
243 Private method to check the given node for the need for a |
247 replacement. |
244 replacement. |
248 </p> |
245 </p> |
|
246 |
249 <dl> |
247 <dl> |
250 |
248 |
251 <dt><i>node</i> (ast.AST)</dt> |
249 <dt><i>node</i> (ast.AST)</dt> |
252 <dd> |
250 <dd> |
253 reference to the AST node to check |
251 reference to the AST node to check |
258 </dd> |
256 </dd> |
259 </dl> |
257 </dl> |
260 <a NAME="PathlibChecker.__error" ID="PathlibChecker.__error"></a> |
258 <a NAME="PathlibChecker.__error" ID="PathlibChecker.__error"></a> |
261 <h4>PathlibChecker.__error</h4> |
259 <h4>PathlibChecker.__error</h4> |
262 <b>__error</b>(<i>lineNumber, offset, code, *args</i>) |
260 <b>__error</b>(<i>lineNumber, offset, code, *args</i>) |
263 |
|
264 <p> |
261 <p> |
265 Private method to record an issue. |
262 Private method to record an issue. |
266 </p> |
263 </p> |
|
264 |
267 <dl> |
265 <dl> |
268 |
266 |
269 <dt><i>lineNumber</i> (int)</dt> |
267 <dt><i>lineNumber</i> (int)</dt> |
270 <dd> |
268 <dd> |
271 line number of the issue |
269 line number of the issue |
284 </dd> |
282 </dd> |
285 </dl> |
283 </dl> |
286 <a NAME="PathlibChecker.__ignoreCode" ID="PathlibChecker.__ignoreCode"></a> |
284 <a NAME="PathlibChecker.__ignoreCode" ID="PathlibChecker.__ignoreCode"></a> |
287 <h4>PathlibChecker.__ignoreCode</h4> |
285 <h4>PathlibChecker.__ignoreCode</h4> |
288 <b>__ignoreCode</b>(<i>code</i>) |
286 <b>__ignoreCode</b>(<i>code</i>) |
289 |
|
290 <p> |
287 <p> |
291 Private method to check if the message code should be ignored. |
288 Private method to check if the message code should be ignored. |
292 </p> |
289 </p> |
|
290 |
293 <dl> |
291 <dl> |
294 |
292 |
295 <dt><i>code</i> (str)</dt> |
293 <dt><i>code</i> (str)</dt> |
296 <dd> |
294 <dd> |
297 message code to check for |
295 message code to check for |
310 </dd> |
308 </dd> |
311 </dl> |
309 </dl> |
312 <a NAME="PathlibChecker.run" ID="PathlibChecker.run"></a> |
310 <a NAME="PathlibChecker.run" ID="PathlibChecker.run"></a> |
313 <h4>PathlibChecker.run</h4> |
311 <h4>PathlibChecker.run</h4> |
314 <b>run</b>(<i></i>) |
312 <b>run</b>(<i></i>) |
315 |
|
316 <p> |
313 <p> |
317 Public method to check the given source against functions |
314 Public method to check the given source against functions |
318 to be replaced by 'pathlib' equivalents. |
315 to be replaced by 'pathlib' equivalents. |
319 </p> |
316 </p> |
|
317 |
320 <div align="right"><a href="#top">Up</a></div> |
318 <div align="right"><a href="#top">Up</a></div> |
321 <hr /> |
319 <hr /> |
322 <hr /> |
320 <hr /> |
323 <a NAME="PathlibVisitor" ID="PathlibVisitor"></a> |
321 <a NAME="PathlibVisitor" ID="PathlibVisitor"></a> |
324 <h2>PathlibVisitor</h2> |
322 <h2>PathlibVisitor</h2> |
325 |
|
326 <p> |
323 <p> |
327 Class to traverse the AST node tree and check for potential issues. |
324 Class to traverse the AST node tree and check for potential issues. |
328 </p> |
325 </p> |
|
326 |
329 <h3>Derived from</h3> |
327 <h3>Derived from</h3> |
330 ast.NodeVisitor |
328 ast.NodeVisitor |
331 <h3>Class Attributes</h3> |
329 <h3>Class Attributes</h3> |
332 |
330 <table> |
333 <table> |
331 <tr><td>None</td></tr> |
334 <tr><td>None</td></tr> |
332 </table> |
335 </table> |
333 |
336 <h3>Class Methods</h3> |
334 <h3>Class Methods</h3> |
337 |
335 <table> |
338 <table> |
336 <tr><td>None</td></tr> |
339 <tr><td>None</td></tr> |
337 </table> |
340 </table> |
338 |
341 <h3>Methods</h3> |
339 <h3>Methods</h3> |
342 |
340 <table> |
343 <table> |
|
344 |
|
345 <tr> |
341 <tr> |
346 <td><a href="#PathlibVisitor.__init__">PathlibVisitor</a></td> |
342 <td><a href="#PathlibVisitor.__init__">PathlibVisitor</a></td> |
347 <td>Constructor</td> |
343 <td>Constructor</td> |
348 </tr> |
344 </tr> |
349 <tr> |
345 <tr> |
357 <tr> |
353 <tr> |
358 <td><a href="#PathlibVisitor.visit_ImportFrom">visit_ImportFrom</a></td> |
354 <td><a href="#PathlibVisitor.visit_ImportFrom">visit_ImportFrom</a></td> |
359 <td>Public method handle the ImportFrom AST node.</td> |
355 <td>Public method handle the ImportFrom AST node.</td> |
360 </tr> |
356 </tr> |
361 </table> |
357 </table> |
|
358 |
362 <h3>Static Methods</h3> |
359 <h3>Static Methods</h3> |
363 |
360 <table> |
364 <table> |
361 <tr><td>None</td></tr> |
365 <tr><td>None</td></tr> |
362 </table> |
366 </table> |
363 |
367 |
364 |
368 <a NAME="PathlibVisitor.__init__" ID="PathlibVisitor.__init__"></a> |
365 <a NAME="PathlibVisitor.__init__" ID="PathlibVisitor.__init__"></a> |
369 <h4>PathlibVisitor (Constructor)</h4> |
366 <h4>PathlibVisitor (Constructor)</h4> |
370 <b>PathlibVisitor</b>(<i>checkCallback</i>) |
367 <b>PathlibVisitor</b>(<i>checkCallback</i>) |
371 |
|
372 <p> |
368 <p> |
373 Constructor |
369 Constructor |
374 </p> |
370 </p> |
|
371 |
375 <dl> |
372 <dl> |
376 |
373 |
377 <dt><i>checkCallback</i> (func)</dt> |
374 <dt><i>checkCallback</i> (func)</dt> |
378 <dd> |
375 <dd> |
379 callback function taking a reference to the |
376 callback function taking a reference to the |
381 </dd> |
378 </dd> |
382 </dl> |
379 </dl> |
383 <a NAME="PathlibVisitor.visit_Call" ID="PathlibVisitor.visit_Call"></a> |
380 <a NAME="PathlibVisitor.visit_Call" ID="PathlibVisitor.visit_Call"></a> |
384 <h4>PathlibVisitor.visit_Call</h4> |
381 <h4>PathlibVisitor.visit_Call</h4> |
385 <b>visit_Call</b>(<i>node</i>) |
382 <b>visit_Call</b>(<i>node</i>) |
386 |
|
387 <p> |
383 <p> |
388 Public method to handle the Call AST node. |
384 Public method to handle the Call AST node. |
389 </p> |
385 </p> |
|
386 |
390 <dl> |
387 <dl> |
391 |
388 |
392 <dt><i>node</i> (ast.Call)</dt> |
389 <dt><i>node</i> (ast.Call)</dt> |
393 <dd> |
390 <dd> |
394 reference to the Call AST node |
391 reference to the Call AST node |
395 </dd> |
392 </dd> |
396 </dl> |
393 </dl> |
397 <a NAME="PathlibVisitor.visit_Import" ID="PathlibVisitor.visit_Import"></a> |
394 <a NAME="PathlibVisitor.visit_Import" ID="PathlibVisitor.visit_Import"></a> |
398 <h4>PathlibVisitor.visit_Import</h4> |
395 <h4>PathlibVisitor.visit_Import</h4> |
399 <b>visit_Import</b>(<i>node</i>) |
396 <b>visit_Import</b>(<i>node</i>) |
400 |
|
401 <p> |
397 <p> |
402 Public method to handle the Import AST node. |
398 Public method to handle the Import AST node. |
403 </p> |
399 </p> |
|
400 |
404 <dl> |
401 <dl> |
405 |
402 |
406 <dt><i>node</i> (ast.Import)</dt> |
403 <dt><i>node</i> (ast.Import)</dt> |
407 <dd> |
404 <dd> |
408 reference to the Import AST node |
405 reference to the Import AST node |
409 </dd> |
406 </dd> |
410 </dl> |
407 </dl> |
411 <a NAME="PathlibVisitor.visit_ImportFrom" ID="PathlibVisitor.visit_ImportFrom"></a> |
408 <a NAME="PathlibVisitor.visit_ImportFrom" ID="PathlibVisitor.visit_ImportFrom"></a> |
412 <h4>PathlibVisitor.visit_ImportFrom</h4> |
409 <h4>PathlibVisitor.visit_ImportFrom</h4> |
413 <b>visit_ImportFrom</b>(<i>node</i>) |
410 <b>visit_ImportFrom</b>(<i>node</i>) |
414 |
|
415 <p> |
411 <p> |
416 Public method handle the ImportFrom AST node. |
412 Public method handle the ImportFrom AST node. |
417 </p> |
413 </p> |
|
414 |
418 <dl> |
415 <dl> |
419 |
416 |
420 <dt><i>node</i> (ast.ImportFrom)</dt> |
417 <dt><i>node</i> (ast.ImportFrom)</dt> |
421 <dd> |
418 <dd> |
422 reference to the ImportFrom AST node |
419 reference to the ImportFrom AST node |