|
1 <!DOCTYPE html> |
|
2 <html><head> |
|
3 <title>eric7.DebugClients.Python.DebugUtilities</title> |
|
4 <meta charset="UTF-8"> |
|
5 <link rel="stylesheet" href="styles.css"> |
|
6 </head> |
|
7 <body> |
|
8 <a NAME="top" ID="top"></a> |
|
9 <h1>eric7.DebugClients.Python.DebugUtilities</h1> |
|
10 |
|
11 <p> |
|
12 Module implementing utilities functions for the debug client. |
|
13 </p> |
|
14 <h3>Global Attributes</h3> |
|
15 |
|
16 <table> |
|
17 <tr><td>ArgInfo</td></tr><tr><td>PYTHON_NAMES</td></tr> |
|
18 </table> |
|
19 <h3>Classes</h3> |
|
20 |
|
21 <table> |
|
22 <tr><td>None</td></tr> |
|
23 </table> |
|
24 <h3>Functions</h3> |
|
25 |
|
26 <table> |
|
27 |
|
28 <tr> |
|
29 <td><a href="#_getfullargs">_getfullargs</a></td> |
|
30 <td>Protected function to get information about the arguments accepted by a code object.</td> |
|
31 </tr> |
|
32 <tr> |
|
33 <td><a href="#formatargvalues">formatargvalues</a></td> |
|
34 <td>Function to format an argument spec from the 4 values returned by getargvalues.</td> |
|
35 </tr> |
|
36 <tr> |
|
37 <td><a href="#getargvalues">getargvalues</a></td> |
|
38 <td>Function to get information about arguments passed into a particular frame.</td> |
|
39 </tr> |
|
40 <tr> |
|
41 <td><a href="#isExecutable">isExecutable</a></td> |
|
42 <td>Function to check, if the given program is executable.</td> |
|
43 </tr> |
|
44 <tr> |
|
45 <td><a href="#isPythonProgram">isPythonProgram</a></td> |
|
46 <td>Function to check, if the given program is a Python interpreter or program.</td> |
|
47 </tr> |
|
48 <tr> |
|
49 <td><a href="#isWindowsPlatform">isWindowsPlatform</a></td> |
|
50 <td>Function to check, if this is a Windows platform.</td> |
|
51 </tr> |
|
52 <tr> |
|
53 <td><a href="#patchArgumentStringWindows">patchArgumentStringWindows</a></td> |
|
54 <td>Function to patch an argument string for Windows.</td> |
|
55 </tr> |
|
56 <tr> |
|
57 <td><a href="#patchArguments">patchArguments</a></td> |
|
58 <td>Function to patch the arguments given to start a program in order to execute it in our debugger.</td> |
|
59 </tr> |
|
60 <tr> |
|
61 <td><a href="#prepareJsonCommand">prepareJsonCommand</a></td> |
|
62 <td>Function to prepare a single command or response for transmission to the IDE.</td> |
|
63 </tr> |
|
64 <tr> |
|
65 <td><a href="#quoteArgs">quoteArgs</a></td> |
|
66 <td>Function to quote the given list of arguments.</td> |
|
67 </tr> |
|
68 <tr> |
|
69 <td><a href="#removeQuotesFromArgs">removeQuotesFromArgs</a></td> |
|
70 <td>Function to remove quotes from the arguments list.</td> |
|
71 </tr> |
|
72 <tr> |
|
73 <td><a href="#startsWithShebang">startsWithShebang</a></td> |
|
74 <td>Function to check, if the given program start with a Shebang line.</td> |
|
75 </tr> |
|
76 <tr> |
|
77 <td><a href="#stringToArgumentsWindows">stringToArgumentsWindows</a></td> |
|
78 <td>Function to prepare a string of arguments for Windows platform.</td> |
|
79 </tr> |
|
80 </table> |
|
81 <hr /> |
|
82 <hr /> |
|
83 <a NAME="_getfullargs" ID="_getfullargs"></a> |
|
84 <h2>_getfullargs</h2> |
|
85 <b>_getfullargs</b>(<i>co</i>) |
|
86 |
|
87 <p> |
|
88 Protected function to get information about the arguments accepted |
|
89 by a code object. |
|
90 </p> |
|
91 <dl> |
|
92 |
|
93 <dt><i>co</i> (code)</dt> |
|
94 <dd> |
|
95 reference to a code object to be processed |
|
96 </dd> |
|
97 </dl> |
|
98 <dl> |
|
99 <dt>Return:</dt> |
|
100 <dd> |
|
101 tuple of four things, where 'args' and 'kwonlyargs' are lists of |
|
102 argument names, and 'varargs' and 'varkw' are the names of the |
|
103 * and ** arguments or None. |
|
104 </dd> |
|
105 </dl> |
|
106 <dl> |
|
107 |
|
108 <dt>Raises <b>TypeError</b>:</dt> |
|
109 <dd> |
|
110 raised if the input parameter is not a code object |
|
111 </dd> |
|
112 </dl> |
|
113 <div align="right"><a href="#top">Up</a></div> |
|
114 <hr /> |
|
115 <hr /> |
|
116 <a NAME="formatargvalues" ID="formatargvalues"></a> |
|
117 <h2>formatargvalues</h2> |
|
118 <b>formatargvalues</b>(<i>args, varargs, varkw, localsDict, formatarg=str, formatvarargs=lambda name: '*' + name, formatvarkw=lambda name: '**' + name, formatvalue=lambda value: '=' + repr(value)</i>) |
|
119 |
|
120 <p> |
|
121 Function to format an argument spec from the 4 values returned |
|
122 by getargvalues. |
|
123 </p> |
|
124 <dl> |
|
125 |
|
126 <dt><i>args</i> (list of str)</dt> |
|
127 <dd> |
|
128 list of argument names |
|
129 </dd> |
|
130 <dt><i>varargs</i> (str)</dt> |
|
131 <dd> |
|
132 name of the variable arguments |
|
133 </dd> |
|
134 <dt><i>varkw</i> (str)</dt> |
|
135 <dd> |
|
136 name of the keyword arguments |
|
137 </dd> |
|
138 <dt><i>localsDict</i> (dict)</dt> |
|
139 <dd> |
|
140 reference to the local variables dictionary |
|
141 </dd> |
|
142 <dt><i>formatarg</i> (func)</dt> |
|
143 <dd> |
|
144 argument formatting function |
|
145 </dd> |
|
146 <dt><i>formatvarargs</i> (func)</dt> |
|
147 <dd> |
|
148 variable arguments formatting function |
|
149 </dd> |
|
150 <dt><i>formatvarkw</i> (func)</dt> |
|
151 <dd> |
|
152 keyword arguments formatting function |
|
153 </dd> |
|
154 <dt><i>formatvalue</i> (func)</dt> |
|
155 <dd> |
|
156 value formating functtion |
|
157 </dd> |
|
158 </dl> |
|
159 <dl> |
|
160 <dt>Return:</dt> |
|
161 <dd> |
|
162 formatted call signature |
|
163 </dd> |
|
164 </dl> |
|
165 <dl> |
|
166 <dt>Return Type:</dt> |
|
167 <dd> |
|
168 str |
|
169 </dd> |
|
170 </dl> |
|
171 <div align="right"><a href="#top">Up</a></div> |
|
172 <hr /> |
|
173 <hr /> |
|
174 <a NAME="getargvalues" ID="getargvalues"></a> |
|
175 <h2>getargvalues</h2> |
|
176 <b>getargvalues</b>(<i>frame</i>) |
|
177 |
|
178 <p> |
|
179 Function to get information about arguments passed into a |
|
180 particular frame. |
|
181 </p> |
|
182 <dl> |
|
183 |
|
184 <dt><i>frame</i> (frame)</dt> |
|
185 <dd> |
|
186 reference to a frame object to be processed |
|
187 </dd> |
|
188 </dl> |
|
189 <dl> |
|
190 <dt>Return:</dt> |
|
191 <dd> |
|
192 tuple of four things, where 'args' is a list of the argument names, |
|
193 'varargs' and 'varkw' are the names of the * and ** arguments or None |
|
194 and 'locals' is the locals dictionary of the given frame. |
|
195 </dd> |
|
196 </dl> |
|
197 <dl> |
|
198 |
|
199 <dt>Raises <b>TypeError</b>:</dt> |
|
200 <dd> |
|
201 raised if the input parameter is not a frame object |
|
202 </dd> |
|
203 </dl> |
|
204 <div align="right"><a href="#top">Up</a></div> |
|
205 <hr /> |
|
206 <hr /> |
|
207 <a NAME="isExecutable" ID="isExecutable"></a> |
|
208 <h2>isExecutable</h2> |
|
209 <b>isExecutable</b>(<i>program</i>) |
|
210 |
|
211 <p> |
|
212 Function to check, if the given program is executable. |
|
213 </p> |
|
214 <dl> |
|
215 |
|
216 <dt><i>program</i> (str)</dt> |
|
217 <dd> |
|
218 program path to be checked |
|
219 </dd> |
|
220 </dl> |
|
221 <dl> |
|
222 <dt>Return:</dt> |
|
223 <dd> |
|
224 flag indicating an executable program |
|
225 </dd> |
|
226 </dl> |
|
227 <dl> |
|
228 <dt>Return Type:</dt> |
|
229 <dd> |
|
230 bool |
|
231 </dd> |
|
232 </dl> |
|
233 <div align="right"><a href="#top">Up</a></div> |
|
234 <hr /> |
|
235 <hr /> |
|
236 <a NAME="isPythonProgram" ID="isPythonProgram"></a> |
|
237 <h2>isPythonProgram</h2> |
|
238 <b>isPythonProgram</b>(<i>program</i>) |
|
239 |
|
240 <p> |
|
241 Function to check, if the given program is a Python interpreter or |
|
242 program. |
|
243 </p> |
|
244 <dl> |
|
245 |
|
246 <dt><i>program</i> (str)</dt> |
|
247 <dd> |
|
248 program to be checked |
|
249 </dd> |
|
250 </dl> |
|
251 <dl> |
|
252 <dt>Return:</dt> |
|
253 <dd> |
|
254 flag indicating a Python interpreter or program |
|
255 </dd> |
|
256 </dl> |
|
257 <dl> |
|
258 <dt>Return Type:</dt> |
|
259 <dd> |
|
260 bool |
|
261 </dd> |
|
262 </dl> |
|
263 <div align="right"><a href="#top">Up</a></div> |
|
264 <hr /> |
|
265 <hr /> |
|
266 <a NAME="isWindowsPlatform" ID="isWindowsPlatform"></a> |
|
267 <h2>isWindowsPlatform</h2> |
|
268 <b>isWindowsPlatform</b>(<i></i>) |
|
269 |
|
270 <p> |
|
271 Function to check, if this is a Windows platform. |
|
272 </p> |
|
273 <dl> |
|
274 <dt>Return:</dt> |
|
275 <dd> |
|
276 flag indicating Windows platform |
|
277 </dd> |
|
278 </dl> |
|
279 <dl> |
|
280 <dt>Return Type:</dt> |
|
281 <dd> |
|
282 bool |
|
283 </dd> |
|
284 </dl> |
|
285 <div align="right"><a href="#top">Up</a></div> |
|
286 <hr /> |
|
287 <hr /> |
|
288 <a NAME="patchArgumentStringWindows" ID="patchArgumentStringWindows"></a> |
|
289 <h2>patchArgumentStringWindows</h2> |
|
290 <b>patchArgumentStringWindows</b>(<i>debugClient, argStr</i>) |
|
291 |
|
292 <p> |
|
293 Function to patch an argument string for Windows. |
|
294 </p> |
|
295 <dl> |
|
296 |
|
297 <dt><i>debugClient</i> (DebugClient)</dt> |
|
298 <dd> |
|
299 reference to the debug client object |
|
300 </dd> |
|
301 <dt><i>argStr</i> (str)</dt> |
|
302 <dd> |
|
303 argument string |
|
304 </dd> |
|
305 </dl> |
|
306 <dl> |
|
307 <dt>Return:</dt> |
|
308 <dd> |
|
309 patched argument string |
|
310 </dd> |
|
311 </dl> |
|
312 <dl> |
|
313 <dt>Return Type:</dt> |
|
314 <dd> |
|
315 str |
|
316 </dd> |
|
317 </dl> |
|
318 <div align="right"><a href="#top">Up</a></div> |
|
319 <hr /> |
|
320 <hr /> |
|
321 <a NAME="patchArguments" ID="patchArguments"></a> |
|
322 <h2>patchArguments</h2> |
|
323 <b>patchArguments</b>(<i>debugClient, arguments, noRedirect=False</i>) |
|
324 |
|
325 <p> |
|
326 Function to patch the arguments given to start a program in order to |
|
327 execute it in our debugger. |
|
328 </p> |
|
329 <dl> |
|
330 |
|
331 <dt><i>debugClient</i> (DebugClient)</dt> |
|
332 <dd> |
|
333 reference to the debug client object |
|
334 </dd> |
|
335 <dt><i>arguments</i> (list of str)</dt> |
|
336 <dd> |
|
337 list of program arguments |
|
338 </dd> |
|
339 <dt><i>noRedirect</i> (bool)</dt> |
|
340 <dd> |
|
341 flag indicating to not redirect stdin and stdout |
|
342 </dd> |
|
343 </dl> |
|
344 <dl> |
|
345 <dt>Return:</dt> |
|
346 <dd> |
|
347 modified argument list |
|
348 </dd> |
|
349 </dl> |
|
350 <dl> |
|
351 <dt>Return Type:</dt> |
|
352 <dd> |
|
353 list of str |
|
354 </dd> |
|
355 </dl> |
|
356 <div align="right"><a href="#top">Up</a></div> |
|
357 <hr /> |
|
358 <hr /> |
|
359 <a NAME="prepareJsonCommand" ID="prepareJsonCommand"></a> |
|
360 <h2>prepareJsonCommand</h2> |
|
361 <b>prepareJsonCommand</b>(<i>method, params</i>) |
|
362 |
|
363 <p> |
|
364 Function to prepare a single command or response for transmission to |
|
365 the IDE. |
|
366 </p> |
|
367 <dl> |
|
368 |
|
369 <dt><i>method</i> (str)</dt> |
|
370 <dd> |
|
371 command or response name to be sent |
|
372 </dd> |
|
373 <dt><i>params</i> (dict)</dt> |
|
374 <dd> |
|
375 dictionary of named parameters for the command or response |
|
376 </dd> |
|
377 </dl> |
|
378 <dl> |
|
379 <dt>Return:</dt> |
|
380 <dd> |
|
381 prepared JSON command or response string |
|
382 </dd> |
|
383 </dl> |
|
384 <dl> |
|
385 <dt>Return Type:</dt> |
|
386 <dd> |
|
387 str |
|
388 </dd> |
|
389 </dl> |
|
390 <div align="right"><a href="#top">Up</a></div> |
|
391 <hr /> |
|
392 <hr /> |
|
393 <a NAME="quoteArgs" ID="quoteArgs"></a> |
|
394 <h2>quoteArgs</h2> |
|
395 <b>quoteArgs</b>(<i>args</i>) |
|
396 |
|
397 <p> |
|
398 Function to quote the given list of arguments. |
|
399 </p> |
|
400 <dl> |
|
401 |
|
402 <dt><i>args</i> (list of str)</dt> |
|
403 <dd> |
|
404 list of arguments to be quoted |
|
405 </dd> |
|
406 </dl> |
|
407 <dl> |
|
408 <dt>Return:</dt> |
|
409 <dd> |
|
410 list of quoted arguments |
|
411 </dd> |
|
412 </dl> |
|
413 <dl> |
|
414 <dt>Return Type:</dt> |
|
415 <dd> |
|
416 list of str |
|
417 </dd> |
|
418 </dl> |
|
419 <div align="right"><a href="#top">Up</a></div> |
|
420 <hr /> |
|
421 <hr /> |
|
422 <a NAME="removeQuotesFromArgs" ID="removeQuotesFromArgs"></a> |
|
423 <h2>removeQuotesFromArgs</h2> |
|
424 <b>removeQuotesFromArgs</b>(<i>args</i>) |
|
425 |
|
426 <p> |
|
427 Function to remove quotes from the arguments list. |
|
428 </p> |
|
429 <dl> |
|
430 |
|
431 <dt><i>args</i> (list of str)</dt> |
|
432 <dd> |
|
433 list of arguments |
|
434 </dd> |
|
435 </dl> |
|
436 <dl> |
|
437 <dt>Return:</dt> |
|
438 <dd> |
|
439 list of unquoted strings |
|
440 </dd> |
|
441 </dl> |
|
442 <dl> |
|
443 <dt>Return Type:</dt> |
|
444 <dd> |
|
445 list of str |
|
446 </dd> |
|
447 </dl> |
|
448 <div align="right"><a href="#top">Up</a></div> |
|
449 <hr /> |
|
450 <hr /> |
|
451 <a NAME="startsWithShebang" ID="startsWithShebang"></a> |
|
452 <h2>startsWithShebang</h2> |
|
453 <b>startsWithShebang</b>(<i>program</i>) |
|
454 |
|
455 <p> |
|
456 Function to check, if the given program start with a Shebang line. |
|
457 </p> |
|
458 <dl> |
|
459 |
|
460 <dt><i>program</i> (str)</dt> |
|
461 <dd> |
|
462 program path to be checked |
|
463 </dd> |
|
464 </dl> |
|
465 <dl> |
|
466 <dt>Return:</dt> |
|
467 <dd> |
|
468 flag indicating an existing and valid shebang line |
|
469 </dd> |
|
470 </dl> |
|
471 <dl> |
|
472 <dt>Return Type:</dt> |
|
473 <dd> |
|
474 bool |
|
475 </dd> |
|
476 </dl> |
|
477 <div align="right"><a href="#top">Up</a></div> |
|
478 <hr /> |
|
479 <hr /> |
|
480 <a NAME="stringToArgumentsWindows" ID="stringToArgumentsWindows"></a> |
|
481 <h2>stringToArgumentsWindows</h2> |
|
482 <b>stringToArgumentsWindows</b>(<i>args</i>) |
|
483 |
|
484 <p> |
|
485 Function to prepare a string of arguments for Windows platform. |
|
486 </p> |
|
487 <dl> |
|
488 |
|
489 <dt><i>args</i> (str)</dt> |
|
490 <dd> |
|
491 list of command arguments |
|
492 </dd> |
|
493 </dl> |
|
494 <dl> |
|
495 <dt>Return:</dt> |
|
496 <dd> |
|
497 list of command arguments |
|
498 </dd> |
|
499 </dl> |
|
500 <dl> |
|
501 <dt>Return Type:</dt> |
|
502 <dd> |
|
503 list of str |
|
504 </dd> |
|
505 </dl> |
|
506 <dl> |
|
507 |
|
508 <dt>Raises <b>RuntimeError</b>:</dt> |
|
509 <dd> |
|
510 raised to indicate an illegal arguments parsing |
|
511 condition |
|
512 </dd> |
|
513 </dl> |
|
514 <div align="right"><a href="#top">Up</a></div> |
|
515 <hr /> |
|
516 </body></html> |