Update developer docs
[wifi-radar.git] / docs / developer / wifi-radar.py / ConfigFile.html
blob64c687a9837d7d33599cd1a483ed92602ce32246
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2 "http://www.w3.org/TR/html40/loose.dtd">
4 <html>
6 <head>
7 <title>HappyDoc Generated Documentation</title>
8 </head>
10 <body bgcolor="#ffffff">
13 <table border="0" cellpadding="5" cellspacing="0" width="100%">
14 <tr>
15 <th rowspan="2"
16 valign="top"
17 align="left"
18 width="10%"
19 bgcolor="#88bbee"><font color="#000000">HappyDoc Generated Documentation</font>
20 </th>
21 <th bgcolor="#88bbee"
22 width="90%"
23 align="right"><font color="#000000">Class: ConfigFile</font>
24 </th>
25 </tr>
26 <tr>
27 <td>
28 <!-- breadcrumbs -->
29 <p><small>
30 /&nbsp;<a href="../wifi-radar.html">wifi-radar.py</a>&nbsp;/&nbsp;ConfigFile&nbsp;</small></p>
32 <!-- /breadcrumbs -->
34 <p>Manage the configuration for the application, including reading and writing the config from/to a file.</p>
35 <table border="0" cellpadding="5" cellspacing="0" width="100%">
37 <tr>
38 <th bgcolor="#99ccff"
39 rowspan="2"
40 valign="top"
41 align="left"
42 width="20%"
44 <font color="#000000">
45 <a name="">Methods</a>&nbsp;
46 </font>
47 </th>
48 <th bgcolor="#99ccff"
49 valign="top"
50 align="left"
51 width="80%"
53 <font color="#000000">&nbsp;</font>
54 </th>
55 </tr>
56 <tr>
57 <td>
58 <table border="0" cellpadding="5" cellspacing="0" width="100%">
60 <tr>
61 <th bgcolor="#99ccff"
62 rowspan="2"
63 valign="top"
64 align="left"
65 width="20%"
67 <font color="#000000">
68 <a name="set_opt"></a>&nbsp;
69 </font>
70 </th>
71 <th bgcolor="#99ccff"
72 valign="top"
73 align="left"
74 width="80%"
76 <font color="#000000">set_opt&nbsp;</font>
77 </th>
78 </tr>
79 <tr>
80 <td>
81 <pre>
82 set_opt (
83 self,
84 option_path,
85 value,
87 </pre>
89 <p>Set a config option while handling exceptions.</p>
90 <h4>Parameters:</h4>
91 <dl>
92 <dt> <code>option_path</code></dt>
93 <dd>string - Section (a.k.a. profile) name concatenated with a
94 period and the option key. (E.g. "DEFAULT.interface")</dd>
95 <dt> <code>value</code></dt>
96 <dd>string - Value to set.</dd>
97 </dl>
98 <h4>Returns:</h4>
99 <p> nothing</p>
100 </td></tr>
101 </table><table border="0" cellpadding="5" cellspacing="0" width="100%">
103 <tr>
104 <th bgcolor="#99ccff"
105 rowspan="2"
106 valign="top"
107 align="left"
108 width="20%"
110 <font color="#000000">
111 <a name="get_opt"></a>&nbsp;
112 </font>
113 </th>
114 <th bgcolor="#99ccff"
115 valign="top"
116 align="left"
117 width="80%"
119 <font color="#000000">get_opt&nbsp;</font>
120 </th>
121 </tr>
122 <tr>
123 <td>
124 <pre>
125 get_opt ( self, option_path )
126 </pre>
128 <p>Get a config option and handle exceptions.</p>
129 <h4>Parameters:</h4>
130 <dl>
131 <dt> <code>option_path</code></dt>
132 <dd>string - Section (a.k.a. profile) name concatenated with a
133 period and the option key. (E.g. "DEFAULT.interface")</dd>
134 </dl>
135 <h4>Returns:</h4>
136 <p> string or None - option value as string or None on failure</p>
137 </td></tr>
138 </table><table border="0" cellpadding="5" cellspacing="0" width="100%">
140 <tr>
141 <th bgcolor="#99ccff"
142 rowspan="2"
143 valign="top"
144 align="left"
145 width="20%"
147 <font color="#000000">
148 <a name="set_section"></a>&nbsp;
149 </font>
150 </th>
151 <th bgcolor="#99ccff"
152 valign="top"
153 align="left"
154 width="80%"
156 <font color="#000000">set_section&nbsp;</font>
157 </th>
158 </tr>
159 <tr>
160 <td>
161 <pre>
162 set_section (
163 self,
164 section_name,
165 section_dict,
167 </pre>
169 <p>Set the contents of a section to values from a dictionary.</p>
170 <h4>Parameters:</h4>
171 <dl>
172 <dt> <code>section_name</code></dt>
173 <dd>string - Configuration file section.</dd>
174 <dt> <code>section_dict</code></dt>
175 <dd>dictionary - Values to add to section.</dd>
176 </dl>
177 <h4>Returns:</h4>
178 <p> nothing</p>
179 </td></tr>
180 </table><table border="0" cellpadding="5" cellspacing="0" width="100%">
182 <tr>
183 <th bgcolor="#99ccff"
184 rowspan="2"
185 valign="top"
186 align="left"
187 width="20%"
189 <font color="#000000">
190 <a name="set_float_opt"></a>&nbsp;
191 </font>
192 </th>
193 <th bgcolor="#99ccff"
194 valign="top"
195 align="left"
196 width="80%"
198 <font color="#000000">set_float_opt&nbsp;</font>
199 </th>
200 </tr>
201 <tr>
202 <td>
203 <pre>
204 set_float_opt (
205 self,
206 option_path,
207 value,
209 </pre>
211 <p>Convert float type to string and set config option.</p>
212 <h4>Parameters:</h4>
213 <dl>
214 <dt> <code>option_path</code></dt>
215 <dd>string - Section (a.k.a. profile) name concatenated with a
216 period and the option key. (E.g. "DEFAULT.interface")</dd>
217 <dt> <code>value</code></dt>
218 <dd>float - Value to set.</dd>
219 </dl>
220 <h4>Returns:</h4>
221 <p> nothing</p>
222 <table border="0" cellpadding="5" cellspacing="0" width="100%">
224 <tr>
225 <th bgcolor="#99ccff"
226 rowspan="2"
227 valign="top"
228 align="left"
229 width="20%"
231 <font color="#000000">
232 <a name="">Exceptions</a>&nbsp;
233 </font>
234 </th>
235 <th bgcolor="#99ccff"
236 valign="top"
237 align="left"
238 width="80%"
240 <font color="#000000">&nbsp;</font>
241 </th>
242 </tr>
243 <tr>
244 <td>
246 ValueError, 'value is not a float'<br>
247 </p>
248 </td></tr>
249 </table></td></tr>
250 </table><table border="0" cellpadding="5" cellspacing="0" width="100%">
252 <tr>
253 <th bgcolor="#99ccff"
254 rowspan="2"
255 valign="top"
256 align="left"
257 width="20%"
259 <font color="#000000">
260 <a name="set_int_opt"></a>&nbsp;
261 </font>
262 </th>
263 <th bgcolor="#99ccff"
264 valign="top"
265 align="left"
266 width="80%"
268 <font color="#000000">set_int_opt&nbsp;</font>
269 </th>
270 </tr>
271 <tr>
272 <td>
273 <pre>
274 set_int_opt (
275 self,
276 option_path,
277 value,
279 </pre>
281 <p>Convert integer type to string and set config option.</p>
282 <h4>Parameters:</h4>
283 <dl>
284 <dt> <code>option_path</code></dt>
285 <dd>string - Section (a.k.a. profile) name concatenated with a
286 period and the option key. (E.g. "DEFAULT.interface")</dd>
287 <dt> <code>value</code></dt>
288 <dd>integer - Value to set.</dd>
289 </dl>
290 <h4>Returns:</h4>
291 <p> nothing</p>
292 <table border="0" cellpadding="5" cellspacing="0" width="100%">
294 <tr>
295 <th bgcolor="#99ccff"
296 rowspan="2"
297 valign="top"
298 align="left"
299 width="20%"
301 <font color="#000000">
302 <a name="">Exceptions</a>&nbsp;
303 </font>
304 </th>
305 <th bgcolor="#99ccff"
306 valign="top"
307 align="left"
308 width="80%"
310 <font color="#000000">&nbsp;</font>
311 </th>
312 </tr>
313 <tr>
314 <td>
316 ValueError, 'value is not an integer'<br>
317 </p>
318 </td></tr>
319 </table></td></tr>
320 </table><table border="0" cellpadding="5" cellspacing="0" width="100%">
322 <tr>
323 <th bgcolor="#99ccff"
324 rowspan="2"
325 valign="top"
326 align="left"
327 width="20%"
329 <font color="#000000">
330 <a name="profiles"></a>&nbsp;
331 </font>
332 </th>
333 <th bgcolor="#99ccff"
334 valign="top"
335 align="left"
336 width="80%"
338 <font color="#000000">profiles&nbsp;</font>
339 </th>
340 </tr>
341 <tr>
342 <td>
343 <pre>
344 profiles ( self )
345 </pre>
347 <p>Return a list of the section names which denote AP profiles.</p>
348 <h4>Parameters:</h4>
349 <p> nothing</p>
350 <h4>Returns:</h4>
351 <p> list - profile names</p>
352 </td></tr>
353 </table><table border="0" cellpadding="5" cellspacing="0" width="100%">
355 <tr>
356 <th bgcolor="#99ccff"
357 rowspan="2"
358 valign="top"
359 align="left"
360 width="20%"
362 <font color="#000000">
363 <a name="write"></a>&nbsp;
364 </font>
365 </th>
366 <th bgcolor="#99ccff"
367 valign="top"
368 align="left"
369 width="80%"
371 <font color="#000000">write&nbsp;</font>
372 </th>
373 </tr>
374 <tr>
375 <td>
376 <pre>
377 write ( self )
378 </pre>
380 <p>Write configuration file to disk from instance variables. Copied from
381 ConfigParser and modified to write options in alphabetical order.</p>
382 <h4>Parameters:</h4>
383 <p> nothing</p>
384 <h4>Returns:</h4>
385 <p> nothing</p>
386 </td></tr>
387 </table><table border="0" cellpadding="5" cellspacing="0" width="100%">
389 <tr>
390 <th bgcolor="#99ccff"
391 rowspan="2"
392 valign="top"
393 align="left"
394 width="20%"
396 <font color="#000000">
397 <a name="set_bool_opt"></a>&nbsp;
398 </font>
399 </th>
400 <th bgcolor="#99ccff"
401 valign="top"
402 align="left"
403 width="80%"
405 <font color="#000000">set_bool_opt&nbsp;</font>
406 </th>
407 </tr>
408 <tr>
409 <td>
410 <pre>
411 set_bool_opt (
412 self,
413 option_path,
414 value,
416 </pre>
418 <p>Convert boolean type to string and set config option.</p>
419 <h4>Parameters:</h4>
420 <dl>
421 <dt> <code>option_path</code></dt>
422 <dd>string - Section (a.k.a. profile) name concatenated with a
423 period and the option key. (E.g. "DEFAULT.interface")</dd>
424 <dt> <code>value</code></dt>
425 <dd>boolean - Value to set.</dd>
426 </dl>
427 <h4>Returns:</h4>
428 <p> nothing</p>
429 <table border="0" cellpadding="5" cellspacing="0" width="100%">
431 <tr>
432 <th bgcolor="#99ccff"
433 rowspan="2"
434 valign="top"
435 align="left"
436 width="20%"
438 <font color="#000000">
439 <a name="">Exceptions</a>&nbsp;
440 </font>
441 </th>
442 <th bgcolor="#99ccff"
443 valign="top"
444 align="left"
445 width="80%"
447 <font color="#000000">&nbsp;</font>
448 </th>
449 </tr>
450 <tr>
451 <td>
453 ValueError, 'cannot convert value to string'<br>
454 </p>
455 </td></tr>
456 </table></td></tr>
457 </table><table border="0" cellpadding="5" cellspacing="0" width="100%">
459 <tr>
460 <th bgcolor="#99ccff"
461 rowspan="2"
462 valign="top"
463 align="left"
464 width="20%"
466 <font color="#000000">
467 <a name="read"></a>&nbsp;
468 </font>
469 </th>
470 <th bgcolor="#99ccff"
471 valign="top"
472 align="left"
473 width="80%"
475 <font color="#000000">read&nbsp;</font>
476 </th>
477 </tr>
478 <tr>
479 <td>
480 <pre>
481 read ( self )
482 </pre>
484 <p>Read configuration file from disk into instance variables.</p>
485 <h4>Parameters:</h4>
486 <p> nothing</p>
487 <h4>Returns:</h4>
488 <p> nothing</p>
489 </td></tr>
490 </table><table border="0" cellpadding="5" cellspacing="0" width="100%">
492 <tr>
493 <th bgcolor="#99ccff"
494 rowspan="2"
495 valign="top"
496 align="left"
497 width="20%"
499 <font color="#000000">
500 <a name="get_opt_as_bool"></a>&nbsp;
501 </font>
502 </th>
503 <th bgcolor="#99ccff"
504 valign="top"
505 align="left"
506 width="80%"
508 <font color="#000000">get_opt_as_bool&nbsp;</font>
509 </th>
510 </tr>
511 <tr>
512 <td>
513 <pre>
514 get_opt_as_bool ( self, option_path )
515 </pre>
517 <p>Get a config option and return as a boolean type.</p>
518 <h4>Parameters:</h4>
519 <dl>
520 <dt> <code>option_path</code></dt>
521 <dd>string - Section (a.k.a. profile) name concatenated with a
522 period and the option key. (E.g. "DEFAULT.interface")</dd>
523 </dl>
524 <h4>Returns:</h4>
525 <p> boolean - option value as boolean</p>
526 <table border="0" cellpadding="5" cellspacing="0" width="100%">
528 <tr>
529 <th bgcolor="#99ccff"
530 rowspan="2"
531 valign="top"
532 align="left"
533 width="20%"
535 <font color="#000000">
536 <a name="">Exceptions</a>&nbsp;
537 </font>
538 </th>
539 <th bgcolor="#99ccff"
540 valign="top"
541 align="left"
542 width="80%"
544 <font color="#000000">&nbsp;</font>
545 </th>
546 </tr>
547 <tr>
548 <td>
550 ValueError, 'boolean option was not True or False'<br>
551 </p>
552 </td></tr>
553 </table></td></tr>
554 </table><table border="0" cellpadding="5" cellspacing="0" width="100%">
556 <tr>
557 <th bgcolor="#99ccff"
558 rowspan="2"
559 valign="top"
560 align="left"
561 width="20%"
563 <font color="#000000">
564 <a name="get_opt_as_int"></a>&nbsp;
565 </font>
566 </th>
567 <th bgcolor="#99ccff"
568 valign="top"
569 align="left"
570 width="80%"
572 <font color="#000000">get_opt_as_int&nbsp;</font>
573 </th>
574 </tr>
575 <tr>
576 <td>
577 <pre>
578 get_opt_as_int ( self, option_path )
579 </pre>
581 <p>Get a config option and return as an integer type.</p>
582 <h4>Parameters:</h4>
583 <dl>
584 <dt> <code>option_path</code></dt>
585 <dd>string - Section (a.k.a. profile) name concatenated with a
586 period and the option key. (E.g. "DEFAULT.interface")</dd>
587 </dl>
588 <h4>Returns:</h4>
589 <p> integer- option value as integer</p>
590 </td></tr>
591 </table><table border="0" cellpadding="5" cellspacing="0" width="100%">
593 <tr>
594 <th bgcolor="#99ccff"
595 rowspan="2"
596 valign="top"
597 align="left"
598 width="20%"
600 <font color="#000000">
601 <a name="__init__"></a>&nbsp;
602 </font>
603 </th>
604 <th bgcolor="#99ccff"
605 valign="top"
606 align="left"
607 width="80%"
609 <font color="#000000">__init__&nbsp;</font>
610 </th>
611 </tr>
612 <tr>
613 <td>
614 <pre>
615 __init__ (
616 self,
617 filename,
618 defaults,
619 raw=None,
621 </pre>
623 <p>Create a new ConfigFile.</p>
624 <h4>Parameters:</h4>
625 <dl>
626 <dt> <code>filename</code></dt>
627 <dd>string - The configuration file's name.</dd>
628 <dt> <code>defaults</code></dt>
629 <dd>dictionary - Default values for the DEFAULT section.</dd>
630 </dl>
631 <h4>Returns:</h4>
632 <p> ConfigFile instance</p>
633 </td></tr>
634 </table><table border="0" cellpadding="5" cellspacing="0" width="100%">
636 <tr>
637 <th bgcolor="#99ccff"
638 rowspan="2"
639 valign="top"
640 align="left"
641 width="20%"
643 <font color="#000000">
644 <a name="get_profile"></a>&nbsp;
645 </font>
646 </th>
647 <th bgcolor="#99ccff"
648 valign="top"
649 align="left"
650 width="80%"
652 <font color="#000000">get_profile&nbsp;</font>
653 </th>
654 </tr>
655 <tr>
656 <td>
657 <pre>
658 get_profile ( self, section_name )
659 </pre>
661 <p>Return the profile recorded in the specified section.</p>
662 <h4>Parameters:</h4>
663 <dl>
664 <dt> <code>section_name</code></dt>
665 <dd>string - Configuration file section.</dd>
666 </dl>
667 <h4>Returns:</h4>
668 <p> dictionary or None - The specified profile or None if not found</p>
669 </td></tr>
670 </table></td></tr>
671 </table>
672 </td>
673 </tr>
674 </table>
676 <hr>
678 <font size="-2"><i>This document was automatically generated
679 Sun Apr 19 14:31:33 2009 by <a
680 href="http://happydoc.sourceforge.net">HappyDoc</a> version
681 3.1</i></font>
683 </body>
684 </html>