1 <!DOCTYPE html> |
|
2 <html><head> |
|
3 <title>eric5.Utilities.SyntaxCheck</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>eric5.Utilities.SyntaxCheck</h1> |
|
23 <p> |
|
24 Module implementing the syntax check for Python 2/3. |
|
25 </p> |
|
26 <h3>Global Attributes</h3> |
|
27 <table> |
|
28 <tr><td>codingBytes_regexps</td></tr> |
|
29 </table> |
|
30 <h3>Classes</h3> |
|
31 <table> |
|
32 <tr><td>None</td></tr> |
|
33 </table> |
|
34 <h3>Functions</h3> |
|
35 <table> |
|
36 <tr> |
|
37 <td><a href="#compile_and_check">compile_and_check</a></td> |
|
38 <td>Function to compile one Python source file to Python bytecode and to perform a pyflakes check.</td> |
|
39 </tr><tr> |
|
40 <td><a href="#decode">decode</a></td> |
|
41 <td>Function to decode some byte text into a string.</td> |
|
42 </tr><tr> |
|
43 <td><a href="#extractLineFlags">extractLineFlags</a></td> |
|
44 <td>Function to extract flags starting and ending with '__' from a line comment.</td> |
|
45 </tr><tr> |
|
46 <td><a href="#get_codingBytes">get_codingBytes</a></td> |
|
47 <td>Function to get the coding of a bytes text.</td> |
|
48 </tr><tr> |
|
49 <td><a href="#normalizeCode">normalizeCode</a></td> |
|
50 <td>Function to normalize the given code.</td> |
|
51 </tr><tr> |
|
52 <td><a href="#readEncodedFile">readEncodedFile</a></td> |
|
53 <td>Function to read a file and decode it's contents into proper text.</td> |
|
54 </tr> |
|
55 </table> |
|
56 <hr /><hr /> |
|
57 <a NAME="compile_and_check" ID="compile_and_check"></a> |
|
58 <h2>compile_and_check</h2> |
|
59 <b>compile_and_check</b>(<i>file_, codestring="", checkFlakes=True, ignoreStarImportWarnings=False</i>) |
|
60 <p> |
|
61 Function to compile one Python source file to Python bytecode |
|
62 and to perform a pyflakes check. |
|
63 </p><dl> |
|
64 <dt><i>file_</i></dt> |
|
65 <dd> |
|
66 source filename (string) |
|
67 </dd><dt><i>codestring</i></dt> |
|
68 <dd> |
|
69 string containing the code to compile (string) |
|
70 </dd><dt><i>checkFlakes=</i></dt> |
|
71 <dd> |
|
72 flag indicating to do a pyflakes check (boolean) |
|
73 </dd><dt><i>ignoreStarImportWarnings=</i></dt> |
|
74 <dd> |
|
75 flag indicating to |
|
76 ignore 'star import' warnings (boolean) |
|
77 </dd> |
|
78 </dl><dl> |
|
79 <dt>Returns:</dt> |
|
80 <dd> |
|
81 A tuple indicating status (True = an error was found), the |
|
82 file name, the line number, the index number, the code string |
|
83 and the error message (boolean, string, string, string, string, |
|
84 string). If checkFlakes is True, a list of strings containing the |
|
85 warnings (marker, file name, line number, message) |
|
86 The values are only valid, if the status is True. |
|
87 </dd> |
|
88 </dl> |
|
89 <div align="right"><a href="#top">Up</a></div> |
|
90 <hr /><hr /> |
|
91 <a NAME="decode" ID="decode"></a> |
|
92 <h2>decode</h2> |
|
93 <b>decode</b>(<i>text</i>) |
|
94 <p> |
|
95 Function to decode some byte text into a string. |
|
96 </p><dl> |
|
97 <dt><i>text</i></dt> |
|
98 <dd> |
|
99 byte text to decode (bytes) |
|
100 </dd> |
|
101 </dl><dl> |
|
102 <dt>Returns:</dt> |
|
103 <dd> |
|
104 tuple of decoded text and encoding (string, string) |
|
105 </dd> |
|
106 </dl> |
|
107 <div align="right"><a href="#top">Up</a></div> |
|
108 <hr /><hr /> |
|
109 <a NAME="extractLineFlags" ID="extractLineFlags"></a> |
|
110 <h2>extractLineFlags</h2> |
|
111 <b>extractLineFlags</b>(<i>line, startComment="</i>) |
|
112 <p> |
|
113 Function to extract flags starting and ending with '__' from a line |
|
114 comment. |
|
115 </p><dl> |
|
116 <dt><i>line</i></dt> |
|
117 <dd> |
|
118 line to extract flags from (string) |
|
119 </dd><dt><i>startComment=</i></dt> |
|
120 <dd> |
|
121 string identifying the start of the comment (string) |
|
122 </dd><dt><i>endComment=</i></dt> |
|
123 <dd> |
|
124 string identifying the end of a comment (string) |
|
125 </dd> |
|
126 </dl><dl> |
|
127 <dt>Returns:</dt> |
|
128 <dd> |
|
129 list containing the extracted flags (list of strings) |
|
130 </dd> |
|
131 </dl> |
|
132 <div align="right"><a href="#top">Up</a></div> |
|
133 <hr /><hr /> |
|
134 <a NAME="get_codingBytes" ID="get_codingBytes"></a> |
|
135 <h2>get_codingBytes</h2> |
|
136 <b>get_codingBytes</b>(<i>text</i>) |
|
137 <p> |
|
138 Function to get the coding of a bytes text. |
|
139 </p><dl> |
|
140 <dt><i>text</i></dt> |
|
141 <dd> |
|
142 bytes text to inspect (bytes) |
|
143 </dd> |
|
144 </dl><dl> |
|
145 <dt>Returns:</dt> |
|
146 <dd> |
|
147 coding string |
|
148 </dd> |
|
149 </dl> |
|
150 <div align="right"><a href="#top">Up</a></div> |
|
151 <hr /><hr /> |
|
152 <a NAME="normalizeCode" ID="normalizeCode"></a> |
|
153 <h2>normalizeCode</h2> |
|
154 <b>normalizeCode</b>(<i>codestring</i>) |
|
155 <p> |
|
156 Function to normalize the given code. |
|
157 </p><dl> |
|
158 <dt><i>codestring</i></dt> |
|
159 <dd> |
|
160 code to be normalized (string) |
|
161 </dd> |
|
162 </dl><dl> |
|
163 <dt>Returns:</dt> |
|
164 <dd> |
|
165 normalized code (string) |
|
166 </dd> |
|
167 </dl> |
|
168 <div align="right"><a href="#top">Up</a></div> |
|
169 <hr /><hr /> |
|
170 <a NAME="readEncodedFile" ID="readEncodedFile"></a> |
|
171 <h2>readEncodedFile</h2> |
|
172 <b>readEncodedFile</b>(<i>filename</i>) |
|
173 <p> |
|
174 Function to read a file and decode it's contents into proper text. |
|
175 </p><dl> |
|
176 <dt><i>filename</i></dt> |
|
177 <dd> |
|
178 name of the file to read (string) |
|
179 </dd> |
|
180 </dl><dl> |
|
181 <dt>Returns:</dt> |
|
182 <dd> |
|
183 tuple of decoded text and encoding (string, string) |
|
184 </dd> |
|
185 </dl> |
|
186 <div align="right"><a href="#top">Up</a></div> |
|
187 <hr /> |
|
188 </body></html> |
|