comparison commons/pyRepetUnit/doc/commons.Checker-pysrc.html @ 31:0ab839023fe4

Uploaded
author m-zytnicki
date Tue, 30 Apr 2013 14:33:21 -0400
parents 94ab73e8a190
children
comparison
equal deleted inserted replaced
30:5677346472b5 31:0ab839023fe4
1 <?xml version="1.0" encoding="ascii"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3 "DTD/xhtml1-transitional.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5 <head>
6 <title>commons.Checker</title>
7 <link rel="stylesheet" href="epydoc.css" type="text/css" />
8 <script type="text/javascript" src="epydoc.js"></script>
9 </head>
10
11 <body bgcolor="white" text="black" link="blue" vlink="#204080"
12 alink="#204080">
13 <!-- ==================== NAVIGATION BAR ==================== -->
14 <table class="navbar" border="0" width="100%" cellpadding="0"
15 bgcolor="#a0c0ff" cellspacing="0">
16 <tr valign="middle">
17
18 <!-- Tree link -->
19 <th>&nbsp;&nbsp;&nbsp;<a
20 href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
21
22 <!-- Index link -->
23 <th>&nbsp;&nbsp;&nbsp;<a
24 href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>
25
26 <!-- Help link -->
27 <th>&nbsp;&nbsp;&nbsp;<a
28 href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
29
30 <th class="navbar" width="100%"></th>
31 </tr>
32 </table>
33 <table width="100%" cellpadding="0" cellspacing="0">
34 <tr valign="top">
35 <td width="100%">
36 <span class="breadcrumbs">
37 Package&nbsp;commons ::
38 Module&nbsp;Checker
39 </span>
40 </td>
41 <td>
42 <table cellpadding="0" cellspacing="0">
43 <!-- hide/show private -->
44 <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
45 onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
46 <tr><td align="right"><span class="options"
47 >[<a href="frames.html" target="_top">frames</a
48 >]&nbsp;|&nbsp;<a href="commons.Checker-pysrc.html"
49 target="_top">no&nbsp;frames</a>]</span></td></tr>
50 </table>
51 </td>
52 </tr>
53 </table>
54 <h1 class="epydoc">Source Code for <a href="commons.Checker-module.html">Module commons.Checker</a></h1>
55 <pre class="py-src">
56 <a name="L1"></a><tt class="py-lineno"> 1</tt> <tt class="py-line"><tt class="py-docstring">'''</tt> </tt>
57 <a name="L2"></a><tt class="py-lineno"> 2</tt> <tt class="py-line"><tt class="py-docstring">Created on 9 avr. 2009</tt> </tt>
58 <a name="L3"></a><tt class="py-lineno"> 3</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
59 <a name="L4"></a><tt class="py-lineno"> 4</tt> <tt class="py-line"><tt class="py-docstring">@author: oinizan</tt> </tt>
60 <a name="L5"></a><tt class="py-lineno"> 5</tt> <tt class="py-line"><tt class="py-docstring">'''</tt> </tt>
61 <a name="L6"></a><tt class="py-lineno"> 6</tt> <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">logging</tt><tt class="py-op">.</tt><tt class="py-name">config</tt> </tt>
62 <a name="L7"></a><tt class="py-lineno"> 7</tt> <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">ConfigParser</tt> </tt>
63 <a name="L8"></a><tt class="py-lineno"> 8</tt> <tt class="py-line"><tt class="py-keyword">from</tt> <tt class="py-name">ConfigParser</tt> <tt class="py-keyword">import</tt> <tt class="py-name">NoSectionError</tt> </tt>
64 <a name="L9"></a><tt class="py-lineno"> 9</tt> <tt class="py-line"><tt class="py-keyword">from</tt> <tt class="py-name">ConfigParser</tt> <tt class="py-keyword">import</tt> <tt class="py-name">NoOptionError</tt> </tt>
65 <a name="L10"></a><tt class="py-lineno"> 10</tt> <tt class="py-line"> </tt>
66 <a name="L11"></a><tt class="py-lineno"> 11</tt> <tt class="py-line"><tt id="link-0" class="py-name" targets="Variable commons.Checker.LOG_FILE=commons.Checker-module.html#LOG_FILE"><a title="commons.Checker.LOG_FILE" class="py-name" href="#" onclick="return doclink('link-0', 'LOG_FILE', 'link-0');">LOG_FILE</a></tt> <tt class="py-op">=</tt> <tt class="py-string">"/home/oinizan/workspace/repet_pipe/pyRepetUnit/blaster/check/longconf.ini"</tt> </tt>
67 <a name="L12"></a><tt class="py-lineno"> 12</tt> <tt class="py-line"><tt id="link-1" class="py-name" targets="Variable commons.Checker.DEFAULT_LOGGER_NAME=commons.Checker-module.html#DEFAULT_LOGGER_NAME"><a title="commons.Checker.DEFAULT_LOGGER_NAME" class="py-name" href="#" onclick="return doclink('link-1', 'DEFAULT_LOGGER_NAME', 'link-1');">DEFAULT_LOGGER_NAME</a></tt> <tt class="py-op">=</tt> <tt class="py-string">"log02"</tt> </tt>
68 <a name="L13"></a><tt class="py-lineno"> 13</tt> <tt class="py-line"> </tt>
69 <a name="IChecker"></a><div id="IChecker-def"><a name="L14"></a><tt class="py-lineno"> 14</tt> <a class="py-toggle" href="#" id="IChecker-toggle" onclick="return toggle('IChecker');">-</a><tt class="py-line"><tt class="py-keyword">class</tt> <a class="py-def-name" href="commons.Checker.IChecker-class.html">IChecker</a><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
70 </div><div id="IChecker-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="IChecker-expanded"><a name="L15"></a><tt class="py-lineno"> 15</tt> <tt class="py-line"> <tt class="py-docstring">"""</tt> </tt>
71 <a name="L16"></a><tt class="py-lineno"> 16</tt> <tt class="py-line"><tt class="py-docstring"> Interface emulation for a checker </tt> </tt>
72 <a name="L17"></a><tt class="py-lineno"> 17</tt> <tt class="py-line"><tt class="py-docstring"> """</tt> </tt>
73 <a name="IChecker.check"></a><div id="IChecker.check-def"><a name="L18"></a><tt class="py-lineno"> 18</tt> <a class="py-toggle" href="#" id="IChecker.check-toggle" onclick="return toggle('IChecker.check');">-</a><tt class="py-line"> <tt class="py-keyword">def</tt> <a class="py-def-name" href="commons.Checker.IChecker-class.html#check">check</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">arg</tt><tt class="py-op">=</tt><tt class="py-string">""</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
74 </div><div id="IChecker.check-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="IChecker.check-expanded"><a name="L19"></a><tt class="py-lineno"> 19</tt> <tt class="py-line"> <tt class="py-docstring">"""</tt> </tt>
75 <a name="L20"></a><tt class="py-lineno"> 20</tt> <tt class="py-line"><tt class="py-docstring"> perform check, raise a CheckerException if error occured</tt> </tt>
76 <a name="L21"></a><tt class="py-lineno"> 21</tt> <tt class="py-line"><tt class="py-docstring"> </tt> </tt>
77 <a name="L22"></a><tt class="py-lineno"> 22</tt> <tt class="py-line"><tt class="py-docstring"> @param arg: a collecting parameter: put here all you need to perform check </tt> </tt>
78 <a name="L23"></a><tt class="py-lineno"> 23</tt> <tt class="py-line"><tt class="py-docstring"> @type arg: choose the appropriate type</tt> </tt>
79 <a name="L24"></a><tt class="py-lineno"> 24</tt> <tt class="py-line"><tt class="py-docstring"> """</tt> </tt>
80 <a name="L25"></a><tt class="py-lineno"> 25</tt> <tt class="py-line"> <tt class="py-keyword">pass</tt> </tt>
81 </div></div><a name="L26"></a><tt class="py-lineno"> 26</tt> <tt class="py-line"> </tt>
82 <a name="Checker"></a><div id="Checker-def"><a name="L27"></a><tt class="py-lineno"> 27</tt> <a class="py-toggle" href="#" id="Checker-toggle" onclick="return toggle('Checker');">-</a><tt class="py-line"><tt class="py-keyword">class</tt> <a class="py-def-name" href="commons.Checker.Checker-class.html">Checker</a> <tt class="py-op">(</tt><tt class="py-base-class">IChecker</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
83 </div><div id="Checker-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="Checker-expanded"><a name="L28"></a><tt class="py-lineno"> 28</tt> <tt class="py-line"> <tt class="py-docstring">"""</tt> </tt>
84 <a name="L29"></a><tt class="py-lineno"> 29</tt> <tt class="py-line"><tt class="py-docstring"> A concrete checker implementation with a logging.</tt> </tt>
85 <a name="L30"></a><tt class="py-lineno"> 30</tt> <tt class="py-line"><tt class="py-docstring"> Logger instance is a singleton of logging module </tt> </tt>
86 <a name="L31"></a><tt class="py-lineno"> 31</tt> <tt class="py-line"><tt class="py-docstring"> """</tt> </tt>
87 <a name="Checker._handle"></a><div id="Checker._handle-def"><a name="L32"></a><tt class="py-lineno"> 32</tt> <a class="py-toggle" href="#" id="Checker._handle-toggle" onclick="return toggle('Checker._handle');">-</a><tt class="py-line"> <tt class="py-keyword">def</tt> <a class="py-def-name" href="commons.Checker.Checker-class.html#_handle">_handle</a> <tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
88 </div><div id="Checker._handle-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="Checker._handle-expanded"><a name="L33"></a><tt class="py-lineno"> 33</tt> <tt class="py-line"> <tt class="py-keyword">try</tt><tt class="py-op">:</tt> </tt>
89 <a name="L34"></a><tt class="py-lineno"> 34</tt> <tt class="py-line"> <tt class="py-name">single</tt> <tt class="py-op">=</tt> <tt id="link-2" class="py-name" targets="Class commons.Checker._Logger=commons.Checker._Logger-class.html"><a title="commons.Checker._Logger" class="py-name" href="#" onclick="return doclink('link-2', '_Logger', 'link-2');">_Logger</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
90 <a name="L35"></a><tt class="py-lineno"> 35</tt> <tt class="py-line"> <tt class="py-keyword">except</tt> <tt id="link-3" class="py-name"><a title="commons.Checker._Logger" class="py-name" href="#" onclick="return doclink('link-3', '_Logger', 'link-2');">_Logger</a></tt><tt class="py-op">,</tt> <tt class="py-name">l</tt><tt class="py-op">:</tt> </tt>
91 <a name="L36"></a><tt class="py-lineno"> 36</tt> <tt class="py-line"> <tt class="py-name">single</tt> <tt class="py-op">=</tt> <tt class="py-name">l</tt> </tt>
92 <a name="L37"></a><tt class="py-lineno"> 37</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-name">single</tt> </tt>
93 </div><a name="L38"></a><tt class="py-lineno"> 38</tt> <tt class="py-line"> </tt>
94 <a name="Checker.__init__"></a><div id="Checker.__init__-def"><a name="L39"></a><tt class="py-lineno"> 39</tt> <a class="py-toggle" href="#" id="Checker.__init__-toggle" onclick="return toggle('Checker.__init__');">-</a><tt class="py-line"> <tt class="py-keyword">def</tt> <a class="py-def-name" href="commons.Checker.Checker-class.html#__init__">__init__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
95 </div><div id="Checker.__init__-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="Checker.__init__-expanded"><a name="L40"></a><tt class="py-lineno"> 40</tt> <tt class="py-line"> <tt class="py-name">logger</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-4" class="py-name" targets="Method commons.Checker.Checker._handle()=commons.Checker.Checker-class.html#_handle"><a title="commons.Checker.Checker._handle" class="py-name" href="#" onclick="return doclink('link-4', '_handle', 'link-4');">_handle</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
96 <a name="L41"></a><tt class="py-lineno"> 41</tt> <tt class="py-line"> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_log</tt> <tt class="py-op">=</tt> <tt class="py-name">logger</tt><tt class="py-op">.</tt><tt id="link-5" class="py-name" targets="Method commons.Checker.Checker.getLogger()=commons.Checker.Checker-class.html#getLogger,Method commons.Checker._Logger.getLogger()=commons.Checker._Logger-class.html#getLogger"><a title="commons.Checker.Checker.getLogger
97 commons.Checker._Logger.getLogger" class="py-name" href="#" onclick="return doclink('link-5', 'getLogger', 'link-5');">getLogger</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
98 </div><a name="L42"></a><tt class="py-lineno"> 42</tt> <tt class="py-line"> </tt>
99 <a name="Checker.setLogger"></a><div id="Checker.setLogger-def"><a name="L43"></a><tt class="py-lineno"> 43</tt> <a class="py-toggle" href="#" id="Checker.setLogger-toggle" onclick="return toggle('Checker.setLogger');">-</a><tt class="py-line"> <tt class="py-keyword">def</tt> <a class="py-def-name" href="commons.Checker.Checker-class.html#setLogger">setLogger</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">logger</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
100 </div><div id="Checker.setLogger-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="Checker.setLogger-expanded"><a name="L44"></a><tt class="py-lineno"> 44</tt> <tt class="py-line"> <tt class="py-docstring">"""</tt> </tt>
101 <a name="L45"></a><tt class="py-lineno"> 45</tt> <tt class="py-line"><tt class="py-docstring"> set (change) default logger</tt> </tt>
102 <a name="L46"></a><tt class="py-lineno"> 46</tt> <tt class="py-line"><tt class="py-docstring"> </tt> </tt>
103 <a name="L47"></a><tt class="py-lineno"> 47</tt> <tt class="py-line"><tt class="py-docstring"> @param logger: a new logger</tt> </tt>
104 <a name="L48"></a><tt class="py-lineno"> 48</tt> <tt class="py-line"><tt class="py-docstring"> @type logger: class Logger </tt> </tt>
105 <a name="L49"></a><tt class="py-lineno"> 49</tt> <tt class="py-line"><tt class="py-docstring"> """</tt> </tt>
106 <a name="L50"></a><tt class="py-lineno"> 50</tt> <tt class="py-line"> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_log</tt> <tt class="py-op">=</tt> <tt class="py-name">logger</tt> </tt>
107 </div><a name="L51"></a><tt class="py-lineno"> 51</tt> <tt class="py-line"> </tt>
108 <a name="Checker.getLogger"></a><div id="Checker.getLogger-def"><a name="L52"></a><tt class="py-lineno"> 52</tt> <a class="py-toggle" href="#" id="Checker.getLogger-toggle" onclick="return toggle('Checker.getLogger');">-</a><tt class="py-line"> <tt class="py-keyword">def</tt> <a class="py-def-name" href="commons.Checker.Checker-class.html#getLogger">getLogger</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
109 </div><div id="Checker.getLogger-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="Checker.getLogger-expanded"><a name="L53"></a><tt class="py-lineno"> 53</tt> <tt class="py-line"> <tt class="py-docstring">"""</tt> </tt>
110 <a name="L54"></a><tt class="py-lineno"> 54</tt> <tt class="py-line"><tt class="py-docstring"> returns the logger instance</tt> </tt>
111 <a name="L55"></a><tt class="py-lineno"> 55</tt> <tt class="py-line"><tt class="py-docstring"> """</tt> </tt>
112 <a name="L56"></a><tt class="py-lineno"> 56</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_log</tt> </tt>
113 </div></div><a name="L57"></a><tt class="py-lineno"> 57</tt> <tt class="py-line"> </tt>
114 <a name="CheckerException"></a><div id="CheckerException-def"><a name="L58"></a><tt class="py-lineno"> 58</tt> <a class="py-toggle" href="#" id="CheckerException-toggle" onclick="return toggle('CheckerException');">-</a><tt class="py-line"><tt class="py-keyword">class</tt> <a class="py-def-name" href="commons.Checker.CheckerException-class.html">CheckerException</a><tt class="py-op">(</tt><tt class="py-base-class">Exception</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
115 </div><div id="CheckerException-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="CheckerException-expanded"><a name="L59"></a><tt class="py-lineno"> 59</tt> <tt class="py-line"> <tt class="py-docstring">"""</tt> </tt>
116 <a name="L60"></a><tt class="py-lineno"> 60</tt> <tt class="py-line"><tt class="py-docstring"> Exception raised during check. </tt> </tt>
117 <a name="L61"></a><tt class="py-lineno"> 61</tt> <tt class="py-line"><tt class="py-docstring"> </tt> </tt>
118 <a name="L62"></a><tt class="py-lineno"> 62</tt> <tt class="py-line"><tt class="py-docstring"> @ivar msg : message embeded in Execption class </tt> </tt>
119 <a name="L63"></a><tt class="py-lineno"> 63</tt> <tt class="py-line"><tt class="py-docstring"> @type msg: str</tt> </tt>
120 <a name="L64"></a><tt class="py-lineno"> 64</tt> <tt class="py-line"><tt class="py-docstring"> </tt> </tt>
121 <a name="L65"></a><tt class="py-lineno"> 65</tt> <tt class="py-line"><tt class="py-docstring"> """</tt> </tt>
122 <a name="CheckerException.__init__"></a><div id="CheckerException.__init__-def"><a name="L66"></a><tt class="py-lineno"> 66</tt> <a class="py-toggle" href="#" id="CheckerException.__init__-toggle" onclick="return toggle('CheckerException.__init__');">-</a><tt class="py-line"> <tt class="py-keyword">def</tt> <a class="py-def-name" href="commons.Checker.CheckerException-class.html#__init__">__init__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt><tt class="py-param">msg</tt><tt class="py-op">=</tt><tt class="py-string">""</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
123 </div><div id="CheckerException.__init__-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="CheckerException.__init__-expanded"><a name="L67"></a><tt class="py-lineno"> 67</tt> <tt class="py-line"> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-name">msg</tt> </tt>
124 <a name="L68"></a><tt class="py-lineno"> 68</tt> <tt class="py-line"> <tt class="py-name">Exception</tt><tt class="py-op">.</tt><tt id="link-6" class="py-name" targets="Method commons.Checker.Checker.__init__()=commons.Checker.Checker-class.html#__init__,Method commons.Checker.CheckerException.__init__()=commons.Checker.CheckerException-class.html#__init__,Method commons.Checker.ConfigChecker.__init__()=commons.Checker.ConfigChecker-class.html#__init__,Method commons.Checker.ConfigException.__init__()=commons.Checker.ConfigException-class.html#__init__,Method commons.Checker._Logger.__init__()=commons.Checker._Logger-class.html#__init__"><a title="commons.Checker.Checker.__init__
125 commons.Checker.CheckerException.__init__
126 commons.Checker.ConfigChecker.__init__
127 commons.Checker.ConfigException.__init__
128 commons.Checker._Logger.__init__" class="py-name" href="#" onclick="return doclink('link-6', '__init__', 'link-6');">__init__</a></tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">,</tt> <tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
129 </div></div><a name="L69"></a><tt class="py-lineno"> 69</tt> <tt class="py-line"> </tt>
130 <a name="ConfigChecker"></a><div id="ConfigChecker-def"><a name="L70"></a><tt class="py-lineno"> 70</tt> <a class="py-toggle" href="#" id="ConfigChecker-toggle" onclick="return toggle('ConfigChecker');">-</a><tt class="py-line"><tt class="py-keyword">class</tt> <a class="py-def-name" href="commons.Checker.ConfigChecker-class.html">ConfigChecker</a> <tt class="py-op">(</tt><tt class="py-base-class">IChecker</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
131 </div><div id="ConfigChecker-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="ConfigChecker-expanded"><a name="L71"></a><tt class="py-lineno"> 71</tt> <tt class="py-line"> <tt class="py-docstring">"""</tt> </tt>
132 <a name="L72"></a><tt class="py-lineno"> 72</tt> <tt class="py-line"><tt class="py-docstring"> A checker for config file. </tt> </tt>
133 <a name="L73"></a><tt class="py-lineno"> 73</tt> <tt class="py-line"><tt class="py-docstring"> @ivar sectionName: section to check in config file</tt> </tt>
134 <a name="L74"></a><tt class="py-lineno"> 74</tt> <tt class="py-line"><tt class="py-docstring"> @type sectionName: str</tt> </tt>
135 <a name="L75"></a><tt class="py-lineno"> 75</tt> <tt class="py-line"><tt class="py-docstring"> </tt> </tt>
136 <a name="L76"></a><tt class="py-lineno"> 76</tt> <tt class="py-line"><tt class="py-docstring"> @ivar optionsDict: dict with option to check as keys and empty strings "" as values</tt> </tt>
137 <a name="L77"></a><tt class="py-lineno"> 77</tt> <tt class="py-line"><tt class="py-docstring"> @type optionsDict: class Dict</tt> </tt>
138 <a name="L78"></a><tt class="py-lineno"> 78</tt> <tt class="py-line"><tt class="py-docstring"> """</tt> </tt>
139 <a name="L79"></a><tt class="py-lineno"> 79</tt> <tt class="py-line"> </tt>
140 <a name="ConfigChecker.__init__"></a><div id="ConfigChecker.__init__-def"><a name="L80"></a><tt class="py-lineno"> 80</tt> <a class="py-toggle" href="#" id="ConfigChecker.__init__-toggle" onclick="return toggle('ConfigChecker.__init__');">-</a><tt class="py-line"> <tt class="py-keyword">def</tt> <a class="py-def-name" href="commons.Checker.ConfigChecker-class.html#__init__">__init__</a> <tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">sectionName</tt><tt class="py-op">,</tt> <tt class="py-param">optionsDict</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
141 </div><div id="ConfigChecker.__init__-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="ConfigChecker.__init__-expanded"><a name="L81"></a><tt class="py-lineno"> 81</tt> <tt class="py-line"> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_sectionName</tt> <tt class="py-op">=</tt> <tt class="py-name">sectionName</tt> </tt>
142 <a name="L82"></a><tt class="py-lineno"> 82</tt> <tt class="py-line"> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_optionsDict</tt> <tt class="py-op">=</tt> <tt class="py-name">optionsDict</tt> </tt>
143 </div><a name="L83"></a><tt class="py-lineno"> 83</tt> <tt class="py-line"> <tt class="py-string">"""</tt> </tt>
144 <a name="L84"></a><tt class="py-lineno"> 84</tt> <tt class="py-line"><tt class="py-string"> Check options stored in optionsDict. 3 checks are performed:</tt> </tt>
145 <a name="L85"></a><tt class="py-lineno"> 85</tt> <tt class="py-line"><tt class="py-string"> (i) config file existence, (ii) section existence, (iii) options existences</tt> </tt>
146 <a name="L86"></a><tt class="py-lineno"> 86</tt> <tt class="py-line"><tt class="py-string"> If a check fail, raise a ConfigException with a list of messages</tt> </tt>
147 <a name="L87"></a><tt class="py-lineno"> 87</tt> <tt class="py-line"><tt class="py-string"> """</tt> </tt>
148 <a name="ConfigChecker.check"></a><div id="ConfigChecker.check-def"><a name="L88"></a><tt class="py-lineno"> 88</tt> <a class="py-toggle" href="#" id="ConfigChecker.check-toggle" onclick="return toggle('ConfigChecker.check');">-</a><tt class="py-line"> <tt class="py-keyword">def</tt> <a class="py-def-name" href="commons.Checker.ConfigChecker-class.html#check">check</a> <tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">configFile</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
149 </div><div id="ConfigChecker.check-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="ConfigChecker.check-expanded"><a name="L89"></a><tt class="py-lineno"> 89</tt> <tt class="py-line"> <tt class="py-name">config</tt> <tt class="py-op">=</tt> <tt class="py-name">ConfigParser</tt><tt class="py-op">.</tt><tt class="py-name">ConfigParser</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
150 <a name="L90"></a><tt class="py-lineno"> 90</tt> <tt class="py-line"> <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-op">]</tt> </tt>
151 <a name="L91"></a><tt class="py-lineno"> 91</tt> <tt class="py-line"> <tt class="py-keyword">try</tt><tt class="py-op">:</tt> </tt>
152 <a name="L92"></a><tt class="py-lineno"> 92</tt> <tt class="py-line"> <tt class="py-name">config</tt><tt class="py-op">.</tt><tt class="py-name">readfp</tt><tt class="py-op">(</tt> <tt class="py-name">open</tt><tt class="py-op">(</tt><tt class="py-name">configFile</tt><tt class="py-op">)</tt> <tt class="py-op">)</tt> </tt>
153 <a name="L93"></a><tt class="py-lineno"> 93</tt> <tt class="py-line"> <tt class="py-keyword">except</tt> <tt class="py-name">IOError</tt><tt class="py-op">,</tt> <tt class="py-name">e</tt><tt class="py-op">:</tt> </tt>
154 <a name="L94"></a><tt class="py-lineno"> 94</tt> <tt class="py-line"> <tt class="py-name">msg</tt><tt class="py-op">.</tt><tt class="py-name">append</tt><tt class="py-op">(</tt><tt class="py-string">"CONFIG FILE not found - "</tt> <tt class="py-op">+</tt> <tt class="py-name">e</tt><tt class="py-op">.</tt><tt class="py-name">message</tt><tt class="py-op">)</tt> </tt>
155 <a name="L95"></a><tt class="py-lineno"> 95</tt> <tt class="py-line"> <tt class="py-keyword">raise</tt> <tt id="link-7" class="py-name" targets="Class commons.Checker.ConfigException=commons.Checker.ConfigException-class.html"><a title="commons.Checker.ConfigException" class="py-name" href="#" onclick="return doclink('link-7', 'ConfigException', 'link-7');">ConfigException</a></tt><tt class="py-op">(</tt><tt class="py-string">""</tt><tt class="py-op">,</tt> <tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
156 <a name="L96"></a><tt class="py-lineno"> 96</tt> <tt class="py-line"> </tt>
157 <a name="L97"></a><tt class="py-lineno"> 97</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-keyword">not</tt> <tt class="py-op">(</tt><tt class="py-name">config</tt><tt class="py-op">.</tt><tt class="py-name">has_section</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_sectionName</tt><tt class="py-op">)</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
158 <a name="L98"></a><tt class="py-lineno"> 98</tt> <tt class="py-line"> <tt class="py-name">msg</tt><tt class="py-op">.</tt><tt class="py-name">append</tt><tt class="py-op">(</tt><tt class="py-string">"["</tt> <tt class="py-op">+</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_sectionName</tt> <tt class="py-op">+</tt> <tt class="py-string">"]"</tt> <tt class="py-op">+</tt> <tt class="py-string">" section not found - "</tt><tt class="py-op">)</tt> </tt>
159 <a name="L99"></a><tt class="py-lineno"> 99</tt> <tt class="py-line"> <tt class="py-keyword">raise</tt> <tt id="link-8" class="py-name"><a title="commons.Checker.ConfigException" class="py-name" href="#" onclick="return doclink('link-8', 'ConfigException', 'link-7');">ConfigException</a></tt><tt class="py-op">(</tt><tt class="py-string">""</tt><tt class="py-op">,</tt> <tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
160 <a name="L100"></a><tt class="py-lineno">100</tt> <tt class="py-line"> </tt>
161 <a name="L101"></a><tt class="py-lineno">101</tt> <tt class="py-line"> <tt class="py-name">isExceptionOccured</tt> <tt class="py-op">=</tt> <tt class="py-name">False</tt> </tt>
162 <a name="L102"></a><tt class="py-lineno">102</tt> <tt class="py-line"> <tt class="py-keyword">for</tt> <tt class="py-name">key</tt> <tt class="py-keyword">in</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_optionsDict</tt><tt class="py-op">.</tt><tt class="py-name">keys</tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
163 <a name="L103"></a><tt class="py-lineno">103</tt> <tt class="py-line"> <tt class="py-keyword">try</tt><tt class="py-op">:</tt> </tt>
164 <a name="L104"></a><tt class="py-lineno">104</tt> <tt class="py-line"> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_optionsDict</tt><tt class="py-op">[</tt><tt class="py-name">key</tt><tt class="py-op">]</tt> <tt class="py-op">=</tt> <tt class="py-name">config</tt><tt class="py-op">.</tt><tt class="py-name">get</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_sectionName</tt><tt class="py-op">,</tt> <tt class="py-name">key</tt><tt class="py-op">)</tt> </tt>
165 <a name="L105"></a><tt class="py-lineno">105</tt> <tt class="py-line"> <tt class="py-keyword">except</tt> <tt class="py-name">NoOptionError</tt><tt class="py-op">,</tt> <tt class="py-name">e</tt><tt class="py-op">:</tt> </tt>
166 <a name="L106"></a><tt class="py-lineno">106</tt> <tt class="py-line"> <tt class="py-name">msg</tt><tt class="py-op">.</tt><tt class="py-name">append</tt><tt class="py-op">(</tt><tt class="py-string">"["</tt> <tt class="py-op">+</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_sectionName</tt> <tt class="py-op">+</tt> <tt class="py-string">"]"</tt> <tt class="py-op">+</tt> <tt class="py-string">" - "</tt> <tt class="py-op">+</tt> <tt class="py-name">e</tt><tt class="py-op">.</tt><tt class="py-name">message</tt><tt class="py-op">)</tt> </tt>
167 <a name="L107"></a><tt class="py-lineno">107</tt> <tt class="py-line"> <tt class="py-name">isExceptionOccured</tt> <tt class="py-op">=</tt> <tt class="py-name">True</tt> </tt>
168 <a name="L108"></a><tt class="py-lineno">108</tt> <tt class="py-line"> </tt>
169 <a name="L109"></a><tt class="py-lineno">109</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-op">(</tt><tt class="py-name">isExceptionOccured</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
170 <a name="L110"></a><tt class="py-lineno">110</tt> <tt class="py-line"> <tt class="py-keyword">raise</tt> <tt id="link-9" class="py-name"><a title="commons.Checker.ConfigException" class="py-name" href="#" onclick="return doclink('link-9', 'ConfigException', 'link-7');">ConfigException</a></tt><tt class="py-op">(</tt><tt class="py-string">""</tt><tt class="py-op">,</tt> <tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
171 </div></div><a name="L111"></a><tt class="py-lineno">111</tt> <tt class="py-line"> </tt>
172 <a name="ConfigException"></a><div id="ConfigException-def"><a name="L112"></a><tt class="py-lineno">112</tt> <a class="py-toggle" href="#" id="ConfigException-toggle" onclick="return toggle('ConfigException');">-</a><tt class="py-line"><tt class="py-keyword">class</tt> <a class="py-def-name" href="commons.Checker.ConfigException-class.html">ConfigException</a><tt class="py-op">(</tt><tt class="py-base-class">Exception</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
173 </div><div id="ConfigException-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="ConfigException-expanded"><a name="L113"></a><tt class="py-lineno">113</tt> <tt class="py-line"> </tt>
174 <a name="L114"></a><tt class="py-lineno">114</tt> <tt class="py-line"> <tt class="py-docstring">"""</tt> </tt>
175 <a name="L115"></a><tt class="py-lineno">115</tt> <tt class="py-line"><tt class="py-docstring"> A exception raised by check method class ConfigChecker</tt> </tt>
176 <a name="L116"></a><tt class="py-lineno">116</tt> <tt class="py-line"><tt class="py-docstring"> </tt> </tt>
177 <a name="L117"></a><tt class="py-lineno">117</tt> <tt class="py-line"><tt class="py-docstring"> @ivar msg : message embeded in Execption class </tt> </tt>
178 <a name="L118"></a><tt class="py-lineno">118</tt> <tt class="py-line"><tt class="py-docstring"> @type msg: str</tt> </tt>
179 <a name="L119"></a><tt class="py-lineno">119</tt> <tt class="py-line"><tt class="py-docstring"> </tt> </tt>
180 <a name="L120"></a><tt class="py-lineno">120</tt> <tt class="py-line"><tt class="py-docstring"> @ivar messages: list of messages</tt> </tt>
181 <a name="L121"></a><tt class="py-lineno">121</tt> <tt class="py-line"><tt class="py-docstring"> @type messages: Class list</tt> </tt>
182 <a name="L122"></a><tt class="py-lineno">122</tt> <tt class="py-line"><tt class="py-docstring"> </tt> </tt>
183 <a name="L123"></a><tt class="py-lineno">123</tt> <tt class="py-line"><tt class="py-docstring"> """</tt> </tt>
184 <a name="ConfigException.__init__"></a><div id="ConfigException.__init__-def"><a name="L124"></a><tt class="py-lineno">124</tt> <a class="py-toggle" href="#" id="ConfigException.__init__-toggle" onclick="return toggle('ConfigException.__init__');">-</a><tt class="py-line"> <tt class="py-keyword">def</tt> <a class="py-def-name" href="commons.Checker.ConfigException-class.html#__init__">__init__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt><tt class="py-param">msg</tt><tt class="py-op">,</tt> <tt class="py-param">messages</tt><tt class="py-op">=</tt><tt class="py-op">[</tt><tt class="py-op">]</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
185 </div><div id="ConfigException.__init__-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="ConfigException.__init__-expanded"><a name="L125"></a><tt class="py-lineno">125</tt> <tt class="py-line"> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">messages</tt> <tt class="py-op">=</tt> <tt class="py-name">messages</tt> </tt>
186 <a name="L126"></a><tt class="py-lineno">126</tt> <tt class="py-line"> <tt class="py-name">Exception</tt><tt class="py-op">.</tt><tt id="link-10" class="py-name"><a title="commons.Checker.Checker.__init__
187 commons.Checker.CheckerException.__init__
188 commons.Checker.ConfigChecker.__init__
189 commons.Checker.ConfigException.__init__
190 commons.Checker._Logger.__init__" class="py-name" href="#" onclick="return doclink('link-10', '__init__', 'link-6');">__init__</a></tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">,</tt> <tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
191 </div></div><a name="L127"></a><tt class="py-lineno">127</tt> <tt class="py-line"> </tt>
192 <a name="_Logger"></a><div id="_Logger-def"><a name="L128"></a><tt class="py-lineno">128</tt> <a class="py-toggle" href="#" id="_Logger-toggle" onclick="return toggle('_Logger');">-</a><tt class="py-line"><tt class="py-keyword">class</tt> <a class="py-def-name" href="commons.Checker._Logger-class.html">_Logger</a><tt class="py-op">:</tt> </tt>
193 </div><div id="_Logger-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="_Logger-expanded"><a name="L129"></a><tt class="py-lineno">129</tt> <tt class="py-line"> </tt>
194 <a name="L130"></a><tt class="py-lineno">130</tt> <tt class="py-line"> <tt class="py-name">__single</tt> <tt class="py-op">=</tt> <tt class="py-name">None</tt> </tt>
195 <a name="L131"></a><tt class="py-lineno">131</tt> <tt class="py-line"> </tt>
196 <a name="_Logger.__init__"></a><div id="_Logger.__init__-def"><a name="L132"></a><tt class="py-lineno">132</tt> <a class="py-toggle" href="#" id="_Logger.__init__-toggle" onclick="return toggle('_Logger.__init__');">-</a><tt class="py-line"> <tt class="py-keyword">def</tt> <a class="py-def-name" href="commons.Checker._Logger-class.html#__init__">__init__</a><tt class="py-op">(</tt> <tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">loggerName</tt> <tt class="py-op">=</tt><tt class="py-string">""</tt> <tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
197 </div><div id="_Logger.__init__-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="_Logger.__init__-expanded"><a name="L133"></a><tt class="py-lineno">133</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt id="link-11" class="py-name"><a title="commons.Checker._Logger" class="py-name" href="#" onclick="return doclink('link-11', '_Logger', 'link-2');">_Logger</a></tt><tt class="py-op">.</tt><tt class="py-name">__single</tt><tt class="py-op">:</tt> </tt>
198 <a name="L134"></a><tt class="py-lineno">134</tt> <tt class="py-line"> <tt class="py-keyword">raise</tt> <tt id="link-12" class="py-name"><a title="commons.Checker._Logger" class="py-name" href="#" onclick="return doclink('link-12', '_Logger', 'link-2');">_Logger</a></tt><tt class="py-op">.</tt><tt class="py-name">__single</tt> </tt>
199 <a name="L135"></a><tt class="py-lineno">135</tt> <tt class="py-line"> <tt class="py-name">logging</tt><tt class="py-op">.</tt><tt class="py-name">config</tt><tt class="py-op">.</tt><tt class="py-name">fileConfig</tt><tt class="py-op">(</tt><tt id="link-13" class="py-name"><a title="commons.Checker.LOG_FILE" class="py-name" href="#" onclick="return doclink('link-13', 'LOG_FILE', 'link-0');">LOG_FILE</a></tt><tt class="py-op">)</tt> </tt>
200 <a name="L136"></a><tt class="py-lineno">136</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-op">(</tt><tt class="py-name">loggerName</tt> <tt class="py-op">!=</tt> <tt class="py-string">""</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
201 <a name="L137"></a><tt class="py-lineno">137</tt> <tt class="py-line"> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">__log</tt> <tt class="py-op">=</tt> <tt class="py-name">logging</tt><tt class="py-op">.</tt><tt id="link-14" class="py-name"><a title="commons.Checker.Checker.getLogger
202 commons.Checker._Logger.getLogger" class="py-name" href="#" onclick="return doclink('link-14', 'getLogger', 'link-5');">getLogger</a></tt><tt class="py-op">(</tt><tt class="py-name">loggerName</tt><tt class="py-op">)</tt> </tt>
203 <a name="L138"></a><tt class="py-lineno">138</tt> <tt class="py-line"> <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
204 <a name="L139"></a><tt class="py-lineno">139</tt> <tt class="py-line"> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">__log</tt> <tt class="py-op">=</tt> <tt class="py-name">logging</tt><tt class="py-op">.</tt><tt id="link-15" class="py-name"><a title="commons.Checker.Checker.getLogger
205 commons.Checker._Logger.getLogger" class="py-name" href="#" onclick="return doclink('link-15', 'getLogger', 'link-5');">getLogger</a></tt><tt class="py-op">(</tt><tt id="link-16" class="py-name"><a title="commons.Checker.DEFAULT_LOGGER_NAME" class="py-name" href="#" onclick="return doclink('link-16', 'DEFAULT_LOGGER_NAME', 'link-1');">DEFAULT_LOGGER_NAME</a></tt><tt class="py-op">)</tt> </tt>
206 <a name="L140"></a><tt class="py-lineno">140</tt> <tt class="py-line"> <tt id="link-17" class="py-name"><a title="commons.Checker._Logger" class="py-name" href="#" onclick="return doclink('link-17', '_Logger', 'link-2');">_Logger</a></tt><tt class="py-op">.</tt><tt class="py-name">__single</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt> </tt>
207 </div><a name="L141"></a><tt class="py-lineno">141</tt> <tt class="py-line"> </tt>
208 <a name="_Logger.getLogger"></a><div id="_Logger.getLogger-def"><a name="L142"></a><tt class="py-lineno">142</tt> <a class="py-toggle" href="#" id="_Logger.getLogger-toggle" onclick="return toggle('_Logger.getLogger');">-</a><tt class="py-line"> <tt class="py-keyword">def</tt> <a class="py-def-name" href="commons.Checker._Logger-class.html#getLogger">getLogger</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
209 </div><div id="_Logger.getLogger-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="_Logger.getLogger-expanded"><a name="L143"></a><tt class="py-lineno">143</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">__log</tt> </tt>
210 </div></div><a name="L144"></a><tt class="py-lineno">144</tt> <tt class="py-line"> </tt><script type="text/javascript">
211 <!--
212 expandto(location.href);
213 // -->
214 </script>
215 </pre>
216 <br />
217 <!-- ==================== NAVIGATION BAR ==================== -->
218 <table class="navbar" border="0" width="100%" cellpadding="0"
219 bgcolor="#a0c0ff" cellspacing="0">
220 <tr valign="middle">
221
222 <!-- Tree link -->
223 <th>&nbsp;&nbsp;&nbsp;<a
224 href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
225
226 <!-- Index link -->
227 <th>&nbsp;&nbsp;&nbsp;<a
228 href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>
229
230 <!-- Help link -->
231 <th>&nbsp;&nbsp;&nbsp;<a
232 href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
233
234 <th class="navbar" width="100%"></th>
235 </tr>
236 </table>
237 <table border="0" cellpadding="0" cellspacing="0" width="100%%">
238 <tr>
239 <td align="left" class="footer">
240 Generated by Epydoc 3.0.1 on Fri Apr 10 16:39:01 2009
241 </td>
242 <td align="right" class="footer">
243 <a target="mainFrame" href="http://epydoc.sourceforge.net"
244 >http://epydoc.sourceforge.net</a>
245 </td>
246 </tr>
247 </table>
248
249 <script type="text/javascript">
250 <!--
251 // Private objects are initially displayed (because if
252 // javascript is turned off then we want them to be
253 // visible); but by default, we want to hide them. So hide
254 // them unless we have a cookie that says to show them.
255 checkCookie();
256 // -->
257 </script>
258 </body>
259 </html>