mirror of
https://github.com/jlu5/PyLink.git
synced 2024-12-26 12:43:09 +01:00
194 lines
14 KiB
HTML
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> <br>
|
|
<font color="#ffffff" face="helvetica, arial"> <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 - PyLink data structures module.<br>
|
|
<br>
|
|
This module contains custom data structures that may be useful in various situations.</tt></p>
|
|
<p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#aa55cc">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
|
|
|
|
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </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> <br>
|
|
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
|
|
|
|
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </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> <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> </tt></td><td> </td>
|
|
<td width="100%">Methods defined here:<br>
|
|
<dl><dt><a name="DataStore-__contains__"><strong>__contains__</strong></a>(self, key)</dt><dd><tt># single 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 self. See help(type(self)) for accurate 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 all keys with the given 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 all key names. If prefix given, return only keys that start with 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 the DB save loop.</tt></dd></dl>
|
|
|
|
<hr>
|
|
Data descriptors defined here:<br>
|
|
<dl><dt><strong>__dict__</strong></dt>
|
|
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
|
|
</dl>
|
|
<dl><dt><strong>__weakref__</strong></dt>
|
|
<dd><tt>list of weak references to the object (if 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> <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> </tt></td>
|
|
<td colspan=2><tt>Subclass of <a href="collections.html#defaultdict">defaultdict</a> allowing the key to be passed to the default factory.<br> </tt></td></tr>
|
|
<tr><td> </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) # Called by __getitem__ for missing key; pseudo-code:<br>
|
|
if self.<strong>default_factory</strong> is None: raise KeyError((key,))<br>
|
|
self[key] = value = self.<a href="#KeyedDefaultdict-default_factory">default_factory</a>()<br>
|
|
return value</tt></dd></dl>
|
|
|
|
<hr>
|
|
Data descriptors defined here:<br>
|
|
<dl><dt><strong>__dict__</strong></dt>
|
|
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
|
|
</dl>
|
|
<dl><dt><strong>__weakref__</strong></dt>
|
|
<dd><tt>list of weak references to the object (if 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>() -> a shallow copy of D.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="KeyedDefaultdict-__getattribute__"><strong>__getattribute__</strong></a>(self, name, /)</dt><dd><tt>Return getattr(self, name).</tt></dd></dl>
|
|
|
|
<dl><dt><a name="KeyedDefaultdict-__init__"><strong>__init__</strong></a>(self, /, *args, **kwargs)</dt><dd><tt>Initialize self. See help(type(self)) for accurate signature.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="KeyedDefaultdict-__reduce__"><strong>__reduce__</strong></a>(...)</dt><dd><tt>Return state information for pickling.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="KeyedDefaultdict-__repr__"><strong>__repr__</strong></a>(self, /)</dt><dd><tt>Return 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>() -> a shallow copy of 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 for default value called by __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 if D has a key k, else False.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="KeyedDefaultdict-__delitem__"><strong>__delitem__</strong></a>(self, key, /)</dt><dd><tt>Delete self[key].</tt></dd></dl>
|
|
|
|
<dl><dt><a name="KeyedDefaultdict-__eq__"><strong>__eq__</strong></a>(self, value, /)</dt><dd><tt>Return self==value.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="KeyedDefaultdict-__ge__"><strong>__ge__</strong></a>(self, value, /)</dt><dd><tt>Return self>=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) <==> x[y]</tt></dd></dl>
|
|
|
|
<dl><dt><a name="KeyedDefaultdict-__gt__"><strong>__gt__</strong></a>(self, value, /)</dt><dd><tt>Return self>value.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="KeyedDefaultdict-__iter__"><strong>__iter__</strong></a>(self, /)</dt><dd><tt>Implement iter(self).</tt></dd></dl>
|
|
|
|
<dl><dt><a name="KeyedDefaultdict-__le__"><strong>__le__</strong></a>(self, value, /)</dt><dd><tt>Return self<=value.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="KeyedDefaultdict-__len__"><strong>__len__</strong></a>(self, /)</dt><dd><tt>Return len(self).</tt></dd></dl>
|
|
|
|
<dl><dt><a name="KeyedDefaultdict-__lt__"><strong>__lt__</strong></a>(self, value, /)</dt><dd><tt>Return self<value.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="KeyedDefaultdict-__ne__"><strong>__ne__</strong></a>(self, value, /)</dt><dd><tt>Return 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 and return a new <a href="builtins.html#object">object</a>. See help(type) for accurate signature.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="KeyedDefaultdict-__setitem__"><strong>__setitem__</strong></a>(self, key, value, /)</dt><dd><tt>Set self[key] to value.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="KeyedDefaultdict-__sizeof__"><strong>__sizeof__</strong></a>(...)</dt><dd><tt>D.<a href="#KeyedDefaultdict-__sizeof__">__sizeof__</a>() -> size of D in memory, in bytes</tt></dd></dl>
|
|
|
|
<dl><dt><a name="KeyedDefaultdict-clear"><strong>clear</strong></a>(...)</dt><dd><tt>D.<a href="#KeyedDefaultdict-clear">clear</a>() -> None. Remove all items from 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 a new dict with keys from iterable and values equal to 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]) -> D[k] if k in D, else d. d defaults to None.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="KeyedDefaultdict-items"><strong>items</strong></a>(...)</dt><dd><tt>D.<a href="#KeyedDefaultdict-items">items</a>() -> a set-like <a href="builtins.html#object">object</a> providing a view on D's items</tt></dd></dl>
|
|
|
|
<dl><dt><a name="KeyedDefaultdict-keys"><strong>keys</strong></a>(...)</dt><dd><tt>D.<a href="#KeyedDefaultdict-keys">keys</a>() -> a set-like <a href="builtins.html#object">object</a> providing a view on D's 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]) -> v, remove specified key and return the corresponding value.<br>
|
|
If key is not found, d is returned if given, otherwise KeyError is raised</tt></dd></dl>
|
|
|
|
<dl><dt><a name="KeyedDefaultdict-popitem"><strong>popitem</strong></a>(...)</dt><dd><tt>D.<a href="#KeyedDefaultdict-popitem">popitem</a>() -> (k, v), remove and return some (key, value) pair as a<br>
|
|
2-tuple; but raise KeyError if D is 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]) -> D.<a href="#KeyedDefaultdict-get">get</a>(k,d), also set D[k]=d if k not in 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, ]**F) -> None. Update D from dict/iterable E and F.<br>
|
|
If E is present and has a .<a href="#KeyedDefaultdict-keys">keys</a>() method, then does: for k in E: D[k] = E[k]<br>
|
|
If E is present and lacks a .<a href="#KeyedDefaultdict-keys">keys</a>() method, then does: for k, v in E: D[k] = v<br>
|
|
In either case, this is followed by: for k in F: D[k] = 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>() -> an <a href="builtins.html#object">object</a> providing a view on D's 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> |