eric7/Documentation/Source/eric7.DataViews.CodeMetrics.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.DataViews.CodeMetrics</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.DataViews.CodeMetrics</h1>
24
25 <p>
26 Module implementing a simple Python code metrics analyzer.
27 </p>
28 <dl>
29
30 <dt>Raises <b>ValueError</b>:</dt>
31 <dd>
32 the tokenize module is too old
33 </dd>
34 </dl>
35 <h3>Global Attributes</h3>
36
37 <table>
38 <tr><td>COMMENT</td></tr><tr><td>DEDENT</td></tr><tr><td>EMPTY</td></tr><tr><td>INDENT</td></tr><tr><td>KEYWORD</td></tr><tr><td>NEWLINE</td></tr><tr><td>spacer</td></tr>
39 </table>
40 <h3>Classes</h3>
41
42 <table>
43
44 <tr>
45 <td><a href="#Parser">Parser</a></td>
46 <td>Class used to parse the source code of a Python file.</td>
47 </tr>
48 <tr>
49 <td><a href="#SourceStat">SourceStat</a></td>
50 <td>Class used to calculate and store the source code statistics.</td>
51 </tr>
52 <tr>
53 <td><a href="#Token">Token</a></td>
54 <td>Class to store the token related infos.</td>
55 </tr>
56 </table>
57 <h3>Functions</h3>
58
59 <table>
60
61 <tr>
62 <td><a href="#analyze">analyze</a></td>
63 <td>Module function used analyze the source of a Python file.</td>
64 </tr>
65 <tr>
66 <td><a href="#summarize">summarize</a></td>
67 <td>Module function used to collect overall statistics.</td>
68 </tr>
69 </table>
70 <hr />
71 <hr />
72 <a NAME="Parser" ID="Parser"></a>
73 <h2>Parser</h2>
74
75 <p>
76 Class used to parse the source code of a Python file.
77 </p>
78 <h3>Derived from</h3>
79 None
80 <h3>Class Attributes</h3>
81
82 <table>
83 <tr><td>None</td></tr>
84 </table>
85 <h3>Class Methods</h3>
86
87 <table>
88 <tr><td>None</td></tr>
89 </table>
90 <h3>Methods</h3>
91
92 <table>
93
94 <tr>
95 <td><a href="#Parser.__addToken">__addToken</a></td>
96 <td>Private method used to add a token to our list of tokens.</td>
97 </tr>
98 <tr>
99 <td><a href="#Parser.parse">parse</a></td>
100 <td>Public method used to parse the source code.</td>
101 </tr>
102 </table>
103 <h3>Static Methods</h3>
104
105 <table>
106 <tr><td>None</td></tr>
107 </table>
108
109 <a NAME="Parser.__addToken" ID="Parser.__addToken"></a>
110 <h4>Parser.__addToken</h4>
111 <b>__addToken</b>(<i>toktype, toktext, srow, scol, line</i>)
112
113 <p>
114 Private method used to add a token to our list of tokens.
115 </p>
116 <dl>
117
118 <dt><i>toktype</i></dt>
119 <dd>
120 the type of the token (int)
121 </dd>
122 <dt><i>toktext</i></dt>
123 <dd>
124 the text of the token (string)
125 </dd>
126 <dt><i>srow</i></dt>
127 <dd>
128 starting row of the token (int)
129 </dd>
130 <dt><i>scol</i></dt>
131 <dd>
132 starting column of the token (int)
133 </dd>
134 <dt><i>line</i></dt>
135 <dd>
136 logical line the token was found (string)
137 </dd>
138 </dl>
139 <a NAME="Parser.parse" ID="Parser.parse"></a>
140 <h4>Parser.parse</h4>
141 <b>parse</b>(<i>text</i>)
142
143 <p>
144 Public method used to parse the source code.
145 </p>
146 <dl>
147
148 <dt><i>text</i></dt>
149 <dd>
150 the source code as read from a Python source file
151 </dd>
152 </dl>
153 <div align="right"><a href="#top">Up</a></div>
154 <hr />
155 <hr />
156 <a NAME="SourceStat" ID="SourceStat"></a>
157 <h2>SourceStat</h2>
158
159 <p>
160 Class used to calculate and store the source code statistics.
161 </p>
162 <h3>Derived from</h3>
163 None
164 <h3>Class Attributes</h3>
165
166 <table>
167 <tr><td>None</td></tr>
168 </table>
169 <h3>Class Methods</h3>
170
171 <table>
172 <tr><td>None</td></tr>
173 </table>
174 <h3>Methods</h3>
175
176 <table>
177
178 <tr>
179 <td><a href="#SourceStat.__init__">SourceStat</a></td>
180 <td>Constructor</td>
181 </tr>
182 <tr>
183 <td><a href="#SourceStat.dedent">dedent</a></td>
184 <td>Public method used to decrement the indentation level.</td>
185 </tr>
186 <tr>
187 <td><a href="#SourceStat.getCounter">getCounter</a></td>
188 <td>Public method used to get a specific counter value.</td>
189 </tr>
190 <tr>
191 <td><a href="#SourceStat.inc">inc</a></td>
192 <td>Public method used to increment the value of a key.</td>
193 </tr>
194 <tr>
195 <td><a href="#SourceStat.indent">indent</a></td>
196 <td>Public method used to increment the indentation level.</td>
197 </tr>
198 <tr>
199 <td><a href="#SourceStat.push">push</a></td>
200 <td>Public method used to store an identifier.</td>
201 </tr>
202 </table>
203 <h3>Static Methods</h3>
204
205 <table>
206 <tr><td>None</td></tr>
207 </table>
208
209 <a NAME="SourceStat.__init__" ID="SourceStat.__init__"></a>
210 <h4>SourceStat (Constructor)</h4>
211 <b>SourceStat</b>(<i></i>)
212
213 <p>
214 Constructor
215 </p>
216 <a NAME="SourceStat.dedent" ID="SourceStat.dedent"></a>
217 <h4>SourceStat.dedent</h4>
218 <b>dedent</b>(<i>tok</i>)
219
220 <p>
221 Public method used to decrement the indentation level.
222 </p>
223 <dl>
224
225 <dt><i>tok</i></dt>
226 <dd>
227 the token to be processed (Token)
228 </dd>
229 </dl>
230 <dl>
231
232 <dt>Raises <b>ValueError</b>:</dt>
233 <dd>
234 raised to indicate an invalid indentation level
235 </dd>
236 </dl>
237 <a NAME="SourceStat.getCounter" ID="SourceStat.getCounter"></a>
238 <h4>SourceStat.getCounter</h4>
239 <b>getCounter</b>(<i>counterId, key</i>)
240
241 <p>
242 Public method used to get a specific counter value.
243 </p>
244 <dl>
245
246 <dt><i>counterId</i></dt>
247 <dd>
248 id of the counter (string)
249 </dd>
250 <dt><i>key</i></dt>
251 <dd>
252 key of the value to be retrieved (string)
253 </dd>
254 </dl>
255 <dl>
256 <dt>Return:</dt>
257 <dd>
258 the value of the requested counter (int)
259 </dd>
260 </dl>
261 <a NAME="SourceStat.inc" ID="SourceStat.inc"></a>
262 <h4>SourceStat.inc</h4>
263 <b>inc</b>(<i>key, value=1</i>)
264
265 <p>
266 Public method used to increment the value of a key.
267 </p>
268 <dl>
269
270 <dt><i>key</i></dt>
271 <dd>
272 the key to be incremented
273 </dd>
274 <dt><i>value</i></dt>
275 <dd>
276 the increment (int)
277 </dd>
278 </dl>
279 <a NAME="SourceStat.indent" ID="SourceStat.indent"></a>
280 <h4>SourceStat.indent</h4>
281 <b>indent</b>(<i>tok</i>)
282
283 <p>
284 Public method used to increment the indentation level.
285 </p>
286 <dl>
287
288 <dt><i>tok</i></dt>
289 <dd>
290 a token (Token, ignored)
291 </dd>
292 </dl>
293 <a NAME="SourceStat.push" ID="SourceStat.push"></a>
294 <h4>SourceStat.push</h4>
295 <b>push</b>(<i>identifier, row</i>)
296
297 <p>
298 Public method used to store an identifier.
299 </p>
300 <dl>
301
302 <dt><i>identifier</i></dt>
303 <dd>
304 the identifier to be remembered (string)
305 </dd>
306 <dt><i>row</i></dt>
307 <dd>
308 the row, the identifier is defined in (int)
309 </dd>
310 </dl>
311 <div align="right"><a href="#top">Up</a></div>
312 <hr />
313 <hr />
314 <a NAME="Token" ID="Token"></a>
315 <h2>Token</h2>
316
317 <p>
318 Class to store the token related infos.
319 </p>
320 <h3>Derived from</h3>
321 None
322 <h3>Class Attributes</h3>
323
324 <table>
325 <tr><td>None</td></tr>
326 </table>
327 <h3>Class Methods</h3>
328
329 <table>
330 <tr><td>None</td></tr>
331 </table>
332 <h3>Methods</h3>
333
334 <table>
335
336 <tr>
337 <td><a href="#Token.__init__">Token</a></td>
338 <td>Constructor</td>
339 </tr>
340 </table>
341 <h3>Static Methods</h3>
342
343 <table>
344 <tr><td>None</td></tr>
345 </table>
346
347 <a NAME="Token.__init__" ID="Token.__init__"></a>
348 <h4>Token (Constructor)</h4>
349 <b>Token</b>(<i>**kw</i>)
350
351 <p>
352 Constructor
353 </p>
354 <dl>
355
356 <dt><i>**kw=</i></dt>
357 <dd>
358 list of key, value pairs
359 </dd>
360 </dl>
361 <div align="right"><a href="#top">Up</a></div>
362 <hr />
363 <hr />
364 <a NAME="analyze" ID="analyze"></a>
365 <h2>analyze</h2>
366 <b>analyze</b>(<i>filename, total</i>)
367
368 <p>
369 Module function used analyze the source of a Python file.
370 </p>
371 <dl>
372
373 <dt><i>filename</i></dt>
374 <dd>
375 name of the Python file to be analyzed (string)
376 </dd>
377 <dt><i>total</i></dt>
378 <dd>
379 dictionary receiving the overall code statistics
380 </dd>
381 </dl>
382 <dl>
383 <dt>Return:</dt>
384 <dd>
385 a statistics object with the collected code statistics (SourceStat)
386 </dd>
387 </dl>
388 <div align="right"><a href="#top">Up</a></div>
389 <hr />
390 <hr />
391 <a NAME="summarize" ID="summarize"></a>
392 <h2>summarize</h2>
393 <b>summarize</b>(<i>total, key, value</i>)
394
395 <p>
396 Module function used to collect overall statistics.
397 </p>
398 <dl>
399
400 <dt><i>total</i></dt>
401 <dd>
402 the dictionary for the overall statistics
403 </dd>
404 <dt><i>key</i></dt>
405 <dd>
406 the key to be summarize
407 </dd>
408 <dt><i>value</i></dt>
409 <dd>
410 the value to be added to the overall statistics
411 </dd>
412 </dl>
413 <dl>
414 <dt>Return:</dt>
415 <dd>
416 the value added to the overall statistics
417 </dd>
418 </dl>
419 <div align="right"><a href="#top">Up</a></div>
420 <hr />
421 </body></html>

eric ide

mercurial