RadonMetrics/Documentation/source/Plugin_Metrics_Radon.RadonMetrics.radon.raw.html

changeset 14
5f206edea27e
equal deleted inserted replaced
13:22bc345844e7 14:5f206edea27e
1 <!DOCTYPE html>
2 <html><head>
3 <title>Plugin_Metrics_Radon.RadonMetrics.radon.raw</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><a NAME="top" ID="top"></a>
22 <h1>Plugin_Metrics_Radon.RadonMetrics.radon.raw</h1>
23
24 <h3>Global Attributes</h3>
25 <table>
26 <tr><td>COMMENT</td></tr><tr><td>EM</td></tr><tr><td>Module</td></tr><tr><td>NL</td></tr><tr><td>OP</td></tr><tr><td>TOKEN_NUMBER</td></tr><tr><td>__all__</td></tr>
27 </table>
28 <h3>Classes</h3>
29 <table>
30 <tr><td>None</td></tr>
31 </table>
32 <h3>Functions</h3>
33 <table>
34 <tr>
35 <td><a href="#_find">_find</a></td>
36 <td>Return the position of the last token with the same (token, value) pair supplied.</td>
37 </tr><tr>
38 <td><a href="#_generate">_generate</a></td>
39 <td>Pass the code into `tokenize.generate_tokens` and convert the result into a list.</td>
40 </tr><tr>
41 <td><a href="#_get_all_tokens">_get_all_tokens</a></td>
42 <td>Starting from *line*, generate the necessary tokens which represent the shortest tokenization possible.</td>
43 </tr><tr>
44 <td><a href="#_less_tokens">_less_tokens</a></td>
45 <td>Process the output of `tokenize.generate_tokens` removing the tokens specified in `remove`.</td>
46 </tr><tr>
47 <td><a href="#_logical">_logical</a></td>
48 <td>Find how many logical lines are there in the current line.</td>
49 </tr><tr>
50 <td><a href="#_split_tokens">_split_tokens</a></td>
51 <td>Split a list of tokens on the specified token pair (token, value), where *token* is the token type (i.e.</td>
52 </tr><tr>
53 <td><a href="#analyze">analyze</a></td>
54 <td>Analyze the source code and return a namedtuple with the following fields:</td>
55 </tr><tr>
56 <td><a href="#aux">aux</a></td>
57 <td>The actual function which does the job.</td>
58 </tr>
59 </table>
60 <hr /><hr />
61 <a NAME="_find" ID="_find"></a>
62 <h2>_find</h2>
63 <b>_find</b>(<i>tokens, token, value</i>)
64 <p>
65 Return the position of the last token with the same (token, value)
66 pair supplied. The position is the one of the rightmost term.
67 </p>
68 <div align="right"><a href="#top">Up</a></div>
69 <hr /><hr />
70 <a NAME="_generate" ID="_generate"></a>
71 <h2>_generate</h2>
72 <b>_generate</b>(<i>code</i>)
73 <p>
74 Pass the code into `tokenize.generate_tokens` and convert the result
75 into a list.
76 </p>
77 <div align="right"><a href="#top">Up</a></div>
78 <hr /><hr />
79 <a NAME="_get_all_tokens" ID="_get_all_tokens"></a>
80 <h2>_get_all_tokens</h2>
81 <b>_get_all_tokens</b>(<i>line, lines</i>)
82 <p>
83 Starting from *line*, generate the necessary tokens which represent the
84 shortest tokenization possible. This is done by catching
85 :exc:`tokenize.TokenError` when a multi-line string or statement is
86 encountered.
87 </p>
88 <div align="right"><a href="#top">Up</a></div>
89 <hr /><hr />
90 <a NAME="_less_tokens" ID="_less_tokens"></a>
91 <h2>_less_tokens</h2>
92 <b>_less_tokens</b>(<i>tokens, remove</i>)
93 <p>
94 Process the output of `tokenize.generate_tokens` removing
95 the tokens specified in `remove`.
96 </p>
97 <div align="right"><a href="#top">Up</a></div>
98 <hr /><hr />
99 <a NAME="_logical" ID="_logical"></a>
100 <h2>_logical</h2>
101 <b>_logical</b>(<i>tokens</i>)
102 <p>
103 Find how many logical lines are there in the current line.
104 </p><p>
105 Normally 1 line of code is equivalent to 1 logical line of code,
106 but there are cases when this is not true. For example::
107 </p><p>
108 if cond: return 0
109 </p><p>
110 this line actually corresponds to 2 logical lines, since it can be
111 translated into::
112 </p><p>
113 if cond:
114 return 0
115 </p><p>
116 Examples::
117 </p><p>
118 if cond: -> 1
119 </p><p>
120 if cond: return 0 -> 2
121 </p><p>
122 try: 1/0 -> 2
123 </p><p>
124 try: -> 1
125 </p><p>
126 if cond: # Only a comment -> 1
127 </p><p>
128 if cond: return 0 # Only a comment -> 2
129 </p>
130 <div align="right"><a href="#top">Up</a></div>
131 <hr /><hr />
132 <a NAME="_split_tokens" ID="_split_tokens"></a>
133 <h2>_split_tokens</h2>
134 <b>_split_tokens</b>(<i>tokens, token, value</i>)
135 <p>
136 Split a list of tokens on the specified token pair (token, value),
137 where *token* is the token type (i.e. its code) and *value* its actual
138 value in the code.
139 </p>
140 <div align="right"><a href="#top">Up</a></div>
141 <hr /><hr />
142 <a NAME="analyze" ID="analyze"></a>
143 <h2>analyze</h2>
144 <b>analyze</b>(<i>source</i>)
145 <p>
146 Analyze the source code and return a namedtuple with the following
147 fields:
148 </p><p>
149 * **loc**: The number of lines of code (total)
150 * **lloc**: The number of logical lines of code
151 * **sloc**: The number of source lines of code (not necessarily
152 corresponding to the LLOC)
153 * **comments**: The number of Python comment lines
154 * **multi**: The number of lines which represent multi-line strings
155 * **blank**: The number of blank lines (or whitespace-only ones)
156 </p><p>
157 The equation :math:`sloc + blanks = loc` should always hold.
158 Multiline strings are not counted as comments, since, to the Python
159 interpreter, they are not comments but strings.
160 </p>
161 <div align="right"><a href="#top">Up</a></div>
162 <hr /><hr />
163 <a NAME="aux" ID="aux"></a>
164 <h2>aux</h2>
165 <b>aux</b>(<i>sub_tokens</i>)
166 <p>
167 The actual function which does the job.
168 </p>
169 <div align="right"><a href="#top">Up</a></div>
170 <hr />
171 </body></html>

eric ide

mercurial