|
1 <!DOCTYPE html> |
|
2 <html><head> |
|
3 <title>eric6.DebugClients.Python.AsyncFile</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>eric6.DebugClients.Python.AsyncFile</h1> |
|
23 <p> |
|
24 Module implementing an asynchronous file like socket interface for the |
|
25 debugger. |
|
26 </p> |
|
27 <h3>Global Attributes</h3> |
|
28 <table> |
|
29 <tr><td>None</td></tr> |
|
30 </table> |
|
31 <h3>Classes</h3> |
|
32 <table> |
|
33 <tr> |
|
34 <td><a href="#AsyncFile">AsyncFile</a></td> |
|
35 <td>Class wrapping a socket object with a file interface.</td> |
|
36 </tr> |
|
37 </table> |
|
38 <h3>Functions</h3> |
|
39 <table> |
|
40 <tr> |
|
41 <td><a href="#AsyncPendingWrite">AsyncPendingWrite</a></td> |
|
42 <td>Module function to check for data to be written.</td> |
|
43 </tr> |
|
44 </table> |
|
45 <hr /><hr /> |
|
46 <a NAME="AsyncFile" ID="AsyncFile"></a> |
|
47 <h2>AsyncFile</h2> |
|
48 <p> |
|
49 Class wrapping a socket object with a file interface. |
|
50 </p> |
|
51 <h3>Derived from</h3> |
|
52 object |
|
53 <h3>Class Attributes</h3> |
|
54 <table> |
|
55 <tr><td>maxtries</td></tr> |
|
56 </table> |
|
57 <h3>Class Methods</h3> |
|
58 <table> |
|
59 <tr><td>None</td></tr> |
|
60 </table> |
|
61 <h3>Methods</h3> |
|
62 <table> |
|
63 <tr> |
|
64 <td><a href="#AsyncFile.__init__">AsyncFile</a></td> |
|
65 <td>Constructor</td> |
|
66 </tr><tr> |
|
67 <td><a href="#AsyncFile.__checkMode">__checkMode</a></td> |
|
68 <td>Private method to check the mode.</td> |
|
69 </tr><tr> |
|
70 <td><a href="#AsyncFile.close">close</a></td> |
|
71 <td>Public method to close the file.</td> |
|
72 </tr><tr> |
|
73 <td><a href="#AsyncFile.fileno">fileno</a></td> |
|
74 <td>Public method returning the file number.</td> |
|
75 </tr><tr> |
|
76 <td><a href="#AsyncFile.flush">flush</a></td> |
|
77 <td>Public method to write all pending entries.</td> |
|
78 </tr><tr> |
|
79 <td><a href="#AsyncFile.isatty">isatty</a></td> |
|
80 <td>Public method to indicate whether a tty interface is supported.</td> |
|
81 </tr><tr> |
|
82 <td><a href="#AsyncFile.pendingWrite">pendingWrite</a></td> |
|
83 <td>Public method that returns the number of strings waiting to be written.</td> |
|
84 </tr><tr> |
|
85 <td><a href="#AsyncFile.read">read</a></td> |
|
86 <td>Public method to read bytes from this file.</td> |
|
87 </tr><tr> |
|
88 <td><a href="#AsyncFile.readCommand">readCommand</a></td> |
|
89 <td>Public method to read a length prefixed command string.</td> |
|
90 </tr><tr> |
|
91 <td><a href="#AsyncFile.read_p">read_p</a></td> |
|
92 <td>Public method to read bytes from this file.</td> |
|
93 </tr><tr> |
|
94 <td><a href="#AsyncFile.readable">readable</a></td> |
|
95 <td>Public method to check, if the stream is readable.</td> |
|
96 </tr><tr> |
|
97 <td><a href="#AsyncFile.readline">readline</a></td> |
|
98 <td>Public method to read one line from this file.</td> |
|
99 </tr><tr> |
|
100 <td><a href="#AsyncFile.readline_p">readline_p</a></td> |
|
101 <td>Public method to read a line from this file.</td> |
|
102 </tr><tr> |
|
103 <td><a href="#AsyncFile.readlines">readlines</a></td> |
|
104 <td>Public method to read all lines from this file.</td> |
|
105 </tr><tr> |
|
106 <td><a href="#AsyncFile.seek">seek</a></td> |
|
107 <td>Public method to move the filepointer.</td> |
|
108 </tr><tr> |
|
109 <td><a href="#AsyncFile.seekable">seekable</a></td> |
|
110 <td>Public method to check, if the stream is seekable.</td> |
|
111 </tr><tr> |
|
112 <td><a href="#AsyncFile.tell">tell</a></td> |
|
113 <td>Public method to get the filepointer position.</td> |
|
114 </tr><tr> |
|
115 <td><a href="#AsyncFile.truncate">truncate</a></td> |
|
116 <td>Public method to truncate the file.</td> |
|
117 </tr><tr> |
|
118 <td><a href="#AsyncFile.writable">writable</a></td> |
|
119 <td>Public method to check, if a stream is writable.</td> |
|
120 </tr><tr> |
|
121 <td><a href="#AsyncFile.write">write</a></td> |
|
122 <td>Public method to write a string to the file.</td> |
|
123 </tr><tr> |
|
124 <td><a href="#AsyncFile.write_p">write_p</a></td> |
|
125 <td>Public method to write a json-rpc 2.0 coded string to the file.</td> |
|
126 </tr><tr> |
|
127 <td><a href="#AsyncFile.writelines">writelines</a></td> |
|
128 <td>Public method to write a list of strings to the file.</td> |
|
129 </tr> |
|
130 </table> |
|
131 <h3>Static Methods</h3> |
|
132 <table> |
|
133 <tr><td>None</td></tr> |
|
134 </table> |
|
135 <a NAME="AsyncFile.__init__" ID="AsyncFile.__init__"></a> |
|
136 <h4>AsyncFile (Constructor)</h4> |
|
137 <b>AsyncFile</b>(<i>sock, mode, name</i>) |
|
138 <p> |
|
139 Constructor |
|
140 </p><dl> |
|
141 <dt><i>sock</i> (socket)</dt> |
|
142 <dd> |
|
143 the socket object being wrapped |
|
144 </dd><dt><i>mode</i> (str)</dt> |
|
145 <dd> |
|
146 mode of this file |
|
147 </dd><dt><i>name</i> (str)</dt> |
|
148 <dd> |
|
149 name of this file |
|
150 </dd> |
|
151 </dl><a NAME="AsyncFile.__checkMode" ID="AsyncFile.__checkMode"></a> |
|
152 <h4>AsyncFile.__checkMode</h4> |
|
153 <b>__checkMode</b>(<i>mode</i>) |
|
154 <p> |
|
155 Private method to check the mode. |
|
156 </p><p> |
|
157 This method checks, if an operation is permitted according to |
|
158 the mode of the file. If it is not, an IOError is raised. |
|
159 </p><dl> |
|
160 <dt><i>mode</i> (string)</dt> |
|
161 <dd> |
|
162 the mode to be checked |
|
163 </dd> |
|
164 </dl><dl> |
|
165 <dt>Raises <b>IOError</b>:</dt> |
|
166 <dd> |
|
167 raised to indicate a bad file descriptor |
|
168 </dd> |
|
169 </dl><a NAME="AsyncFile.close" ID="AsyncFile.close"></a> |
|
170 <h4>AsyncFile.close</h4> |
|
171 <b>close</b>(<i>closeit=False</i>) |
|
172 <p> |
|
173 Public method to close the file. |
|
174 </p><dl> |
|
175 <dt><i>closeit</i> (bool)</dt> |
|
176 <dd> |
|
177 flag to indicate a close ordered by the debugger code |
|
178 </dd> |
|
179 </dl><a NAME="AsyncFile.fileno" ID="AsyncFile.fileno"></a> |
|
180 <h4>AsyncFile.fileno</h4> |
|
181 <b>fileno</b>(<i></i>) |
|
182 <p> |
|
183 Public method returning the file number. |
|
184 </p><dl> |
|
185 <dt>Returns:</dt> |
|
186 <dd> |
|
187 file number |
|
188 </dd> |
|
189 </dl><dl> |
|
190 <dt>Return Type:</dt> |
|
191 <dd> |
|
192 int |
|
193 </dd> |
|
194 </dl><a NAME="AsyncFile.flush" ID="AsyncFile.flush"></a> |
|
195 <h4>AsyncFile.flush</h4> |
|
196 <b>flush</b>(<i></i>) |
|
197 <p> |
|
198 Public method to write all pending entries. |
|
199 </p><a NAME="AsyncFile.isatty" ID="AsyncFile.isatty"></a> |
|
200 <h4>AsyncFile.isatty</h4> |
|
201 <b>isatty</b>(<i></i>) |
|
202 <p> |
|
203 Public method to indicate whether a tty interface is supported. |
|
204 </p><dl> |
|
205 <dt>Returns:</dt> |
|
206 <dd> |
|
207 always false |
|
208 </dd> |
|
209 </dl><dl> |
|
210 <dt>Return Type:</dt> |
|
211 <dd> |
|
212 bool |
|
213 </dd> |
|
214 </dl><a NAME="AsyncFile.pendingWrite" ID="AsyncFile.pendingWrite"></a> |
|
215 <h4>AsyncFile.pendingWrite</h4> |
|
216 <b>pendingWrite</b>(<i></i>) |
|
217 <p> |
|
218 Public method that returns the number of strings waiting to be written. |
|
219 </p><dl> |
|
220 <dt>Returns:</dt> |
|
221 <dd> |
|
222 the number of strings to be written |
|
223 </dd> |
|
224 </dl><dl> |
|
225 <dt>Return Type:</dt> |
|
226 <dd> |
|
227 int |
|
228 </dd> |
|
229 </dl><a NAME="AsyncFile.read" ID="AsyncFile.read"></a> |
|
230 <h4>AsyncFile.read</h4> |
|
231 <b>read</b>(<i>size=-1</i>) |
|
232 <p> |
|
233 Public method to read bytes from this file. |
|
234 </p><dl> |
|
235 <dt><i>size</i> (int)</dt> |
|
236 <dd> |
|
237 maximum number of bytes to be read |
|
238 </dd> |
|
239 </dl><dl> |
|
240 <dt>Returns:</dt> |
|
241 <dd> |
|
242 the bytes read |
|
243 </dd> |
|
244 </dl><dl> |
|
245 <dt>Return Type:</dt> |
|
246 <dd> |
|
247 str |
|
248 </dd> |
|
249 </dl><a NAME="AsyncFile.readCommand" ID="AsyncFile.readCommand"></a> |
|
250 <h4>AsyncFile.readCommand</h4> |
|
251 <b>readCommand</b>(<i></i>) |
|
252 <p> |
|
253 Public method to read a length prefixed command string. |
|
254 </p><dl> |
|
255 <dt>Returns:</dt> |
|
256 <dd> |
|
257 command string |
|
258 </dd> |
|
259 </dl><dl> |
|
260 <dt>Return Type:</dt> |
|
261 <dd> |
|
262 str |
|
263 </dd> |
|
264 </dl><a NAME="AsyncFile.read_p" ID="AsyncFile.read_p"></a> |
|
265 <h4>AsyncFile.read_p</h4> |
|
266 <b>read_p</b>(<i>size=-1</i>) |
|
267 <p> |
|
268 Public method to read bytes from this file. |
|
269 </p><dl> |
|
270 <dt><i>size</i> (int)</dt> |
|
271 <dd> |
|
272 maximum number of bytes to be read |
|
273 </dd> |
|
274 </dl><dl> |
|
275 <dt>Returns:</dt> |
|
276 <dd> |
|
277 the bytes read |
|
278 </dd> |
|
279 </dl><dl> |
|
280 <dt>Return Type:</dt> |
|
281 <dd> |
|
282 str |
|
283 </dd> |
|
284 </dl><a NAME="AsyncFile.readable" ID="AsyncFile.readable"></a> |
|
285 <h4>AsyncFile.readable</h4> |
|
286 <b>readable</b>(<i></i>) |
|
287 <p> |
|
288 Public method to check, if the stream is readable. |
|
289 </p><dl> |
|
290 <dt>Returns:</dt> |
|
291 <dd> |
|
292 flag indicating a readable stream |
|
293 </dd> |
|
294 </dl><dl> |
|
295 <dt>Return Type:</dt> |
|
296 <dd> |
|
297 bool |
|
298 </dd> |
|
299 </dl><a NAME="AsyncFile.readline" ID="AsyncFile.readline"></a> |
|
300 <h4>AsyncFile.readline</h4> |
|
301 <b>readline</b>(<i>sizehint=-1</i>) |
|
302 <p> |
|
303 Public method to read one line from this file. |
|
304 </p><dl> |
|
305 <dt><i>sizehint</i> (int)</dt> |
|
306 <dd> |
|
307 hint of the numbers of bytes to be read |
|
308 </dd> |
|
309 </dl><dl> |
|
310 <dt>Returns:</dt> |
|
311 <dd> |
|
312 one line read |
|
313 </dd> |
|
314 </dl><dl> |
|
315 <dt>Return Type:</dt> |
|
316 <dd> |
|
317 str |
|
318 </dd> |
|
319 </dl><a NAME="AsyncFile.readline_p" ID="AsyncFile.readline_p"></a> |
|
320 <h4>AsyncFile.readline_p</h4> |
|
321 <b>readline_p</b>(<i>size=-1</i>) |
|
322 <p> |
|
323 Public method to read a line from this file. |
|
324 </p><p> |
|
325 <b>Note</b>: This method will not block and may return |
|
326 only a part of a line if that is all that is available. |
|
327 </p><dl> |
|
328 <dt><i>size</i> (int)</dt> |
|
329 <dd> |
|
330 maximum number of bytes to be read |
|
331 </dd> |
|
332 </dl><dl> |
|
333 <dt>Returns:</dt> |
|
334 <dd> |
|
335 one line of text up to size bytes |
|
336 </dd> |
|
337 </dl><dl> |
|
338 <dt>Return Type:</dt> |
|
339 <dd> |
|
340 str |
|
341 </dd> |
|
342 </dl><a NAME="AsyncFile.readlines" ID="AsyncFile.readlines"></a> |
|
343 <h4>AsyncFile.readlines</h4> |
|
344 <b>readlines</b>(<i>sizehint=-1</i>) |
|
345 <p> |
|
346 Public method to read all lines from this file. |
|
347 </p><dl> |
|
348 <dt><i>sizehint</i> (int)</dt> |
|
349 <dd> |
|
350 hint of the numbers of bytes to be read |
|
351 </dd> |
|
352 </dl><dl> |
|
353 <dt>Returns:</dt> |
|
354 <dd> |
|
355 list of lines read |
|
356 </dd> |
|
357 </dl><dl> |
|
358 <dt>Return Type:</dt> |
|
359 <dd> |
|
360 list of str |
|
361 </dd> |
|
362 </dl><a NAME="AsyncFile.seek" ID="AsyncFile.seek"></a> |
|
363 <h4>AsyncFile.seek</h4> |
|
364 <b>seek</b>(<i>offset, whence=0</i>) |
|
365 <p> |
|
366 Public method to move the filepointer. |
|
367 </p><dl> |
|
368 <dt><i>offset</i> (int)</dt> |
|
369 <dd> |
|
370 offset to move the filepointer to |
|
371 </dd><dt><i>whence</i> (int)</dt> |
|
372 <dd> |
|
373 position the offset relates to |
|
374 </dd> |
|
375 </dl><dl> |
|
376 <dt>Raises <b>IOError</b>:</dt> |
|
377 <dd> |
|
378 This method is not supported and always raises an |
|
379 IOError. |
|
380 </dd> |
|
381 </dl><a NAME="AsyncFile.seekable" ID="AsyncFile.seekable"></a> |
|
382 <h4>AsyncFile.seekable</h4> |
|
383 <b>seekable</b>(<i></i>) |
|
384 <p> |
|
385 Public method to check, if the stream is seekable. |
|
386 </p><dl> |
|
387 <dt>Returns:</dt> |
|
388 <dd> |
|
389 flag indicating a seekable stream |
|
390 </dd> |
|
391 </dl><dl> |
|
392 <dt>Return Type:</dt> |
|
393 <dd> |
|
394 bool |
|
395 </dd> |
|
396 </dl><a NAME="AsyncFile.tell" ID="AsyncFile.tell"></a> |
|
397 <h4>AsyncFile.tell</h4> |
|
398 <b>tell</b>(<i></i>) |
|
399 <p> |
|
400 Public method to get the filepointer position. |
|
401 </p><dl> |
|
402 <dt>Raises <b>IOError</b>:</dt> |
|
403 <dd> |
|
404 This method is not supported and always raises an |
|
405 IOError. |
|
406 </dd> |
|
407 </dl><a NAME="AsyncFile.truncate" ID="AsyncFile.truncate"></a> |
|
408 <h4>AsyncFile.truncate</h4> |
|
409 <b>truncate</b>(<i>size=-1</i>) |
|
410 <p> |
|
411 Public method to truncate the file. |
|
412 </p><dl> |
|
413 <dt><i>size</i> (int)</dt> |
|
414 <dd> |
|
415 size to truncate to |
|
416 </dd> |
|
417 </dl><dl> |
|
418 <dt>Raises <b>IOError</b>:</dt> |
|
419 <dd> |
|
420 This method is not supported and always raises an |
|
421 IOError. |
|
422 </dd> |
|
423 </dl><a NAME="AsyncFile.writable" ID="AsyncFile.writable"></a> |
|
424 <h4>AsyncFile.writable</h4> |
|
425 <b>writable</b>(<i></i>) |
|
426 <p> |
|
427 Public method to check, if a stream is writable. |
|
428 </p><dl> |
|
429 <dt>Returns:</dt> |
|
430 <dd> |
|
431 flag indicating a writable stream |
|
432 </dd> |
|
433 </dl><dl> |
|
434 <dt>Return Type:</dt> |
|
435 <dd> |
|
436 bool |
|
437 </dd> |
|
438 </dl><a NAME="AsyncFile.write" ID="AsyncFile.write"></a> |
|
439 <h4>AsyncFile.write</h4> |
|
440 <b>write</b>(<i>s</i>) |
|
441 <p> |
|
442 Public method to write a string to the file. |
|
443 </p><dl> |
|
444 <dt><i>s</i> (str)</dt> |
|
445 <dd> |
|
446 text to be written |
|
447 </dd> |
|
448 </dl><a NAME="AsyncFile.write_p" ID="AsyncFile.write_p"></a> |
|
449 <h4>AsyncFile.write_p</h4> |
|
450 <b>write_p</b>(<i>s</i>) |
|
451 <p> |
|
452 Public method to write a json-rpc 2.0 coded string to the file. |
|
453 </p><dl> |
|
454 <dt><i>s</i> (str)</dt> |
|
455 <dd> |
|
456 text to be written |
|
457 </dd> |
|
458 </dl><a NAME="AsyncFile.writelines" ID="AsyncFile.writelines"></a> |
|
459 <h4>AsyncFile.writelines</h4> |
|
460 <b>writelines</b>(<i>lines</i>) |
|
461 <p> |
|
462 Public method to write a list of strings to the file. |
|
463 </p><dl> |
|
464 <dt><i>lines</i> (list of str)</dt> |
|
465 <dd> |
|
466 list of texts to be written |
|
467 </dd> |
|
468 </dl> |
|
469 <div align="right"><a href="#top">Up</a></div> |
|
470 <hr /><hr /> |
|
471 <a NAME="AsyncPendingWrite" ID="AsyncPendingWrite"></a> |
|
472 <h2>AsyncPendingWrite</h2> |
|
473 <b>AsyncPendingWrite</b>(<i>file</i>) |
|
474 <p> |
|
475 Module function to check for data to be written. |
|
476 </p><dl> |
|
477 <dt><i>file</i> (file)</dt> |
|
478 <dd> |
|
479 The file object to be checked |
|
480 </dd> |
|
481 </dl><dl> |
|
482 <dt>Returns:</dt> |
|
483 <dd> |
|
484 Flag indicating if there is data waiting |
|
485 </dd> |
|
486 </dl><dl> |
|
487 <dt>Return Type:</dt> |
|
488 <dd> |
|
489 int |
|
490 </dd> |
|
491 </dl> |
|
492 <div align="right"><a href="#top">Up</a></div> |
|
493 <hr /> |
|
494 </body></html> |