storage.html 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <!doctype html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2. <html><head><title>Python: storage</title>
  3. </head><body bgcolor="#f0f0f8">
  4. <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
  5. <tr bgcolor="#7799ee">
  6. <td valign=bottom>&nbsp;<br>
  7. <font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong>storage</strong></big></big></font></td
  8. ><td align=right valign=bottom
  9. ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br>(built-in)</font></td></tr></table>
  10. <p><tt>The&nbsp;storage&nbsp;module&nbsp;allows&nbsp;users&nbsp;to&nbsp;save&nbsp;information&nbsp;to&nbsp;disk&nbsp;as&nbsp;key:value<br>
  11. pairs&nbsp;without&nbsp;having&nbsp;to&nbsp;interact&nbsp;with&nbsp;files&nbsp;directly.&nbsp;This&nbsp;module&nbsp;gives<br>
  12. users&nbsp;access&nbsp;to&nbsp;two&nbsp;classes:&nbsp;StorageSets&nbsp;and&nbsp;StorageLists.&nbsp;Sets&nbsp;match<br>
  13. keys&nbsp;to&nbsp;values.&nbsp;Lists&nbsp;hold&nbsp;multiple&nbsp;sets.</tt></p>
  14. <p>
  15. <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
  16. <tr bgcolor="#ee77aa">
  17. <td colspan=3 valign=bottom>&nbsp;<br>
  18. <font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
  19. <tr><td bgcolor="#ee77aa"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
  20. <td width="100%"><dl>
  21. <dt><font face="helvetica, arial"><a href="__builtin__.html#object">__builtin__.object</a>
  22. </font></dt><dd>
  23. <dl>
  24. <dt><font face="helvetica, arial"><a href="storage.html#StorageList">StorageList</a>
  25. </font></dt><dt><font face="helvetica, arial"><a href="storage.html#StorageSet">StorageSet</a>
  26. </font></dt></dl>
  27. </dd>
  28. </dl>
  29. <p>
  30. <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
  31. <tr bgcolor="#ffc8d8">
  32. <td colspan=3 valign=bottom>&nbsp;<br>
  33. <font color="#000000" face="helvetica, arial"><a name="StorageList">class <strong>StorageList</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr>
  34. <tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
  35. <td colspan=2><tt><a href="#StorageList-__init__">__init__</a>(self,&nbsp;list=None)<br>
  36. &nbsp;<br>
  37. Create&nbsp;a&nbsp;new&nbsp;storage&nbsp;list.&nbsp;A&nbsp;Python&nbsp;list&nbsp;of&nbsp;storage&nbsp;sets&nbsp;may&nbsp;be<br>
  38. supplied,&nbsp;from&nbsp;which&nbsp;to&nbsp;build&nbsp;the&nbsp;storage&nbsp;list.<br>&nbsp;</tt></td></tr>
  39. <tr><td>&nbsp;</td>
  40. <td width="100%">Methods defined here:<br>
  41. <dl><dt><a name="StorageList-__init__"><strong>__init__</strong></a>(...)</dt><dd><tt>x.<a href="#StorageList-__init__">__init__</a>(...)&nbsp;initializes&nbsp;x;&nbsp;see&nbsp;x.__class__.__doc__&nbsp;for&nbsp;signature</tt></dd></dl>
  42. <dl><dt><a name="StorageList-add"><strong>add</strong></a>(...)</dt><dd><tt><a href="#StorageList-add">add</a>(storage_set)<br>
  43. &nbsp;<br>
  44. Append&nbsp;a&nbsp;new&nbsp;storage&nbsp;set&nbsp;to&nbsp;the&nbsp;storage&nbsp;list.</tt></dd></dl>
  45. <dl><dt><a name="StorageList-sets"><strong>sets</strong></a>(...)</dt><dd><tt><a href="#StorageList-sets">sets</a>()<br>
  46. &nbsp;<br>
  47. Returns&nbsp;a&nbsp;python&nbsp;list&nbsp;of&nbsp;all&nbsp;the&nbsp;sets&nbsp;in&nbsp;the&nbsp;storage&nbsp;list.</tt></dd></dl>
  48. <hr>
  49. Data and other attributes defined here:<br>
  50. <dl><dt><strong>__new__</strong> = &lt;built-in method __new__ of type object at 0x6fca0&gt;<dd><tt>T.<a href="#StorageList-__new__">__new__</a>(S,&nbsp;...)&nbsp;-&gt;&nbsp;a&nbsp;new&nbsp;<a href="__builtin__.html#object">object</a>&nbsp;with&nbsp;type&nbsp;S,&nbsp;a&nbsp;subtype&nbsp;of&nbsp;T</tt></dl>
  51. </td></tr></table> <p>
  52. <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
  53. <tr bgcolor="#ffc8d8">
  54. <td colspan=3 valign=bottom>&nbsp;<br>
  55. <font color="#000000" face="helvetica, arial"><a name="StorageSet">class <strong>StorageSet</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr>
  56. <tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
  57. <td colspan=2><tt><a href="#StorageSet-__init__">__init__</a>(self,&nbsp;filename=None)<br>
  58. &nbsp;<br>
  59. Create&nbsp;a&nbsp;new&nbsp;storage&nbsp;set.&nbsp;If&nbsp;a&nbsp;file&nbsp;name&nbsp;is&nbsp;supplied,&nbsp;read&nbsp;a&nbsp;storage&nbsp;set<br>
  60. in&nbsp;from&nbsp;the&nbsp;specified&nbsp;file.<br>&nbsp;</tt></td></tr>
  61. <tr><td>&nbsp;</td>
  62. <td width="100%">Methods defined here:<br>
  63. <dl><dt><a name="StorageSet-__contains__"><strong>__contains__</strong></a>(...)</dt><dd><tt><a href="#StorageSet-__contains__">__contains__</a>(name)&nbsp;&lt;==&gt;&nbsp;name&nbsp;in&nbsp;self</tt></dd></dl>
  64. <dl><dt><a name="StorageSet-__init__"><strong>__init__</strong></a>(...)</dt><dd><tt>x.<a href="#StorageSet-__init__">__init__</a>(...)&nbsp;initializes&nbsp;x;&nbsp;see&nbsp;x.__class__.__doc__&nbsp;for&nbsp;signature</tt></dd></dl>
  65. <dl><dt><a name="StorageSet-close"><strong>close</strong></a>(...)</dt><dd><tt><a href="#StorageSet-close">close</a>()<br>
  66. &nbsp;<br>
  67. Recursively&nbsp;close&nbsp;a&nbsp;storage&nbsp;set&nbsp;and&nbsp;all&nbsp;of&nbsp;its&nbsp;children&nbsp;sets&nbsp;and&nbsp;lists.<br>
  68. MUST&nbsp;be&nbsp;called&nbsp;when&nbsp;the&nbsp;storage&nbsp;set&nbsp;has&nbsp;finished&nbsp;being&nbsp;used.&nbsp;Garbage<br>
  69. collection&nbsp;will&nbsp;not&nbsp;delete&nbsp;the&nbsp;set.</tt></dd></dl>
  70. <dl><dt><a name="StorageSet-contains"><strong>contains</strong></a>(...)</dt><dd><tt><a href="#StorageSet-contains">contains</a>(name)<br>
  71. &nbsp;<br>
  72. Returns&nbsp;True&nbsp;or&nbsp;False&nbsp;if&nbsp;the&nbsp;set&nbsp;contains&nbsp;an&nbsp;entry&nbsp;by&nbsp;the&nbsp;given&nbsp;name.</tt></dd></dl>
  73. <dl><dt><a name="StorageSet-readBool"><strong>readBool</strong></a>(...)</dt><dd><tt>Same&nbsp;as&nbsp;readString,&nbsp;for&nbsp;booleans.&nbsp;Returns&nbsp;False&nbsp;if&nbsp;entry&nbsp;does&nbsp;not&nbsp;exist.</tt></dd></dl>
  74. <dl><dt><a name="StorageSet-readDouble"><strong>readDouble</strong></a>(...)</dt><dd><tt>Same&nbsp;as&nbsp;readString,&nbsp;for&nbsp;floating&nbsp;points.&nbsp;Returns&nbsp;0&nbsp;if&nbsp;entry&nbsp;does&nbsp;not&nbsp;exist..</tt></dd></dl>
  75. <dl><dt><a name="StorageSet-readInt"><strong>readInt</strong></a>(...)</dt><dd><tt>Same&nbsp;as&nbsp;readString,&nbsp;for&nbsp;integers.&nbsp;Returns&nbsp;0&nbsp;if&nbsp;entry&nbsp;does&nbsp;not&nbsp;exist.</tt></dd></dl>
  76. <dl><dt><a name="StorageSet-readList"><strong>readList</strong></a>(...)</dt><dd><tt>Same&nbsp;as&nbsp;readString,&nbsp;for&nbsp;storage&nbsp;lists.&nbsp;Returns&nbsp;an&nbsp;empty&nbsp;storage&nbsp;list<br>
  77. if&nbsp;entry&nbsp;does&nbsp;not&nbsp;exist.</tt></dd></dl>
  78. <dl><dt><a name="StorageSet-readSet"><strong>readSet</strong></a>(...)</dt><dd><tt>Same&nbsp;as&nbsp;readString,&nbsp;for&nbsp;storage&nbsp;sets.&nbsp;Returns&nbsp;an&nbsp;empty&nbsp;set&nbsp;if&nbsp;entry<br>
  79. does&nbsp;not&nbsp;exist.</tt></dd></dl>
  80. <dl><dt><a name="StorageSet-readString"><strong>readString</strong></a>(...)</dt><dd><tt><a href="#StorageSet-readString">readString</a>(name)<br>
  81. &nbsp;<br>
  82. Read&nbsp;a&nbsp;string&nbsp;value&nbsp;from&nbsp;the&nbsp;storage&nbsp;set.&nbsp;Return&nbsp;empty&nbsp;string&nbsp;if&nbsp;the<br>
  83. storage&nbsp;set&nbsp;does&nbsp;not&nbsp;contain&nbsp;an&nbsp;entry&nbsp;by&nbsp;the&nbsp;given&nbsp;name.</tt></dd></dl>
  84. <dl><dt><a name="StorageSet-storeBool"><strong>storeBool</strong></a>(...)</dt><dd><tt>Same&nbsp;as&nbsp;storeString,&nbsp;for&nbsp;boolean&nbsp;values.</tt></dd></dl>
  85. <dl><dt><a name="StorageSet-storeDouble"><strong>storeDouble</strong></a>(...)</dt><dd><tt>Same&nbsp;as&nbsp;storeString,&nbsp;for&nbsp;floating&nbsp;point&nbsp;values.</tt></dd></dl>
  86. <dl><dt><a name="StorageSet-storeInt"><strong>storeInt</strong></a>(...)</dt><dd><tt>Same&nbsp;as&nbsp;storeString,&nbsp;for&nbsp;integers.</tt></dd></dl>
  87. <dl><dt><a name="StorageSet-storeList"><strong>storeList</strong></a>(...)</dt><dd><tt>Same&nbsp;as&nbsp;storeString,&nbsp;for&nbsp;storage&nbsp;lists.</tt></dd></dl>
  88. <dl><dt><a name="StorageSet-storeSet"><strong>storeSet</strong></a>(...)</dt><dd><tt>Same&nbsp;as&nbsp;storeString,&nbsp;for&nbsp;storage&nbsp;sets.</tt></dd></dl>
  89. <dl><dt><a name="StorageSet-storeString"><strong>storeString</strong></a>(...)</dt><dd><tt><a href="#StorageSet-storeString">storeString</a>(name,&nbsp;val)<br>
  90. &nbsp;<br>
  91. Store&nbsp;a&nbsp;string&nbsp;value&nbsp;in&nbsp;the&nbsp;storage&nbsp;set.</tt></dd></dl>
  92. <dl><dt><a name="StorageSet-write"><strong>write</strong></a>(...)</dt><dd><tt><a href="#StorageSet-write">write</a>(filename)<br>
  93. &nbsp;<br>
  94. Write&nbsp;the&nbsp;contents&nbsp;of&nbsp;a&nbsp;storage&nbsp;set&nbsp;to&nbsp;the&nbsp;specified&nbsp;file&nbsp;name.</tt></dd></dl>
  95. <hr>
  96. Data and other attributes defined here:<br>
  97. <dl><dt><strong>__new__</strong> = &lt;built-in method __new__ of type object at 0x6fac0&gt;<dd><tt>T.<a href="#StorageSet-__new__">__new__</a>(S,&nbsp;...)&nbsp;-&gt;&nbsp;a&nbsp;new&nbsp;<a href="__builtin__.html#object">object</a>&nbsp;with&nbsp;type&nbsp;S,&nbsp;a&nbsp;subtype&nbsp;of&nbsp;T</tt></dl>
  98. </td></tr></table></td></tr></table>
  99. </body></html>