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

branch
eric7
changeset 8372
e0227a7c850e
child 8596
d64760b2da50
equal deleted inserted replaced
8371:d6062691d424 8372:e0227a7c850e
1 <!DOCTYPE html>
2 <html><head>
3 <title>eric7.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>eric7.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 None
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.__ignoreCode">__ignoreCode</a></td>
204 <td>Private method to check if the message code should be ignored.</td>
205 </tr>
206 <tr>
207 <td><a href="#PathlibChecker.run">run</a></td>
208 <td>Public method to check the given source against functions to be replaced by 'pathlib' equivalents.</td>
209 </tr>
210 </table>
211 <h3>Static Methods</h3>
212
213 <table>
214 <tr><td>None</td></tr>
215 </table>
216
217 <a NAME="PathlibChecker.__init__" ID="PathlibChecker.__init__"></a>
218 <h4>PathlibChecker (Constructor)</h4>
219 <b>PathlibChecker</b>(<i>source, filename, tree, selected, ignored, expected, repeat</i>)
220
221 <p>
222 Constructor
223 </p>
224 <dl>
225
226 <dt><i>source</i> (list of str)</dt>
227 <dd>
228 source code to be checked
229 </dd>
230 <dt><i>filename</i> (str)</dt>
231 <dd>
232 name of the source file
233 </dd>
234 <dt><i>tree</i> (ast.Module)</dt>
235 <dd>
236 AST tree of the source code
237 </dd>
238 <dt><i>selected</i> (list of str)</dt>
239 <dd>
240 list of selected codes
241 </dd>
242 <dt><i>ignored</i> (list of str)</dt>
243 <dd>
244 list of codes to be ignored
245 </dd>
246 <dt><i>expected</i> (list of str)</dt>
247 <dd>
248 list of expected codes
249 </dd>
250 <dt><i>repeat</i> (bool)</dt>
251 <dd>
252 flag indicating to report each occurrence of a code
253 </dd>
254 </dl>
255 <a NAME="PathlibChecker.__checkForReplacement" ID="PathlibChecker.__checkForReplacement"></a>
256 <h4>PathlibChecker.__checkForReplacement</h4>
257 <b>__checkForReplacement</b>(<i>node, name</i>)
258
259 <p>
260 Private method to check the given node for the need for a
261 replacement.
262 </p>
263 <dl>
264
265 <dt><i>node</i> (ast.AST)</dt>
266 <dd>
267 reference to the AST node to check
268 </dd>
269 <dt><i>name</i> (str)</dt>
270 <dd>
271 resolved name of the node
272 </dd>
273 </dl>
274 <a NAME="PathlibChecker.__error" ID="PathlibChecker.__error"></a>
275 <h4>PathlibChecker.__error</h4>
276 <b>__error</b>(<i>lineNumber, offset, code, *args</i>)
277
278 <p>
279 Private method to record an issue.
280 </p>
281 <dl>
282
283 <dt><i>lineNumber</i> (int)</dt>
284 <dd>
285 line number of the issue
286 </dd>
287 <dt><i>offset</i> (int)</dt>
288 <dd>
289 position within line of the issue
290 </dd>
291 <dt><i>code</i> (str)</dt>
292 <dd>
293 message code
294 </dd>
295 <dt><i>args</i> (list)</dt>
296 <dd>
297 arguments for the message
298 </dd>
299 </dl>
300 <a NAME="PathlibChecker.__ignoreCode" ID="PathlibChecker.__ignoreCode"></a>
301 <h4>PathlibChecker.__ignoreCode</h4>
302 <b>__ignoreCode</b>(<i>code</i>)
303
304 <p>
305 Private method to check if the message code should be ignored.
306 </p>
307 <dl>
308
309 <dt><i>code</i> (str)</dt>
310 <dd>
311 message code to check for
312 </dd>
313 </dl>
314 <dl>
315 <dt>Return:</dt>
316 <dd>
317 flag indicating to ignore the given code
318 </dd>
319 </dl>
320 <dl>
321 <dt>Return Type:</dt>
322 <dd>
323 bool
324 </dd>
325 </dl>
326 <a NAME="PathlibChecker.run" ID="PathlibChecker.run"></a>
327 <h4>PathlibChecker.run</h4>
328 <b>run</b>(<i></i>)
329
330 <p>
331 Public method to check the given source against functions
332 to be replaced by 'pathlib' equivalents.
333 </p>
334 <div align="right"><a href="#top">Up</a></div>
335 <hr />
336 <hr />
337 <a NAME="PathlibVisitor" ID="PathlibVisitor"></a>
338 <h2>PathlibVisitor</h2>
339
340 <p>
341 Class to traverse the AST node tree and check for potential issues.
342 </p>
343 <h3>Derived from</h3>
344 ast.NodeVisitor
345 <h3>Class Attributes</h3>
346
347 <table>
348 <tr><td>None</td></tr>
349 </table>
350 <h3>Class Methods</h3>
351
352 <table>
353 <tr><td>None</td></tr>
354 </table>
355 <h3>Methods</h3>
356
357 <table>
358
359 <tr>
360 <td><a href="#PathlibVisitor.__init__">PathlibVisitor</a></td>
361 <td>Constructor</td>
362 </tr>
363 <tr>
364 <td><a href="#PathlibVisitor.visit_Call">visit_Call</a></td>
365 <td>Public method to handle the Call AST node.</td>
366 </tr>
367 <tr>
368 <td><a href="#PathlibVisitor.visit_Import">visit_Import</a></td>
369 <td>Public method to handle the Import AST node.</td>
370 </tr>
371 <tr>
372 <td><a href="#PathlibVisitor.visit_ImportFrom">visit_ImportFrom</a></td>
373 <td>Public method handle the ImportFrom AST node.</td>
374 </tr>
375 </table>
376 <h3>Static Methods</h3>
377
378 <table>
379 <tr><td>None</td></tr>
380 </table>
381
382 <a NAME="PathlibVisitor.__init__" ID="PathlibVisitor.__init__"></a>
383 <h4>PathlibVisitor (Constructor)</h4>
384 <b>PathlibVisitor</b>(<i>checkCallback</i>)
385
386 <p>
387 Constructor
388 </p>
389 <dl>
390
391 <dt><i>checkCallback</i> (func)</dt>
392 <dd>
393 callback function taking a reference to the
394 AST node and the resolved name
395 </dd>
396 </dl>
397 <a NAME="PathlibVisitor.visit_Call" ID="PathlibVisitor.visit_Call"></a>
398 <h4>PathlibVisitor.visit_Call</h4>
399 <b>visit_Call</b>(<i>node</i>)
400
401 <p>
402 Public method to handle the Call AST node.
403 </p>
404 <dl>
405
406 <dt><i>node</i> (ast.Call)</dt>
407 <dd>
408 reference to the Call AST node
409 </dd>
410 </dl>
411 <a NAME="PathlibVisitor.visit_Import" ID="PathlibVisitor.visit_Import"></a>
412 <h4>PathlibVisitor.visit_Import</h4>
413 <b>visit_Import</b>(<i>node</i>)
414
415 <p>
416 Public method to handle the Import AST node.
417 </p>
418 <dl>
419
420 <dt><i>node</i> (ast.Import)</dt>
421 <dd>
422 reference to the Import AST node
423 </dd>
424 </dl>
425 <a NAME="PathlibVisitor.visit_ImportFrom" ID="PathlibVisitor.visit_ImportFrom"></a>
426 <h4>PathlibVisitor.visit_ImportFrom</h4>
427 <b>visit_ImportFrom</b>(<i>node</i>)
428
429 <p>
430 Public method handle the ImportFrom AST node.
431 </p>
432 <dl>
433
434 <dt><i>node</i> (ast.ImportFrom)</dt>
435 <dd>
436 reference to the ImportFrom AST node
437 </dd>
438 </dl>
439 <div align="right"><a href="#top">Up</a></div>
440 <hr />
441 </body></html>

eric ide

mercurial