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