|
1 <!DOCTYPE html> |
|
2 <html><head> |
|
3 <title>eric7.Plugins.CheckerPlugins.CodeStyleChecker.AstUtilities</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.AstUtilities</h1> |
|
10 |
|
11 <p> |
|
12 Module implementing some utility and compatibility functions for working with |
|
13 the ast module. |
|
14 </p> |
|
15 <h3>Global Attributes</h3> |
|
16 |
|
17 <table> |
|
18 <tr><td>None</td></tr> |
|
19 </table> |
|
20 <h3>Classes</h3> |
|
21 |
|
22 <table> |
|
23 <tr><td>None</td></tr> |
|
24 </table> |
|
25 <h3>Functions</h3> |
|
26 |
|
27 <table> |
|
28 |
|
29 <tr> |
|
30 <td><a href="#getValue">getValue</a></td> |
|
31 <td>Function to extract the value of a node.</td> |
|
32 </tr> |
|
33 <tr> |
|
34 <td><a href="#getValue_1">getValue</a></td> |
|
35 <td>Function to extract the value of a node.</td> |
|
36 </tr> |
|
37 <tr> |
|
38 <td><a href="#isBaseString">isBaseString</a></td> |
|
39 <td>Function to check that a node is a bytes or string.</td> |
|
40 </tr> |
|
41 <tr> |
|
42 <td><a href="#isBaseString_1">isBaseString</a></td> |
|
43 <td>Function to check that a node is a bytes or string.</td> |
|
44 </tr> |
|
45 <tr> |
|
46 <td><a href="#isBytes">isBytes</a></td> |
|
47 <td>Function to check that a node is a bytes.</td> |
|
48 </tr> |
|
49 <tr> |
|
50 <td><a href="#isBytes_1">isBytes</a></td> |
|
51 <td>Function to check that a node is a bytes.</td> |
|
52 </tr> |
|
53 <tr> |
|
54 <td><a href="#isNameConstant">isNameConstant</a></td> |
|
55 <td>Function to check that a node is a name constant.</td> |
|
56 </tr> |
|
57 <tr> |
|
58 <td><a href="#isNameConstant_1">isNameConstant</a></td> |
|
59 <td>Function to check that a node is a name constant.</td> |
|
60 </tr> |
|
61 <tr> |
|
62 <td><a href="#isNumber">isNumber</a></td> |
|
63 <td>Function to check that a node is a number.</td> |
|
64 </tr> |
|
65 <tr> |
|
66 <td><a href="#isNumber_1">isNumber</a></td> |
|
67 <td>Function to check that a node is a number.</td> |
|
68 </tr> |
|
69 <tr> |
|
70 <td><a href="#isString">isString</a></td> |
|
71 <td>Function to check that a node is a string.</td> |
|
72 </tr> |
|
73 <tr> |
|
74 <td><a href="#isString_1">isString</a></td> |
|
75 <td>Function to check that a node is a string.</td> |
|
76 </tr> |
|
77 </table> |
|
78 <hr /> |
|
79 <hr /> |
|
80 <a NAME="getValue" ID="getValue"></a> |
|
81 <h2>getValue</h2> |
|
82 <b>getValue</b>(<i>node</i>) |
|
83 |
|
84 <p> |
|
85 Function to extract the value of a node. |
|
86 </p> |
|
87 <dl> |
|
88 |
|
89 <dt><i>node</i> (ast.Constant)</dt> |
|
90 <dd> |
|
91 reference to the node to extract the value from |
|
92 </dd> |
|
93 </dl> |
|
94 <dl> |
|
95 <dt>Return:</dt> |
|
96 <dd> |
|
97 value of the node |
|
98 </dd> |
|
99 </dl> |
|
100 <dl> |
|
101 <dt>Return Type:</dt> |
|
102 <dd> |
|
103 any |
|
104 </dd> |
|
105 </dl> |
|
106 <dl> |
|
107 |
|
108 <dt>Raises <b>TypeError</b>:</dt> |
|
109 <dd> |
|
110 raised to indicate an unsupported type |
|
111 </dd> |
|
112 </dl> |
|
113 <div align="right"><a href="#top">Up</a></div> |
|
114 <hr /> |
|
115 <hr /> |
|
116 <a NAME="getValue_1" ID="getValue_1"></a> |
|
117 <h2>getValue</h2> |
|
118 <b>getValue</b>(<i>node</i>) |
|
119 |
|
120 <p> |
|
121 Function to extract the value of a node. |
|
122 </p> |
|
123 <dl> |
|
124 |
|
125 <dt><i>node</i> (one of ast.Num, ast.Str, ast.Bytes or ast.NameConstant)</dt> |
|
126 <dd> |
|
127 reference to the node to extract the value from |
|
128 </dd> |
|
129 </dl> |
|
130 <dl> |
|
131 <dt>Return:</dt> |
|
132 <dd> |
|
133 value of the node |
|
134 </dd> |
|
135 </dl> |
|
136 <dl> |
|
137 <dt>Return Type:</dt> |
|
138 <dd> |
|
139 one of str, bytes, int |
|
140 </dd> |
|
141 </dl> |
|
142 <dl> |
|
143 |
|
144 <dt>Raises <b>TypeError</b>:</dt> |
|
145 <dd> |
|
146 raised to indicate an unsupported type |
|
147 </dd> |
|
148 </dl> |
|
149 <div align="right"><a href="#top">Up</a></div> |
|
150 <hr /> |
|
151 <hr /> |
|
152 <a NAME="isBaseString" ID="isBaseString"></a> |
|
153 <h2>isBaseString</h2> |
|
154 <b>isBaseString</b>(<i>node</i>) |
|
155 |
|
156 <p> |
|
157 Function to check that a node is a bytes or string. |
|
158 </p> |
|
159 <dl> |
|
160 |
|
161 <dt><i>node</i> (ast.AST)</dt> |
|
162 <dd> |
|
163 reference to the node to check |
|
164 </dd> |
|
165 </dl> |
|
166 <dl> |
|
167 <dt>Return:</dt> |
|
168 <dd> |
|
169 flag indicating a bytes or string |
|
170 </dd> |
|
171 </dl> |
|
172 <dl> |
|
173 <dt>Return Type:</dt> |
|
174 <dd> |
|
175 bool |
|
176 </dd> |
|
177 </dl> |
|
178 <div align="right"><a href="#top">Up</a></div> |
|
179 <hr /> |
|
180 <hr /> |
|
181 <a NAME="isBaseString_1" ID="isBaseString_1"></a> |
|
182 <h2>isBaseString</h2> |
|
183 <b>isBaseString</b>(<i>node</i>) |
|
184 |
|
185 <p> |
|
186 Function to check that a node is a bytes or string. |
|
187 </p> |
|
188 <dl> |
|
189 |
|
190 <dt><i>node</i> (ast.AST)</dt> |
|
191 <dd> |
|
192 reference to the node to check |
|
193 </dd> |
|
194 </dl> |
|
195 <dl> |
|
196 <dt>Return:</dt> |
|
197 <dd> |
|
198 flag indicating a bytes or string |
|
199 </dd> |
|
200 </dl> |
|
201 <dl> |
|
202 <dt>Return Type:</dt> |
|
203 <dd> |
|
204 bool |
|
205 </dd> |
|
206 </dl> |
|
207 <div align="right"><a href="#top">Up</a></div> |
|
208 <hr /> |
|
209 <hr /> |
|
210 <a NAME="isBytes" ID="isBytes"></a> |
|
211 <h2>isBytes</h2> |
|
212 <b>isBytes</b>(<i>node</i>) |
|
213 |
|
214 <p> |
|
215 Function to check that a node is a bytes. |
|
216 </p> |
|
217 <dl> |
|
218 |
|
219 <dt><i>node</i> (ast.AST)</dt> |
|
220 <dd> |
|
221 reference to the node to check |
|
222 </dd> |
|
223 </dl> |
|
224 <dl> |
|
225 <dt>Return:</dt> |
|
226 <dd> |
|
227 flag indicating a bytes |
|
228 </dd> |
|
229 </dl> |
|
230 <dl> |
|
231 <dt>Return Type:</dt> |
|
232 <dd> |
|
233 bool |
|
234 </dd> |
|
235 </dl> |
|
236 <div align="right"><a href="#top">Up</a></div> |
|
237 <hr /> |
|
238 <hr /> |
|
239 <a NAME="isBytes_1" ID="isBytes_1"></a> |
|
240 <h2>isBytes</h2> |
|
241 <b>isBytes</b>(<i>node</i>) |
|
242 |
|
243 <p> |
|
244 Function to check that a node is a bytes. |
|
245 </p> |
|
246 <dl> |
|
247 |
|
248 <dt><i>node</i> (ast.AST)</dt> |
|
249 <dd> |
|
250 reference to the node to check |
|
251 </dd> |
|
252 </dl> |
|
253 <dl> |
|
254 <dt>Return:</dt> |
|
255 <dd> |
|
256 flag indicating a bytes |
|
257 </dd> |
|
258 </dl> |
|
259 <dl> |
|
260 <dt>Return Type:</dt> |
|
261 <dd> |
|
262 bool |
|
263 </dd> |
|
264 </dl> |
|
265 <div align="right"><a href="#top">Up</a></div> |
|
266 <hr /> |
|
267 <hr /> |
|
268 <a NAME="isNameConstant" ID="isNameConstant"></a> |
|
269 <h2>isNameConstant</h2> |
|
270 <b>isNameConstant</b>(<i>node</i>) |
|
271 |
|
272 <p> |
|
273 Function to check that a node is a name constant. |
|
274 </p> |
|
275 <dl> |
|
276 |
|
277 <dt><i>node</i> (ast.AST)</dt> |
|
278 <dd> |
|
279 reference to the node to check |
|
280 </dd> |
|
281 </dl> |
|
282 <dl> |
|
283 <dt>Return:</dt> |
|
284 <dd> |
|
285 flag indicating a name constant |
|
286 </dd> |
|
287 </dl> |
|
288 <dl> |
|
289 <dt>Return Type:</dt> |
|
290 <dd> |
|
291 bool |
|
292 </dd> |
|
293 </dl> |
|
294 <div align="right"><a href="#top">Up</a></div> |
|
295 <hr /> |
|
296 <hr /> |
|
297 <a NAME="isNameConstant_1" ID="isNameConstant_1"></a> |
|
298 <h2>isNameConstant</h2> |
|
299 <b>isNameConstant</b>(<i>node</i>) |
|
300 |
|
301 <p> |
|
302 Function to check that a node is a name constant. |
|
303 </p> |
|
304 <dl> |
|
305 |
|
306 <dt><i>node</i> (ast.AST)</dt> |
|
307 <dd> |
|
308 reference to the node to check |
|
309 </dd> |
|
310 </dl> |
|
311 <dl> |
|
312 <dt>Return:</dt> |
|
313 <dd> |
|
314 flag indicating a name constant |
|
315 </dd> |
|
316 </dl> |
|
317 <dl> |
|
318 <dt>Return Type:</dt> |
|
319 <dd> |
|
320 bool |
|
321 </dd> |
|
322 </dl> |
|
323 <div align="right"><a href="#top">Up</a></div> |
|
324 <hr /> |
|
325 <hr /> |
|
326 <a NAME="isNumber" ID="isNumber"></a> |
|
327 <h2>isNumber</h2> |
|
328 <b>isNumber</b>(<i>node</i>) |
|
329 |
|
330 <p> |
|
331 Function to check that a node is a number. |
|
332 </p> |
|
333 <dl> |
|
334 |
|
335 <dt><i>node</i> (ast.AST)</dt> |
|
336 <dd> |
|
337 reference to the node to check |
|
338 </dd> |
|
339 </dl> |
|
340 <dl> |
|
341 <dt>Return:</dt> |
|
342 <dd> |
|
343 flag indicating a number |
|
344 </dd> |
|
345 </dl> |
|
346 <dl> |
|
347 <dt>Return Type:</dt> |
|
348 <dd> |
|
349 bool |
|
350 </dd> |
|
351 </dl> |
|
352 <div align="right"><a href="#top">Up</a></div> |
|
353 <hr /> |
|
354 <hr /> |
|
355 <a NAME="isNumber_1" ID="isNumber_1"></a> |
|
356 <h2>isNumber</h2> |
|
357 <b>isNumber</b>(<i>node</i>) |
|
358 |
|
359 <p> |
|
360 Function to check that a node is a number. |
|
361 </p> |
|
362 <dl> |
|
363 |
|
364 <dt><i>node</i> (ast.AST)</dt> |
|
365 <dd> |
|
366 reference to the node to check |
|
367 </dd> |
|
368 </dl> |
|
369 <dl> |
|
370 <dt>Return:</dt> |
|
371 <dd> |
|
372 flag indicating a number |
|
373 </dd> |
|
374 </dl> |
|
375 <dl> |
|
376 <dt>Return Type:</dt> |
|
377 <dd> |
|
378 bool |
|
379 </dd> |
|
380 </dl> |
|
381 <div align="right"><a href="#top">Up</a></div> |
|
382 <hr /> |
|
383 <hr /> |
|
384 <a NAME="isString" ID="isString"></a> |
|
385 <h2>isString</h2> |
|
386 <b>isString</b>(<i>node</i>) |
|
387 |
|
388 <p> |
|
389 Function to check that a node is a string. |
|
390 </p> |
|
391 <dl> |
|
392 |
|
393 <dt><i>node</i> (ast.AST)</dt> |
|
394 <dd> |
|
395 reference to the node to check |
|
396 </dd> |
|
397 </dl> |
|
398 <dl> |
|
399 <dt>Return:</dt> |
|
400 <dd> |
|
401 flag indicating a string |
|
402 </dd> |
|
403 </dl> |
|
404 <dl> |
|
405 <dt>Return Type:</dt> |
|
406 <dd> |
|
407 bool |
|
408 </dd> |
|
409 </dl> |
|
410 <div align="right"><a href="#top">Up</a></div> |
|
411 <hr /> |
|
412 <hr /> |
|
413 <a NAME="isString_1" ID="isString_1"></a> |
|
414 <h2>isString</h2> |
|
415 <b>isString</b>(<i>node</i>) |
|
416 |
|
417 <p> |
|
418 Function to check that a node is a string. |
|
419 </p> |
|
420 <dl> |
|
421 |
|
422 <dt><i>node</i> (ast.AST)</dt> |
|
423 <dd> |
|
424 reference to the node to check |
|
425 </dd> |
|
426 </dl> |
|
427 <dl> |
|
428 <dt>Return:</dt> |
|
429 <dd> |
|
430 flag indicating a string |
|
431 </dd> |
|
432 </dl> |
|
433 <dl> |
|
434 <dt>Return Type:</dt> |
|
435 <dd> |
|
436 bool |
|
437 </dd> |
|
438 </dl> |
|
439 <div align="right"><a href="#top">Up</a></div> |
|
440 <hr /> |
|
441 </body></html> |