<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html40/loose.dtd"> <html> <head> <title>HappyDoc Generated Documentation</title> </head> <body bgcolor="#ffffff"> <table border="0" cellpadding="5" cellspacing="0" width="100%"> <tr> <th rowspan="2" valign="top" align="left" width="10%" bgcolor="#88bbee"><font color="#000000">HappyDoc Generated Documentation</font> </th> <th bgcolor="#88bbee" width="90%" align="right"><font color="#000000">Class: ConfigFile</font> </th> </tr> <tr> <td> <!-- breadcrumbs --> <p><small> / <a href="../wifi-radar.html">wifi-radar.py</a> / ConfigFile </small></p> <!-- /breadcrumbs --> <p>Manage the configuration for the application, including reading and writing the config from/to a file.</p> <table border="0" cellpadding="5" cellspacing="0" width="100%"> <tr> <th bgcolor="#99ccff" rowspan="2" valign="top" align="left" width="20%" > <font color="#000000"> <a name="">Methods</a> </font> </th> <th bgcolor="#99ccff" valign="top" align="left" width="80%" > <font color="#000000"> </font> </th> </tr> <tr> <td> <table border="0" cellpadding="5" cellspacing="0" width="100%"> <tr> <th bgcolor="#99ccff" rowspan="2" valign="top" align="left" width="20%" > <font color="#000000"> <a name="set_opt"></a> </font> </th> <th bgcolor="#99ccff" valign="top" align="left" width="80%" > <font color="#000000">set_opt </font> </th> </tr> <tr> <td> <pre> set_opt ( self, option_path, value, ) </pre> <p>Set a config option while handling exceptions.</p> <h4>Parameters:</h4> <dl> <dt> <code>option_path</code></dt> <dd>string - Section (a.k.a. profile) name concatenated with a period and the option key. (E.g. "DEFAULT.interface")</dd> <dt> <code>value</code></dt> <dd>string - Value to set.</dd> </dl> <h4>Returns:</h4> <p> nothing</p> </td></tr> </table><table border="0" cellpadding="5" cellspacing="0" width="100%"> <tr> <th bgcolor="#99ccff" rowspan="2" valign="top" align="left" width="20%" > <font color="#000000"> <a name="get_opt"></a> </font> </th> <th bgcolor="#99ccff" valign="top" align="left" width="80%" > <font color="#000000">get_opt </font> </th> </tr> <tr> <td> <pre> get_opt ( self, option_path ) </pre> <p>Get a config option and handle exceptions.</p> <h4>Parameters:</h4> <dl> <dt> <code>option_path</code></dt> <dd>string - Section (a.k.a. profile) name concatenated with a period and the option key. (E.g. "DEFAULT.interface")</dd> </dl> <h4>Returns:</h4> <p> string or None - option value as string or None on failure</p> </td></tr> </table><table border="0" cellpadding="5" cellspacing="0" width="100%"> <tr> <th bgcolor="#99ccff" rowspan="2" valign="top" align="left" width="20%" > <font color="#000000"> <a name="set_section"></a> </font> </th> <th bgcolor="#99ccff" valign="top" align="left" width="80%" > <font color="#000000">set_section </font> </th> </tr> <tr> <td> <pre> set_section ( self, section_name, section_dict, ) </pre> <p>Set the contents of a section to values from a dictionary.</p> <h4>Parameters:</h4> <dl> <dt> <code>section_name</code></dt> <dd>string - Configuration file section.</dd> <dt> <code>section_dict</code></dt> <dd>dictionary - Values to add to section.</dd> </dl> <h4>Returns:</h4> <p> nothing</p> </td></tr> </table><table border="0" cellpadding="5" cellspacing="0" width="100%"> <tr> <th bgcolor="#99ccff" rowspan="2" valign="top" align="left" width="20%" > <font color="#000000"> <a name="set_float_opt"></a> </font> </th> <th bgcolor="#99ccff" valign="top" align="left" width="80%" > <font color="#000000">set_float_opt </font> </th> </tr> <tr> <td> <pre> set_float_opt ( self, option_path, value, ) </pre> <p>Convert float type to string and set config option.</p> <h4>Parameters:</h4> <dl> <dt> <code>option_path</code></dt> <dd>string - Section (a.k.a. profile) name concatenated with a period and the option key. (E.g. "DEFAULT.interface")</dd> <dt> <code>value</code></dt> <dd>float - Value to set.</dd> </dl> <h4>Returns:</h4> <p> nothing</p> <table border="0" cellpadding="5" cellspacing="0" width="100%"> <tr> <th bgcolor="#99ccff" rowspan="2" valign="top" align="left" width="20%" > <font color="#000000"> <a name="">Exceptions</a> </font> </th> <th bgcolor="#99ccff" valign="top" align="left" width="80%" > <font color="#000000"> </font> </th> </tr> <tr> <td> <p> ValueError, 'value is not a float'<br> </p> </td></tr> </table></td></tr> </table><table border="0" cellpadding="5" cellspacing="0" width="100%"> <tr> <th bgcolor="#99ccff" rowspan="2" valign="top" align="left" width="20%" > <font color="#000000"> <a name="set_int_opt"></a> </font> </th> <th bgcolor="#99ccff" valign="top" align="left" width="80%" > <font color="#000000">set_int_opt </font> </th> </tr> <tr> <td> <pre> set_int_opt ( self, option_path, value, ) </pre> <p>Convert integer type to string and set config option.</p> <h4>Parameters:</h4> <dl> <dt> <code>option_path</code></dt> <dd>string - Section (a.k.a. profile) name concatenated with a period and the option key. (E.g. "DEFAULT.interface")</dd> <dt> <code>value</code></dt> <dd>integer - Value to set.</dd> </dl> <h4>Returns:</h4> <p> nothing</p> <table border="0" cellpadding="5" cellspacing="0" width="100%"> <tr> <th bgcolor="#99ccff" rowspan="2" valign="top" align="left" width="20%" > <font color="#000000"> <a name="">Exceptions</a> </font> </th> <th bgcolor="#99ccff" valign="top" align="left" width="80%" > <font color="#000000"> </font> </th> </tr> <tr> <td> <p> ValueError, 'value is not an integer'<br> </p> </td></tr> </table></td></tr> </table><table border="0" cellpadding="5" cellspacing="0" width="100%"> <tr> <th bgcolor="#99ccff" rowspan="2" valign="top" align="left" width="20%" > <font color="#000000"> <a name="profiles"></a> </font> </th> <th bgcolor="#99ccff" valign="top" align="left" width="80%" > <font color="#000000">profiles </font> </th> </tr> <tr> <td> <pre> profiles ( self ) </pre> <p>Return a list of the section names which denote AP profiles.</p> <h4>Parameters:</h4> <p> nothing</p> <h4>Returns:</h4> <p> list - profile names</p> </td></tr> </table><table border="0" cellpadding="5" cellspacing="0" width="100%"> <tr> <th bgcolor="#99ccff" rowspan="2" valign="top" align="left" width="20%" > <font color="#000000"> <a name="write"></a> </font> </th> <th bgcolor="#99ccff" valign="top" align="left" width="80%" > <font color="#000000">write </font> </th> </tr> <tr> <td> <pre> write ( self ) </pre> <p>Write configuration file to disk from instance variables. Copied from ConfigParser and modified to write options in alphabetical order.</p> <h4>Parameters:</h4> <p> nothing</p> <h4>Returns:</h4> <p> nothing</p> </td></tr> </table><table border="0" cellpadding="5" cellspacing="0" width="100%"> <tr> <th bgcolor="#99ccff" rowspan="2" valign="top" align="left" width="20%" > <font color="#000000"> <a name="set_bool_opt"></a> </font> </th> <th bgcolor="#99ccff" valign="top" align="left" width="80%" > <font color="#000000">set_bool_opt </font> </th> </tr> <tr> <td> <pre> set_bool_opt ( self, option_path, value, ) </pre> <p>Convert boolean type to string and set config option.</p> <h4>Parameters:</h4> <dl> <dt> <code>option_path</code></dt> <dd>string - Section (a.k.a. profile) name concatenated with a period and the option key. (E.g. "DEFAULT.interface")</dd> <dt> <code>value</code></dt> <dd>boolean - Value to set.</dd> </dl> <h4>Returns:</h4> <p> nothing</p> <table border="0" cellpadding="5" cellspacing="0" width="100%"> <tr> <th bgcolor="#99ccff" rowspan="2" valign="top" align="left" width="20%" > <font color="#000000"> <a name="">Exceptions</a> </font> </th> <th bgcolor="#99ccff" valign="top" align="left" width="80%" > <font color="#000000"> </font> </th> </tr> <tr> <td> <p> ValueError, 'cannot convert value to string'<br> </p> </td></tr> </table></td></tr> </table><table border="0" cellpadding="5" cellspacing="0" width="100%"> <tr> <th bgcolor="#99ccff" rowspan="2" valign="top" align="left" width="20%" > <font color="#000000"> <a name="read"></a> </font> </th> <th bgcolor="#99ccff" valign="top" align="left" width="80%" > <font color="#000000">read </font> </th> </tr> <tr> <td> <pre> read ( self ) </pre> <p>Read configuration file from disk into instance variables.</p> <h4>Parameters:</h4> <p> nothing</p> <h4>Returns:</h4> <p> nothing</p> </td></tr> </table><table border="0" cellpadding="5" cellspacing="0" width="100%"> <tr> <th bgcolor="#99ccff" rowspan="2" valign="top" align="left" width="20%" > <font color="#000000"> <a name="get_opt_as_bool"></a> </font> </th> <th bgcolor="#99ccff" valign="top" align="left" width="80%" > <font color="#000000">get_opt_as_bool </font> </th> </tr> <tr> <td> <pre> get_opt_as_bool ( self, option_path ) </pre> <p>Get a config option and return as a boolean type.</p> <h4>Parameters:</h4> <dl> <dt> <code>option_path</code></dt> <dd>string - Section (a.k.a. profile) name concatenated with a period and the option key. (E.g. "DEFAULT.interface")</dd> </dl> <h4>Returns:</h4> <p> boolean - option value as boolean</p> <table border="0" cellpadding="5" cellspacing="0" width="100%"> <tr> <th bgcolor="#99ccff" rowspan="2" valign="top" align="left" width="20%" > <font color="#000000"> <a name="">Exceptions</a> </font> </th> <th bgcolor="#99ccff" valign="top" align="left" width="80%" > <font color="#000000"> </font> </th> </tr> <tr> <td> <p> ValueError, 'boolean option was not True or False'<br> </p> </td></tr> </table></td></tr> </table><table border="0" cellpadding="5" cellspacing="0" width="100%"> <tr> <th bgcolor="#99ccff" rowspan="2" valign="top" align="left" width="20%" > <font color="#000000"> <a name="get_opt_as_int"></a> </font> </th> <th bgcolor="#99ccff" valign="top" align="left" width="80%" > <font color="#000000">get_opt_as_int </font> </th> </tr> <tr> <td> <pre> get_opt_as_int ( self, option_path ) </pre> <p>Get a config option and return as an integer type.</p> <h4>Parameters:</h4> <dl> <dt> <code>option_path</code></dt> <dd>string - Section (a.k.a. profile) name concatenated with a period and the option key. (E.g. "DEFAULT.interface")</dd> </dl> <h4>Returns:</h4> <p> integer- option value as integer</p> </td></tr> </table><table border="0" cellpadding="5" cellspacing="0" width="100%"> <tr> <th bgcolor="#99ccff" rowspan="2" valign="top" align="left" width="20%" > <font color="#000000"> <a name="__init__"></a> </font> </th> <th bgcolor="#99ccff" valign="top" align="left" width="80%" > <font color="#000000">__init__ </font> </th> </tr> <tr> <td> <pre> __init__ ( self, filename, defaults, raw=None, ) </pre> <p>Create a new ConfigFile.</p> <h4>Parameters:</h4> <dl> <dt> <code>filename</code></dt> <dd>string - The configuration file's name.</dd> <dt> <code>defaults</code></dt> <dd>dictionary - Default values for the DEFAULT section.</dd> </dl> <h4>Returns:</h4> <p> ConfigFile instance</p> </td></tr> </table><table border="0" cellpadding="5" cellspacing="0" width="100%"> <tr> <th bgcolor="#99ccff" rowspan="2" valign="top" align="left" width="20%" > <font color="#000000"> <a name="get_profile"></a> </font> </th> <th bgcolor="#99ccff" valign="top" align="left" width="80%" > <font color="#000000">get_profile </font> </th> </tr> <tr> <td> <pre> get_profile ( self, section_name ) </pre> <p>Return the profile recorded in the specified section.</p> <h4>Parameters:</h4> <dl> <dt> <code>section_name</code></dt> <dd>string - Configuration file section.</dd> </dl> <h4>Returns:</h4> <p> dictionary or None - The specified profile or None if not found</p> </td></tr> </table></td></tr> </table> </td> </tr> </table> <hr> <font size="-2"><i>This document was automatically generated Thu May 21 05:32:36 2009 by <a href="http://happydoc.sourceforge.net">HappyDoc</a> version 3.1</i></font> </body> </html>