1 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN"
2 "http://www.w3.org/TR/html40/loose.dtd">
7 <title>HappyDoc Generated Documentation
</title>
10 <body bgcolor=
"#ffffff">
13 <table border=
"0" cellpadding=
"5" cellspacing=
"0" width=
"100%">
19 bgcolor=
"#88bbee"><font color=
"#000000">HappyDoc Generated Documentation
</font>
23 align=
"right"><font color=
"#000000">Class: ConfigFile
</font>
30 /
<a href=
"../wifi-radar.html">wifi-radar.py
</a> /
ConfigFile
</small></p>
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%">
44 <font color=
"#000000">
45 <a name=
"">Methods
</a>
53 <font color=
"#000000"> </font>
58 <table border=
"0" cellpadding=
"5" cellspacing=
"0" width=
"100%">
67 <font color=
"#000000">
68 <a name=
"set_opt"></a>
76 <font color=
"#000000">set_opt
</font>
89 <p>Set a config option while handling exceptions.
</p>
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>
101 </table><table border=
"0" cellpadding=
"5" cellspacing=
"0" width=
"100%">
104 <th bgcolor=
"#99ccff"
110 <font color=
"#000000">
111 <a name=
"get_opt"></a>
114 <th bgcolor=
"#99ccff"
119 <font color=
"#000000">get_opt
</font>
125 get_opt ( self, option_path )
128 <p>Get a config option and handle exceptions.
</p>
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>
136 <p> string or None - option value as string or None on failure
</p>
138 </table><table border=
"0" cellpadding=
"5" cellspacing=
"0" width=
"100%">
141 <th bgcolor=
"#99ccff"
147 <font color=
"#000000">
148 <a name=
"set_section"></a>
151 <th bgcolor=
"#99ccff"
156 <font color=
"#000000">set_section
</font>
169 <p>Set the contents of a section to values from a dictionary.
</p>
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>
180 </table><table border=
"0" cellpadding=
"5" cellspacing=
"0" width=
"100%">
183 <th bgcolor=
"#99ccff"
189 <font color=
"#000000">
190 <a name=
"set_float_opt"></a>
193 <th bgcolor=
"#99ccff"
198 <font color=
"#000000">set_float_opt
</font>
211 <p>Convert float type to string and set config option.
</p>
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>
222 <table border=
"0" cellpadding=
"5" cellspacing=
"0" width=
"100%">
225 <th bgcolor=
"#99ccff"
231 <font color=
"#000000">
232 <a name=
"">Exceptions
</a>
235 <th bgcolor=
"#99ccff"
240 <font color=
"#000000"> </font>
246 ValueError, 'value is not a float'
<br>
250 </table><table border=
"0" cellpadding=
"5" cellspacing=
"0" width=
"100%">
253 <th bgcolor=
"#99ccff"
259 <font color=
"#000000">
260 <a name=
"set_int_opt"></a>
263 <th bgcolor=
"#99ccff"
268 <font color=
"#000000">set_int_opt
</font>
281 <p>Convert integer type to string and set config option.
</p>
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>
292 <table border=
"0" cellpadding=
"5" cellspacing=
"0" width=
"100%">
295 <th bgcolor=
"#99ccff"
301 <font color=
"#000000">
302 <a name=
"">Exceptions
</a>
305 <th bgcolor=
"#99ccff"
310 <font color=
"#000000"> </font>
316 ValueError, 'value is not an integer'
<br>
320 </table><table border=
"0" cellpadding=
"5" cellspacing=
"0" width=
"100%">
323 <th bgcolor=
"#99ccff"
329 <font color=
"#000000">
330 <a name=
"profiles"></a>
333 <th bgcolor=
"#99ccff"
338 <font color=
"#000000">profiles
</font>
347 <p>Return a list of the section names which denote AP profiles.
</p>
351 <p> list - profile names
</p>
353 </table><table border=
"0" cellpadding=
"5" cellspacing=
"0" width=
"100%">
356 <th bgcolor=
"#99ccff"
362 <font color=
"#000000">
363 <a name=
"write"></a>
366 <th bgcolor=
"#99ccff"
371 <font color=
"#000000">write
</font>
380 <p>Write configuration file to disk from instance variables. Copied from
381 ConfigParser and modified to write options in alphabetical order.
</p>
387 </table><table border=
"0" cellpadding=
"5" cellspacing=
"0" width=
"100%">
390 <th bgcolor=
"#99ccff"
396 <font color=
"#000000">
397 <a name=
"set_bool_opt"></a>
400 <th bgcolor=
"#99ccff"
405 <font color=
"#000000">set_bool_opt
</font>
418 <p>Convert boolean type to string and set config option.
</p>
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>
429 <table border=
"0" cellpadding=
"5" cellspacing=
"0" width=
"100%">
432 <th bgcolor=
"#99ccff"
438 <font color=
"#000000">
439 <a name=
"">Exceptions
</a>
442 <th bgcolor=
"#99ccff"
447 <font color=
"#000000"> </font>
453 ValueError, 'cannot convert value to string'
<br>
457 </table><table border=
"0" cellpadding=
"5" cellspacing=
"0" width=
"100%">
460 <th bgcolor=
"#99ccff"
466 <font color=
"#000000">
467 <a name=
"read"></a>
470 <th bgcolor=
"#99ccff"
475 <font color=
"#000000">read
</font>
484 <p>Read configuration file from disk into instance variables.
</p>
490 </table><table border=
"0" cellpadding=
"5" cellspacing=
"0" width=
"100%">
493 <th bgcolor=
"#99ccff"
499 <font color=
"#000000">
500 <a name=
"get_opt_as_bool"></a>
503 <th bgcolor=
"#99ccff"
508 <font color=
"#000000">get_opt_as_bool
</font>
514 get_opt_as_bool ( self, option_path )
517 <p>Get a config option and return as a boolean type.
</p>
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>
525 <p> boolean - option value as boolean
</p>
526 <table border=
"0" cellpadding=
"5" cellspacing=
"0" width=
"100%">
529 <th bgcolor=
"#99ccff"
535 <font color=
"#000000">
536 <a name=
"">Exceptions
</a>
539 <th bgcolor=
"#99ccff"
544 <font color=
"#000000"> </font>
550 ValueError, 'boolean option was not True or False'
<br>
554 </table><table border=
"0" cellpadding=
"5" cellspacing=
"0" width=
"100%">
557 <th bgcolor=
"#99ccff"
563 <font color=
"#000000">
564 <a name=
"get_opt_as_int"></a>
567 <th bgcolor=
"#99ccff"
572 <font color=
"#000000">get_opt_as_int
</font>
578 get_opt_as_int ( self, option_path )
581 <p>Get a config option and return as an integer type.
</p>
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>
589 <p> integer- option value as integer
</p>
591 </table><table border=
"0" cellpadding=
"5" cellspacing=
"0" width=
"100%">
594 <th bgcolor=
"#99ccff"
600 <font color=
"#000000">
601 <a name=
"__init__"></a>
604 <th bgcolor=
"#99ccff"
609 <font color=
"#000000">__init__
</font>
623 <p>Create a new ConfigFile.
</p>
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>
632 <p> ConfigFile instance
</p>
634 </table><table border=
"0" cellpadding=
"5" cellspacing=
"0" width=
"100%">
637 <th bgcolor=
"#99ccff"
643 <font color=
"#000000">
644 <a name=
"get_profile"></a>
647 <th bgcolor=
"#99ccff"
652 <font color=
"#000000">get_profile
</font>
658 get_profile ( self, section_name )
661 <p>Return the profile recorded in the specified section.
</p>
664 <dt> <code>section_name
</code></dt>
665 <dd>string - Configuration file section.
</dd>
668 <p> dictionary or None - The specified profile or None if not found
</p>
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