<h1><ttclass="xref docutils literal"><spanclass="pre">deluge.config</span></tt><aclass="headerlink"href="#module-deluge.config"title="Permalink to this headline">¶</a></h1>
<p>Deluge Config Module</p>
<p>This module is used for loading and saving of configuration files.. or anything
really.</p>
<p>The format of the config file is as follows:</p>
<p><format version as int>
<config file version as int>
<content></p>
<p>The format version is controlled by the Config class. It should only be changed
when anything below it is changed directly by the Config class. An example of
this would be if we changed the serializer for the content to something different.</p>
<p>The config file version is changed by the ‘owner’ of the config file. This is
to signify that there is a change in the naming of some config keys or something
similar along those lines.</p>
<p>The content is simply the dict to be saved and will be serialized before being
written.</p>
<p>Converting</p>
<p>Since the format of the config could change, there needs to be a way to have
the Config object convert to newer formats. To do this, you will need to
register conversion functions for various versions of the config file. Note that
this can only be done for the ‘config file version’ and not for the ‘format’
version as this will be done internally.</p>
<dlclass="class">
<dtid="deluge.config.Config">
<emclass="property">
class </em><ttclass="descclassname">deluge.config.</tt><ttclass="descname">Config</tt><big>(</big><em>filename</em>, <em>defaults=None</em>, <em>config_dir=None</em><big>)</big><aclass="headerlink"href="#deluge.config.Config"title="Permalink to this definition">¶</a></dt>
<trclass="field"><thclass="field-name">Parameters:</th><tdclass="field-body"><ulclass="first last simple">
<li><em>filename</em>– the name of the config file</li>
<li><em>defaults</em>– dictionary of default values</li>
<li><em>config_dir</em>– the path to the config directory</li>
</ul>
</td>
</tr>
</tbody>
</table>
<dlclass="method">
<dtid="deluge.config.Config.__setitem__">
<ttclass="descname">__setitem__</tt><big>(</big><em>key</em>, <em>value</em><big>)</big><aclass="headerlink"href="#deluge.config.Config.__setitem__"title="Permalink to this definition">¶</a></dt>
<ttclass="descname">__getitem__</tt><big>(</big><em>key</em><big>)</big><aclass="headerlink"href="#deluge.config.Config.__getitem__"title="Permalink to this definition">¶</a></dt>
<ttclass="descname">apply_all</tt><big>(</big><big>)</big><aclass="headerlink"href="#deluge.config.Config.apply_all"title="Permalink to this definition">¶</a></dt>
<ttclass="descname">apply_set_functions</tt><big>(</big><em>key</em><big>)</big><aclass="headerlink"href="#deluge.config.Config.apply_set_functions"title="Permalink to this definition">¶</a></dt>
<dd><p>Calls set functions for <cite>:param:key</cite>.</p>
<trclass="field"><thclass="field-name">Parameter:</th><tdclass="field-body"><em>key</em>– str, the config key</td>
</tr>
</tbody>
</table>
</dd></dl>
<dlclass="attribute">
<dtid="deluge.config.Config.config">
<ttclass="descname">config</tt><aclass="headerlink"href="#deluge.config.Config.config"title="Permalink to this definition">¶</a></dt>
<dd>The config dictionary</dd></dl>
<dlclass="attribute">
<dtid="deluge.config.Config.config_file">
<ttclass="descname">config_file</tt><aclass="headerlink"href="#deluge.config.Config.config_file"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="deluge.config.Config.get_item">
<ttclass="descname">get_item</tt><big>(</big><em>key</em><big>)</big><aclass="headerlink"href="#deluge.config.Config.get_item"title="Permalink to this definition">¶</a></dt>
<dd><p>Gets the value of item ‘key’</p>
<ttclass="descname">load</tt><big>(</big><em>filename=None</em><big>)</big><aclass="headerlink"href="#deluge.config.Config.load"title="Permalink to this definition">¶</a></dt>
<trclass="field"><thclass="field-name">Parameter:</th><tdclass="field-body"><em>filename</em>– if None, uses filename set in object initialization</td>
<ttclass="descname">register_change_callback</tt><big>(</big><em>callback</em><big>)</big><aclass="headerlink"href="#deluge.config.Config.register_change_callback"title="Permalink to this definition">¶</a></dt>
<dd><p>Registers a callback function that will be called when a value is changed in the config dictionary</p>
<ttclass="descname">register_set_function</tt><big>(</big><em>key</em>, <em>function</em>, <em>apply_now=True</em><big>)</big><aclass="headerlink"href="#deluge.config.Config.register_set_function"title="Permalink to this definition">¶</a></dt>
<dd><p>Register a function to be called when a config value changes</p>
<ttclass="descname">run_converter</tt><big>(</big><em>input_range</em>, <em>output_version</em>, <em>func</em><big>)</big><aclass="headerlink"href="#deluge.config.Config.run_converter"title="Permalink to this definition">¶</a></dt>
<dd><p>Runs a function that will convert file versions in the <cite>:param:input_range</cite>
<tr><td> </td><tdclass="field-body"><pclass="first last">if the output_version is less than the input_range</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dlclass="method">
<dtid="deluge.config.Config.save">
<ttclass="descname">save</tt><big>(</big><em>filename=None</em><big>)</big><aclass="headerlink"href="#deluge.config.Config.save"title="Permalink to this definition">¶</a></dt>
<trclass="field"><thclass="field-name">Parameter:</th><tdclass="field-body"><em>filename</em>– if None, uses filename set in object initiliazation</td>
<trclass="field"><thclass="field-name">Returns:</th><tdclass="field-body">whether or not the save succeeded.</td>
</tr>
</tbody>
</table>
</dd></dl>
<dlclass="method">
<dtid="deluge.config.Config.set_item">
<ttclass="descname">set_item</tt><big>(</big><em>key</em>, <em>value</em><big>)</big><aclass="headerlink"href="#deluge.config.Config.set_item"title="Permalink to this definition">¶</a></dt>
<dd><p>Sets item ‘key’ to ‘value’ in the config dictionary, but does not allow
changing the item’s type unless it is None</p>