3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-01 17:29:21 +01:00
PyLink/docs/technical/autogen/structures.html
2016-05-27 22:39:40 -07:00

194 lines
14 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module structures</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head><body bgcolor="#f0f0f8">
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong>structures</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/gl/pylink/structures.py">/home/gl/pylink/structures.py</a></font></td></tr></table>
<p><tt>structures.py&nbsp;-&nbsp;PyLink&nbsp;data&nbsp;structures&nbsp;module.<br>
&nbsp;<br>
This&nbsp;module&nbsp;contains&nbsp;custom&nbsp;data&nbsp;structures&nbsp;that&nbsp;may&nbsp;be&nbsp;useful&nbsp;in&nbsp;various&nbsp;situations.</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
<tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="collections.html">collections</a><br>
</td><td width="25%" valign=top><a href="json.html">json</a><br>
</td><td width="25%" valign=top></td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
<tr><td bgcolor="#ee77aa"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="builtins.html#object">builtins.object</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="structures.html#DataStore">DataStore</a>
</font></dt></dl>
</dd>
<dt><font face="helvetica, arial"><a href="collections.html#defaultdict">collections.defaultdict</a>(<a href="builtins.html#dict">builtins.dict</a>)
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="structures.html#KeyedDefaultdict">KeyedDefaultdict</a>
</font></dt></dl>
</dd>
</dl>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="DataStore">class <strong>DataStore</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
<tr><td bgcolor="#ffc8d8"><tt>&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="DataStore-__contains__"><strong>__contains__</strong></a>(self, key)</dt><dd><tt>#&nbsp;single&nbsp;keys</tt></dd></dl>
<dl><dt><a name="DataStore-__init__"><strong>__init__</strong></a>(self, name, filename, db_format='json', save_frequency={'seconds': 30})</dt><dd><tt>Initialize&nbsp;self.&nbsp;&nbsp;See&nbsp;help(type(self))&nbsp;for&nbsp;accurate&nbsp;signature.</tt></dd></dl>
<dl><dt><a name="DataStore-create_or_load"><strong>create_or_load</strong></a>(self)</dt></dl>
<dl><dt><a name="DataStore-delete"><strong>delete</strong></a>(self, key)</dt></dl>
<dl><dt><a name="DataStore-delete_keys"><strong>delete_keys</strong></a>(self, prefix)</dt><dd><tt>Delete&nbsp;all&nbsp;keys&nbsp;with&nbsp;the&nbsp;given&nbsp;prefix.</tt></dd></dl>
<dl><dt><a name="DataStore-get"><strong>get</strong></a>(self, key, default=None)</dt></dl>
<dl><dt><a name="DataStore-list_keys"><strong>list_keys</strong></a>(self, prefix=None)</dt><dd><tt>Return&nbsp;all&nbsp;key&nbsp;names.&nbsp;If&nbsp;prefix&nbsp;given,&nbsp;return&nbsp;only&nbsp;keys&nbsp;that&nbsp;start&nbsp;with&nbsp;it.</tt></dd></dl>
<dl><dt><a name="DataStore-put"><strong>put</strong></a>(self, key, value)</dt></dl>
<dl><dt><a name="DataStore-save"><strong>save</strong></a>(self)</dt></dl>
<dl><dt><a name="DataStore-save_callback"><strong>save_callback</strong></a>(self, starting=False)</dt><dd><tt>Start&nbsp;the&nbsp;DB&nbsp;save&nbsp;loop.</tt></dd></dl>
<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
<hr>
Data and other attributes defined here:<br>
<dl><dt><strong>initial_version</strong> = 1</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="KeyedDefaultdict">class <strong>KeyedDefaultdict</strong></a>(<a href="collections.html#defaultdict">collections.defaultdict</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
<td colspan=2><tt>Subclass&nbsp;of&nbsp;<a href="collections.html#defaultdict">defaultdict</a>&nbsp;allowing&nbsp;the&nbsp;key&nbsp;to&nbsp;be&nbsp;passed&nbsp;to&nbsp;the&nbsp;default&nbsp;factory.<br>&nbsp;</tt></td></tr>
<tr><td>&nbsp;</td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="structures.html#KeyedDefaultdict">KeyedDefaultdict</a></dd>
<dd><a href="collections.html#defaultdict">collections.defaultdict</a></dd>
<dd><a href="builtins.html#dict">builtins.dict</a></dd>
<dd><a href="builtins.html#object">builtins.object</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="KeyedDefaultdict-__missing__"><strong>__missing__</strong></a>(self, key)</dt><dd><tt><a href="#KeyedDefaultdict-__missing__">__missing__</a>(key)&nbsp;#&nbsp;Called&nbsp;by&nbsp;__getitem__&nbsp;for&nbsp;missing&nbsp;key;&nbsp;pseudo-code:<br>
if&nbsp;self.<strong>default_factory</strong>&nbsp;is&nbsp;None:&nbsp;raise&nbsp;KeyError((key,))<br>
self[key]&nbsp;=&nbsp;value&nbsp;=&nbsp;self.<a href="#KeyedDefaultdict-default_factory">default_factory</a>()<br>
return&nbsp;value</tt></dd></dl>
<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
<hr>
Methods inherited from <a href="collections.html#defaultdict">collections.defaultdict</a>:<br>
<dl><dt><a name="KeyedDefaultdict-__copy__"><strong>__copy__</strong></a>(...)</dt><dd><tt>D.<a href="#KeyedDefaultdict-copy">copy</a>()&nbsp;-&gt;&nbsp;a&nbsp;shallow&nbsp;copy&nbsp;of&nbsp;D.</tt></dd></dl>
<dl><dt><a name="KeyedDefaultdict-__getattribute__"><strong>__getattribute__</strong></a>(self, name, /)</dt><dd><tt>Return&nbsp;getattr(self,&nbsp;name).</tt></dd></dl>
<dl><dt><a name="KeyedDefaultdict-__init__"><strong>__init__</strong></a>(self, /, *args, **kwargs)</dt><dd><tt>Initialize&nbsp;self.&nbsp;&nbsp;See&nbsp;help(type(self))&nbsp;for&nbsp;accurate&nbsp;signature.</tt></dd></dl>
<dl><dt><a name="KeyedDefaultdict-__reduce__"><strong>__reduce__</strong></a>(...)</dt><dd><tt>Return&nbsp;state&nbsp;information&nbsp;for&nbsp;pickling.</tt></dd></dl>
<dl><dt><a name="KeyedDefaultdict-__repr__"><strong>__repr__</strong></a>(self, /)</dt><dd><tt>Return&nbsp;repr(self).</tt></dd></dl>
<dl><dt><a name="KeyedDefaultdict-copy"><strong>copy</strong></a>(...)</dt><dd><tt>D.<a href="#KeyedDefaultdict-copy">copy</a>()&nbsp;-&gt;&nbsp;a&nbsp;shallow&nbsp;copy&nbsp;of&nbsp;D.</tt></dd></dl>
<hr>
Data descriptors inherited from <a href="collections.html#defaultdict">collections.defaultdict</a>:<br>
<dl><dt><strong>default_factory</strong></dt>
<dd><tt>Factory&nbsp;for&nbsp;default&nbsp;value&nbsp;called&nbsp;by&nbsp;__missing__().</tt></dd>
</dl>
<hr>
Methods inherited from <a href="builtins.html#dict">builtins.dict</a>:<br>
<dl><dt><a name="KeyedDefaultdict-__contains__"><strong>__contains__</strong></a>(self, key, /)</dt><dd><tt>True&nbsp;if&nbsp;D&nbsp;has&nbsp;a&nbsp;key&nbsp;k,&nbsp;else&nbsp;False.</tt></dd></dl>
<dl><dt><a name="KeyedDefaultdict-__delitem__"><strong>__delitem__</strong></a>(self, key, /)</dt><dd><tt>Delete&nbsp;self[key].</tt></dd></dl>
<dl><dt><a name="KeyedDefaultdict-__eq__"><strong>__eq__</strong></a>(self, value, /)</dt><dd><tt>Return&nbsp;self==value.</tt></dd></dl>
<dl><dt><a name="KeyedDefaultdict-__ge__"><strong>__ge__</strong></a>(self, value, /)</dt><dd><tt>Return&nbsp;self&gt;=value.</tt></dd></dl>
<dl><dt><a name="KeyedDefaultdict-__getitem__"><strong>__getitem__</strong></a>(...)</dt><dd><tt>x.<a href="#KeyedDefaultdict-__getitem__">__getitem__</a>(y)&nbsp;&lt;==&gt;&nbsp;x[y]</tt></dd></dl>
<dl><dt><a name="KeyedDefaultdict-__gt__"><strong>__gt__</strong></a>(self, value, /)</dt><dd><tt>Return&nbsp;self&gt;value.</tt></dd></dl>
<dl><dt><a name="KeyedDefaultdict-__iter__"><strong>__iter__</strong></a>(self, /)</dt><dd><tt>Implement&nbsp;iter(self).</tt></dd></dl>
<dl><dt><a name="KeyedDefaultdict-__le__"><strong>__le__</strong></a>(self, value, /)</dt><dd><tt>Return&nbsp;self&lt;=value.</tt></dd></dl>
<dl><dt><a name="KeyedDefaultdict-__len__"><strong>__len__</strong></a>(self, /)</dt><dd><tt>Return&nbsp;len(self).</tt></dd></dl>
<dl><dt><a name="KeyedDefaultdict-__lt__"><strong>__lt__</strong></a>(self, value, /)</dt><dd><tt>Return&nbsp;self&lt;value.</tt></dd></dl>
<dl><dt><a name="KeyedDefaultdict-__ne__"><strong>__ne__</strong></a>(self, value, /)</dt><dd><tt>Return&nbsp;self!=value.</tt></dd></dl>
<dl><dt><a name="KeyedDefaultdict-__new__"><strong>__new__</strong></a>(*args, **kwargs)<font color="#909090"><font face="helvetica, arial"> from <a href="builtins.html#type">builtins.type</a></font></font></dt><dd><tt>Create&nbsp;and&nbsp;return&nbsp;a&nbsp;new&nbsp;<a href="builtins.html#object">object</a>.&nbsp;&nbsp;See&nbsp;help(type)&nbsp;for&nbsp;accurate&nbsp;signature.</tt></dd></dl>
<dl><dt><a name="KeyedDefaultdict-__setitem__"><strong>__setitem__</strong></a>(self, key, value, /)</dt><dd><tt>Set&nbsp;self[key]&nbsp;to&nbsp;value.</tt></dd></dl>
<dl><dt><a name="KeyedDefaultdict-__sizeof__"><strong>__sizeof__</strong></a>(...)</dt><dd><tt>D.<a href="#KeyedDefaultdict-__sizeof__">__sizeof__</a>()&nbsp;-&gt;&nbsp;size&nbsp;of&nbsp;D&nbsp;in&nbsp;memory,&nbsp;in&nbsp;bytes</tt></dd></dl>
<dl><dt><a name="KeyedDefaultdict-clear"><strong>clear</strong></a>(...)</dt><dd><tt>D.<a href="#KeyedDefaultdict-clear">clear</a>()&nbsp;-&gt;&nbsp;None.&nbsp;&nbsp;Remove&nbsp;all&nbsp;items&nbsp;from&nbsp;D.</tt></dd></dl>
<dl><dt><a name="KeyedDefaultdict-fromkeys"><strong>fromkeys</strong></a>(iterable, value=None, /)<font color="#909090"><font face="helvetica, arial"> from <a href="builtins.html#type">builtins.type</a></font></font></dt><dd><tt>Returns&nbsp;a&nbsp;new&nbsp;dict&nbsp;with&nbsp;keys&nbsp;from&nbsp;iterable&nbsp;and&nbsp;values&nbsp;equal&nbsp;to&nbsp;value.</tt></dd></dl>
<dl><dt><a name="KeyedDefaultdict-get"><strong>get</strong></a>(...)</dt><dd><tt>D.<a href="#KeyedDefaultdict-get">get</a>(k[,d])&nbsp;-&gt;&nbsp;D[k]&nbsp;if&nbsp;k&nbsp;in&nbsp;D,&nbsp;else&nbsp;d.&nbsp;&nbsp;d&nbsp;defaults&nbsp;to&nbsp;None.</tt></dd></dl>
<dl><dt><a name="KeyedDefaultdict-items"><strong>items</strong></a>(...)</dt><dd><tt>D.<a href="#KeyedDefaultdict-items">items</a>()&nbsp;-&gt;&nbsp;a&nbsp;set-like&nbsp;<a href="builtins.html#object">object</a>&nbsp;providing&nbsp;a&nbsp;view&nbsp;on&nbsp;D's&nbsp;items</tt></dd></dl>
<dl><dt><a name="KeyedDefaultdict-keys"><strong>keys</strong></a>(...)</dt><dd><tt>D.<a href="#KeyedDefaultdict-keys">keys</a>()&nbsp;-&gt;&nbsp;a&nbsp;set-like&nbsp;<a href="builtins.html#object">object</a>&nbsp;providing&nbsp;a&nbsp;view&nbsp;on&nbsp;D's&nbsp;keys</tt></dd></dl>
<dl><dt><a name="KeyedDefaultdict-pop"><strong>pop</strong></a>(...)</dt><dd><tt>D.<a href="#KeyedDefaultdict-pop">pop</a>(k[,d])&nbsp;-&gt;&nbsp;v,&nbsp;remove&nbsp;specified&nbsp;key&nbsp;and&nbsp;return&nbsp;the&nbsp;corresponding&nbsp;value.<br>
If&nbsp;key&nbsp;is&nbsp;not&nbsp;found,&nbsp;d&nbsp;is&nbsp;returned&nbsp;if&nbsp;given,&nbsp;otherwise&nbsp;KeyError&nbsp;is&nbsp;raised</tt></dd></dl>
<dl><dt><a name="KeyedDefaultdict-popitem"><strong>popitem</strong></a>(...)</dt><dd><tt>D.<a href="#KeyedDefaultdict-popitem">popitem</a>()&nbsp;-&gt;&nbsp;(k,&nbsp;v),&nbsp;remove&nbsp;and&nbsp;return&nbsp;some&nbsp;(key,&nbsp;value)&nbsp;pair&nbsp;as&nbsp;a<br>
2-tuple;&nbsp;but&nbsp;raise&nbsp;KeyError&nbsp;if&nbsp;D&nbsp;is&nbsp;empty.</tt></dd></dl>
<dl><dt><a name="KeyedDefaultdict-setdefault"><strong>setdefault</strong></a>(...)</dt><dd><tt>D.<a href="#KeyedDefaultdict-setdefault">setdefault</a>(k[,d])&nbsp;-&gt;&nbsp;D.<a href="#KeyedDefaultdict-get">get</a>(k,d),&nbsp;also&nbsp;set&nbsp;D[k]=d&nbsp;if&nbsp;k&nbsp;not&nbsp;in&nbsp;D</tt></dd></dl>
<dl><dt><a name="KeyedDefaultdict-update"><strong>update</strong></a>(...)</dt><dd><tt>D.<a href="#KeyedDefaultdict-update">update</a>([E,&nbsp;]**F)&nbsp;-&gt;&nbsp;None.&nbsp;&nbsp;Update&nbsp;D&nbsp;from&nbsp;dict/iterable&nbsp;E&nbsp;and&nbsp;F.<br>
If&nbsp;E&nbsp;is&nbsp;present&nbsp;and&nbsp;has&nbsp;a&nbsp;.<a href="#KeyedDefaultdict-keys">keys</a>()&nbsp;method,&nbsp;then&nbsp;does:&nbsp;&nbsp;for&nbsp;k&nbsp;in&nbsp;E:&nbsp;D[k]&nbsp;=&nbsp;E[k]<br>
If&nbsp;E&nbsp;is&nbsp;present&nbsp;and&nbsp;lacks&nbsp;a&nbsp;.<a href="#KeyedDefaultdict-keys">keys</a>()&nbsp;method,&nbsp;then&nbsp;does:&nbsp;&nbsp;for&nbsp;k,&nbsp;v&nbsp;in&nbsp;E:&nbsp;D[k]&nbsp;=&nbsp;v<br>
In&nbsp;either&nbsp;case,&nbsp;this&nbsp;is&nbsp;followed&nbsp;by:&nbsp;for&nbsp;k&nbsp;in&nbsp;F:&nbsp;&nbsp;D[k]&nbsp;=&nbsp;F[k]</tt></dd></dl>
<dl><dt><a name="KeyedDefaultdict-values"><strong>values</strong></a>(...)</dt><dd><tt>D.<a href="#KeyedDefaultdict-values">values</a>()&nbsp;-&gt;&nbsp;an&nbsp;<a href="builtins.html#object">object</a>&nbsp;providing&nbsp;a&nbsp;view&nbsp;on&nbsp;D's&nbsp;values</tt></dd></dl>
<hr>
Data and other attributes inherited from <a href="builtins.html#dict">builtins.dict</a>:<br>
<dl><dt><strong>__hash__</strong> = None</dl>
</td></tr></table></td></tr></table>
</body></html>