/usr/share/doc/python-pebl/html/config.html is in python-pebl-doc 1.0.2-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>config – Pebl’s configuration system — Pebl v1.0.1 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '1.0.1',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="Pebl v1.0.1 documentation" href="index.html" />
<link rel="up" title="API Reference" href="apiref.html" />
<link rel="next" title="cpd – Conditional probability distributions" href="cpd.html" />
<link rel="prev" title="API Reference" href="apiref.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="cpd.html" title="cpd – Conditional probability distributions"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="apiref.html" title="API Reference"
accesskey="P">previous</a> |</li>
<li><a href="index.html">Pebl v1.0.1 documentation</a> »</li>
<li><a href="apiref.html" accesskey="U">API Reference</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="module-pebl.config">
<span id="config-pebl-s-configuration-system"></span><h1><tt class="xref py py-mod docutils literal"><span class="pre">config</span></tt> – Pebl’s configuration system<a class="headerlink" href="#module-pebl.config" title="Permalink to this headline">¶</a></h1>
<p>The config module defines a set of parameter types and functions to validate
user input. A module or class can define a parameter by creating an instance of
one of the Parameter classes – it is automatically registered with the config
module. Many modules provide a fromconfig() factory function that create and
return a parametrized object.</p>
<div class="section" id="specifying-parameters">
<h2>Specifying Parameters<a class="headerlink" href="#specifying-parameters" title="Permalink to this headline">¶</a></h2>
<p>A Parameter definition requires the following:</p>
<blockquote>
<div><ul>
<li><p class="first">a name of the form section.option
(examples: data.filename, result.format)</p>
</li>
<li><p class="first">a short description</p>
</li>
<li><p class="first">a validator function</p>
<p>The function has one argument: the string value of the parameter. It
should return true if the value is valid and false otherwise. The config
module includes several factory functions that create
validator functions. See section on validator factories.</p>
</li>
<li><p class="first">a default value specified as a string</p>
</li>
</ul>
</div></blockquote>
<div class="section" id="example-parameter-definitions">
<h3>Example parameter definitions<a class="headerlink" href="#example-parameter-definitions" title="Permalink to this headline">¶</a></h3>
<p>From the pebl.data module:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">_pfilename</span> <span class="o">=</span> <span class="n">config</span><span class="o">.</span><span class="n">StringParameter</span><span class="p">(</span>
<span class="s">'data.filename'</span><span class="p">,</span>
<span class="s">'File to read data from.'</span><span class="p">,</span>
<span class="n">config</span><span class="o">.</span><span class="n">fileexists</span><span class="p">(),</span>
<span class="p">)</span>
</pre></div>
</div>
<p>In the above example, the config.fileexists() function returns a validator
function that checks whether the file exists.</p>
<p>From the pebl.result module:</p>
<div class="highlight-python"><pre>_psize = config.IntParameter(
'result.numnetworks',
\"\"\"Number of top-scoring networks to save. Specify 0 to indicate that
all scored networks should be saved.\"\"\",
default=1000
)</pre>
</div>
<p>In the above example, The IntParameter subclass of Parameter automatically
checks whether the parameter value is an integer and raises an error if it is
not. It thus does not require an additional validator.</p>
</div>
</div>
<div class="section" id="parameter-types">
<h2>Parameter Types<a class="headerlink" href="#parameter-types" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="pebl.config.StringParameter">
<em class="property">class </em><tt class="descclassname">pebl.config.</tt><tt class="descname">StringParameter</tt><big>(</big><em>name</em>, <em>description</em>, <em>validator=<function default_validator at 0x2cf5b18></em>, <em>default=None</em><big>)</big><a class="headerlink" href="#pebl.config.StringParameter" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="class">
<dt id="pebl.config.IntParameter">
<em class="property">class </em><tt class="descclassname">pebl.config.</tt><tt class="descname">IntParameter</tt><big>(</big><em>name</em>, <em>description</em>, <em>validator=<function default_validator at 0x2cf5b18></em>, <em>default=None</em><big>)</big><a class="headerlink" href="#pebl.config.IntParameter" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="class">
<dt id="pebl.config.FloatParameter">
<em class="property">class </em><tt class="descclassname">pebl.config.</tt><tt class="descname">FloatParameter</tt><big>(</big><em>name</em>, <em>description</em>, <em>validator=<function default_validator at 0x2cf5b18></em>, <em>default=None</em><big>)</big><a class="headerlink" href="#pebl.config.FloatParameter" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</div>
<div class="section" id="validator-factories">
<h2>Validator Factories<a class="headerlink" href="#validator-factories" title="Permalink to this headline">¶</a></h2>
<p>The following functions create validator functions.</p>
<dl class="function">
<dt id="pebl.config.between">
<tt class="descclassname">pebl.config.</tt><tt class="descname">between</tt><big>(</big><em>min</em>, <em>max</em><big>)</big><a class="headerlink" href="#pebl.config.between" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns validator that checks whether value is between min and max.</p>
</dd></dl>
<dl class="function">
<dt id="pebl.config.oneof">
<tt class="descclassname">pebl.config.</tt><tt class="descname">oneof</tt><big>(</big><em>*values</em><big>)</big><a class="headerlink" href="#pebl.config.oneof" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns validator that checks whether value is in approved list.</p>
</dd></dl>
<dl class="function">
<dt id="pebl.config.atleast">
<tt class="descclassname">pebl.config.</tt><tt class="descname">atleast</tt><big>(</big><em>min</em><big>)</big><a class="headerlink" href="#pebl.config.atleast" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns validator that checks whether value is > min.</p>
</dd></dl>
<dl class="function">
<dt id="pebl.config.atmost">
<tt class="descclassname">pebl.config.</tt><tt class="descname">atmost</tt><big>(</big><em>max</em><big>)</big><a class="headerlink" href="#pebl.config.atmost" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns validator that checks whether value is < max.</p>
</dd></dl>
<dl class="function">
<dt id="pebl.config.fileexists">
<tt class="descclassname">pebl.config.</tt><tt class="descname">fileexists</tt><big>(</big><big>)</big><a class="headerlink" href="#pebl.config.fileexists" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns validator that checks whether value is an existing file.</p>
</dd></dl>
</div>
<div class="section" id="using-parameters">
<h2>Using Parameters<a class="headerlink" href="#using-parameters" title="Permalink to this headline">¶</a></h2>
<p>Parameters can be set with the config.set function or in a configuration file.
The config file should be in a format compatible with Python’s ConfigParser
module.</p>
<p>Specifying parameter values using a config file:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="p">[</span><span class="n">data</span><span class="p">]</span>
<span class="n">filename</span> <span class="o">=</span> <span class="n">example_data</span><span class="o">.</span><span class="n">txt</span>
<span class="p">[</span><span class="n">result</span><span class="p">]</span>
<span class="n">format</span><span class="o">=</span><span class="n">html</span>
</pre></div>
</div>
<p>Specifying parameter values using config.set:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">pebl</span> <span class="kn">import</span> <span class="n">config</span>
<span class="n">config</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s">'data.filename'</span><span class="p">,</span> <span class="s">'example_data.txt'</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s">'result.format'</span><span class="p">,</span> <span class="s">'html'</span><span class="p">)</span>
</pre></div>
</div>
<dl class="function">
<dt id="pebl.config.set">
<tt class="descclassname">pebl.config.</tt><tt class="descname">set</tt><big>(</big><em>name</em>, <em>value</em>, <em>source='config.set'</em><big>)</big><a class="headerlink" href="#pebl.config.set" title="Permalink to this definition">¶</a></dt>
<dd><p>Set a parameter value.</p>
<ul class="simple">
<li>name should be of the form “section.name”.</li>
<li>value can be a string which will be casted to the required datatype.</li>
<li>source specifies where this parameter value was specified (config file,
command line, interactive shell, etc).</li>
</ul>
</dd></dl>
<p>The following functions are used for reading, getting, writing and listing
parameters.</p>
<dl class="function">
<dt id="pebl.config.read">
<tt class="descclassname">pebl.config.</tt><tt class="descname">read</tt><big>(</big><em>filename</em><big>)</big><a class="headerlink" href="#pebl.config.read" title="Permalink to this definition">¶</a></dt>
<dd><p>Reads parameter from config file.</p>
<p>Config files should conform to the format specified in the ConfigParser
module from Python’s standard library. A Parameter’s name has two parts:
the section and the option name. These correspond to ‘section’ and
‘option’ as defined in ConfigParser.</p>
<p>For example, parameter ‘foo.bar’ would be specified in the config file as:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="p">[</span><span class="n">foo</span><span class="p">]</span>
<span class="n">bar</span> <span class="o">=</span> <span class="mi">5</span>
</pre></div>
</div>
</dd></dl>
<dl class="function">
<dt id="pebl.config.get">
<tt class="descclassname">pebl.config.</tt><tt class="descname">get</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#pebl.config.get" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns value of parameter.</p>
<p>Raises KeyError if parameter not found.
Examples:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">pebl</span> <span class="kn">import</span> <span class="n">config</span>
<span class="n">config</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">'data.filename'</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">'result.format'</span><span class="p">)</span>
</pre></div>
</div>
<p>The value returned could be the default value or the latest value set using
config.set or config.read</p>
</dd></dl>
<dl class="function">
<dt id="pebl.config.write">
<tt class="descclassname">pebl.config.</tt><tt class="descname">write</tt><big>(</big><em>filename</em>, <em>include_defaults=False</em><big>)</big><a class="headerlink" href="#pebl.config.write" title="Permalink to this definition">¶</a></dt>
<dd><p>Writes parameters to config file.</p>
<p>If include_default is True, writes all parameters. Else, only writes
parameters that were specifically set (via config file, command line, etc).</p>
</dd></dl>
<dl class="function">
<dt id="pebl.config.parameters">
<tt class="descclassname">pebl.config.</tt><tt class="descname">parameters</tt><big>(</big><em>section=None</em><big>)</big><a class="headerlink" href="#pebl.config.parameters" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns list of parameters.</p>
<p>If section is specified, returns parameters for that section only.
section can be a section name or a search string to use with
string.startswith(..)</p>
</dd></dl>
<dl class="function">
<dt id="pebl.config.configobj">
<tt class="descclassname">pebl.config.</tt><tt class="descname">configobj</tt><big>(</big><em>params</em><big>)</big><a class="headerlink" href="#pebl.config.configobj" title="Permalink to this definition">¶</a></dt>
<dd><p>Given a list of parameters, returns a ConfigParser object.</p>
<p>This function can be used to convert a list of parameters to a config
object which can then be written to file.</p>
</dd></dl>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#"><tt class="docutils literal"><span class="pre">config</span></tt> – Pebl’s configuration system</a><ul>
<li><a class="reference internal" href="#specifying-parameters">Specifying Parameters</a><ul>
<li><a class="reference internal" href="#example-parameter-definitions">Example parameter definitions</a></li>
</ul>
</li>
<li><a class="reference internal" href="#parameter-types">Parameter Types</a></li>
<li><a class="reference internal" href="#validator-factories">Validator Factories</a></li>
<li><a class="reference internal" href="#using-parameters">Using Parameters</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="apiref.html"
title="previous chapter">API Reference</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="cpd.html"
title="next chapter"><tt class="docutils literal"><span class="pre">cpd</span></tt> – Conditional probability distributions</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/config.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" size="18" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="cpd.html" title="cpd – Conditional probability distributions"
>next</a> |</li>
<li class="right" >
<a href="apiref.html" title="API Reference"
>previous</a> |</li>
<li><a href="index.html">Pebl v1.0.1 documentation</a> »</li>
<li><a href="apiref.html" >API Reference</a> »</li>
</ul>
</div>
<div class="footer">
© Copyright 2008, Abhik Shah.
Last updated on Apr 29, 2011.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
</div>
</body>
</html>
|