文件操作 - easygui.EgStore-class.html
返回文件管理
返回主菜单
删除本文件
文件: /usr/share/doc/python2-easygui-0.96/epydoc/easygui.EgStore-class.html
编辑文件内容
<?xml version="1.0" encoding="ascii"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>easygui.EgStore</title> <link rel="stylesheet" href="epydoc.css" type="text/css" /> <script type="text/javascript" src="epydoc.js"></script> </head> <body bgcolor="white" text="black" link="blue" vlink="#204080" alink="#204080"> <!-- ==================== NAVIGATION BAR ==================== --> <table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0"> <tr valign="middle"> <!-- Home link --> <th> <a href="easygui-module.html">Home</a> </th> <!-- Tree link --> <th> <a href="module-tree.html">Trees</a> </th> <!-- Index link --> <th> <a href="identifier-index.html">Indices</a> </th> <!-- Help link --> <th> <a href="help.html">Help</a> </th> <th class="navbar" width="100%"></th> </tr> </table> <table width="100%" cellpadding="0" cellspacing="0"> <tr valign="top"> <td width="100%"> <span class="breadcrumbs"> <a href="easygui-module.html">Module easygui</a> :: Class EgStore </span> </td> <td> <table cellpadding="0" cellspacing="0"> <!-- hide/show private --> <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink" onclick="toggle_private();">hide private</a>]</span></td></tr> <tr><td align="right"><span class="options" >[<a href="frames.html" target="_top">frames</a >] | <a href="easygui.EgStore-class.html" target="_top">no frames</a>]</span></td></tr> </table> </td> </tr> </table> <!-- ==================== CLASS DESCRIPTION ==================== --> <h1 class="epydoc">Class EgStore</h1><p class="nomargin-top"><span class="codelink"><a href="easygui-pysrc.html#EgStore">source code</a></span></p> <pre class="literalblock"> A class to support persistent storage. You can use EgStore to support the storage and retrieval of user settings for an EasyGui application. # Example A #----------------------------------------------------------------------- # define a class named Settings as a subclass of EgStore #----------------------------------------------------------------------- class Settings(EgStore): def __init__(self, filename): # filename is required #------------------------------------------------- # Specify default/initial values for variables that # this particular application wants to remember. #------------------------------------------------- self.userId = "" self.targetServer = "" #------------------------------------------------- # For subclasses of EgStore, these must be # the last two statements in __init__ #------------------------------------------------- self.filename = filename # this is required self.restore() # restore values from the storage file if possible # Example B #----------------------------------------------------------------------- # create settings, a persistent Settings object #----------------------------------------------------------------------- settingsFile = "myApp_settings.txt" settings = Settings(settingsFile) user = "obama_barak" server = "whitehouse1" settings.userId = user settings.targetServer = server settings.store() # persist the settings # run code that gets a new value for userId, and persist the settings user = "biden_joe" settings.userId = user settings.store() # Example C #----------------------------------------------------------------------- # recover the Settings instance, change an attribute, and store it again. #----------------------------------------------------------------------- settings = Settings(settingsFile) settings.userId = "vanrossum_g" settings.store() </pre> <!-- ==================== INSTANCE METHODS ==================== --> <a name="section-InstanceMethods"></a> <table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr bgcolor="#70b0f0" class="table-header"> <td colspan="2" class="table-header"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr valign="top"> <td align="left"><span class="table-header">Instance Methods</span></td> <td align="right" valign="top" ><span class="options">[<a href="#section-InstanceMethods" class="privatelink" onclick="toggle_private();" >hide private</a>]</span></td> </tr> </table> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td><span class="summary-sig"><a name="__init__"></a><span class="summary-sig-name">__init__</span>(<span class="summary-sig-arg">self</span>, <span class="summary-sig-arg">filename</span>)</span></td> <td align="right" valign="top"> <span class="codelink"><a href="easygui-pysrc.html#EgStore.__init__">source code</a></span> </td> </tr> </table> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td><span class="summary-sig"><a href="easygui.EgStore-class.html#restore" class="summary-sig-name">restore</a>(<span class="summary-sig-arg">self</span>)</span><br /> Set the values of whatever attributes are recoverable from the pickle file.</td> <td align="right" valign="top"> <span class="codelink"><a href="easygui-pysrc.html#EgStore.restore">source code</a></span> </td> </tr> </table> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td><span class="summary-sig"><a href="easygui.EgStore-class.html#store" class="summary-sig-name">store</a>(<span class="summary-sig-arg">self</span>)</span><br /> Save the attributes of the EgStore object to a pickle file.</td> <td align="right" valign="top"> <span class="codelink"><a href="easygui-pysrc.html#EgStore.store">source code</a></span> </td> </tr> </table> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td><span class="summary-sig"><a href="easygui.EgStore-class.html#kill" class="summary-sig-name">kill</a>(<span class="summary-sig-arg">self</span>)</span><br /> Delete my persistent file (i.e.</td> <td align="right" valign="top"> <span class="codelink"><a href="easygui-pysrc.html#EgStore.kill">source code</a></span> </td> </tr> </table> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td><span class="summary-sig"><a name="__str__"></a><span class="summary-sig-name">__str__</span>(<span class="summary-sig-arg">self</span>)</span><br /> return my contents as a string in an easy-to-read format.</td> <td align="right" valign="top"> <span class="codelink"><a href="easygui-pysrc.html#EgStore.__str__">source code</a></span> </td> </tr> </table> </td> </tr> </table> <!-- ==================== METHOD DETAILS ==================== --> <a name="section-MethodDetails"></a> <table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr bgcolor="#70b0f0" class="table-header"> <td colspan="2" class="table-header"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr valign="top"> <td align="left"><span class="table-header">Method Details</span></td> <td align="right" valign="top" ><span class="options">[<a href="#section-MethodDetails" class="privatelink" onclick="toggle_private();" >hide private</a>]</span></td> </tr> </table> </td> </tr> </table> <a name="restore"></a> <div> <table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr><td> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr valign="top"><td> <h3 class="epydoc"><span class="sig"><span class="sig-name">restore</span>(<span class="sig-arg">self</span>)</span> </h3> </td><td align="right" valign="top" ><span class="codelink"><a href="easygui-pysrc.html#EgStore.restore">source code</a></span> </td> </tr></table> <p>Set the values of whatever attributes are recoverable from the pickle file.</p> <p>Populate the attributes (the __dict__) of the EgStore object from the attributes (the __dict__) of the pickled object.</p> <p>If the pickled object has attributes that have been initialized in the EgStore object, then those attributes of the EgStore object will be replaced by the values of the corresponding attributes in the pickled object.</p> <p>If the pickled object is missing some attributes that have been initialized in the EgStore object, then those attributes of the EgStore object will retain the values that they were initialized with.</p> <p>If the pickled object has some attributes that were not initialized in the EgStore object, then those attributes will be ignored.</p> <p>IN SUMMARY:</p> <p>After the recover() operation, the EgStore object will have all, and only, the attributes that it had when it was initialized.</p> <p>Where possible, those attributes will have values recovered from the pickled object.</p> <dl class="fields"> </dl> </td></tr></table> </div> <a name="store"></a> <div> <table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr><td> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr valign="top"><td> <h3 class="epydoc"><span class="sig"><span class="sig-name">store</span>(<span class="sig-arg">self</span>)</span> </h3> </td><td align="right" valign="top" ><span class="codelink"><a href="easygui-pysrc.html#EgStore.store">source code</a></span> </td> </tr></table> <p>Save the attributes of the EgStore object to a pickle file. Note that if the directory for the pickle file does not already exist, the store operation will fail.</p> <dl class="fields"> </dl> </td></tr></table> </div> <a name="kill"></a> <div> <table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr><td> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr valign="top"><td> <h3 class="epydoc"><span class="sig"><span class="sig-name">kill</span>(<span class="sig-arg">self</span>)</span> </h3> </td><td align="right" valign="top" ><span class="codelink"><a href="easygui-pysrc.html#EgStore.kill">source code</a></span> </td> </tr></table> <p>Delete my persistent file (i.e. pickle file), if it exists.</p> <dl class="fields"> </dl> </td></tr></table> </div> <br /> <!-- ==================== NAVIGATION BAR ==================== --> <table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0"> <tr valign="middle"> <!-- Home link --> <th> <a href="easygui-module.html">Home</a> </th> <!-- Tree link --> <th> <a href="module-tree.html">Trees</a> </th> <!-- Index link --> <th> <a href="identifier-index.html">Indices</a> </th> <!-- Help link --> <th> <a href="help.html">Help</a> </th> <th class="navbar" width="100%"></th> </tr> </table> <table border="0" cellpadding="0" cellspacing="0" width="100%%"> <tr> <td align="left" class="footer"> Generated by Epydoc 3.0.1 on Tue Jul 13 01:24:16 2010 </td> <td align="right" class="footer"> <a target="mainFrame" href="http://epydoc.sourceforge.net" >http://epydoc.sourceforge.net</a> </td> </tr> </table> <script type="text/javascript"> <!-- // Private objects are initially displayed (because if // javascript is turned off then we want them to be // visible); but by default, we want to hide them. So hide // them unless we have a cookie that says to show them. checkCookie(); // --> </script> </body> </html>
修改文件时间
将文件时间修改为当前时间的前一年
删除文件