korsygfhrtzangaiide
Elepffwdsff
/
usr
/
share
/
doc
/
python-docs-2.7.5
/
html
/
library
/
Upload FileeE
HOME
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>18.5. mhlib — Access to MH mailboxes — Python 2.7.5 documentation</title> <link rel="stylesheet" href="../_static/default.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', VERSION: '2.7.5', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="../_static/jquery.js"></script> <script type="text/javascript" src="../_static/underscore.js"></script> <script type="text/javascript" src="../_static/doctools.js"></script> <script type="text/javascript" src="../_static/sidebar.js"></script> <link rel="search" type="application/opensearchdescription+xml" title="Search within Python 2.7.5 documentation" href="../_static/opensearch.xml"/> <link rel="author" title="About these documents" href="../about.html" /> <link rel="copyright" title="Copyright" href="../copyright.html" /> <link rel="top" title="Python 2.7.5 documentation" href="../index.html" /> <link rel="up" title="18. Internet Data Handling" href="netdata.html" /> <link rel="next" title="18.6. mimetools — Tools for parsing MIME messages" href="mimetools.html" /> <link rel="prev" title="18.4. mailbox — Manipulate mailboxes in various formats" href="mailbox.html" /> <link rel="shortcut icon" type="image/png" href="../_static/py.png" /> <script type="text/javascript" src="../_static/copybutton.js"></script> </head> <body> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" accesskey="I">index</a></li> <li class="right" > <a href="../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="mimetools.html" title="18.6. mimetools — Tools for parsing MIME messages" accesskey="N">next</a> |</li> <li class="right" > <a href="mailbox.html" title="18.4. mailbox — Manipulate mailboxes in various formats" accesskey="P">previous</a> |</li> <li><img src="../_static/py.png" alt="" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="http://www.python.org/">Python</a> »</li> <li> <a href="../index.html">Python 2.7.5 documentation</a> » </li> <li><a href="index.html" >The Python Standard Library</a> »</li> <li><a href="netdata.html" accesskey="U">18. Internet Data Handling</a> »</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="module-mhlib"> <span id="mhlib-access-to-mh-mailboxes"></span><h1>18.5. <a class="reference internal" href="#module-mhlib" title="mhlib: Manipulate MH mailboxes from Python. (deprecated)"><tt class="xref py py-mod docutils literal"><span class="pre">mhlib</span></tt></a> — Access to MH mailboxes<a class="headerlink" href="#module-mhlib" title="Permalink to this headline">¶</a></h1> <p class="deprecated"> <span class="versionmodified">Deprecated since version 2.6: </span>The <a class="reference internal" href="#module-mhlib" title="mhlib: Manipulate MH mailboxes from Python. (deprecated)"><tt class="xref py py-mod docutils literal"><span class="pre">mhlib</span></tt></a> module has been removed in Python 3. Use the <a class="reference internal" href="mailbox.html#module-mailbox" title="mailbox: Manipulate mailboxes in various formats"><tt class="xref py py-mod docutils literal"><span class="pre">mailbox</span></tt></a> instead.</p> <p>The <a class="reference internal" href="#module-mhlib" title="mhlib: Manipulate MH mailboxes from Python. (deprecated)"><tt class="xref py py-mod docutils literal"><span class="pre">mhlib</span></tt></a> module provides a Python interface to MH folders and their contents.</p> <p>The module contains three basic classes, <a class="reference internal" href="#mhlib.MH" title="mhlib.MH"><tt class="xref py py-class docutils literal"><span class="pre">MH</span></tt></a>, which represents a particular collection of folders, <a class="reference internal" href="#mhlib.Folder" title="mhlib.Folder"><tt class="xref py py-class docutils literal"><span class="pre">Folder</span></tt></a>, which represents a single folder, and <a class="reference internal" href="#mhlib.Message" title="mhlib.Message"><tt class="xref py py-class docutils literal"><span class="pre">Message</span></tt></a>, which represents a single message.</p> <dl class="class"> <dt id="mhlib.MH"> <em class="property">class </em><tt class="descclassname">mhlib.</tt><tt class="descname">MH</tt><big>(</big><span class="optional">[</span><em>path</em><span class="optional">[</span>, <em>profile</em><span class="optional">]</span><span class="optional">]</span><big>)</big><a class="headerlink" href="#mhlib.MH" title="Permalink to this definition">¶</a></dt> <dd><p><a class="reference internal" href="#mhlib.MH" title="mhlib.MH"><tt class="xref py py-class docutils literal"><span class="pre">MH</span></tt></a> represents a collection of MH folders.</p> </dd></dl> <dl class="class"> <dt id="mhlib.Folder"> <em class="property">class </em><tt class="descclassname">mhlib.</tt><tt class="descname">Folder</tt><big>(</big><em>mh</em>, <em>name</em><big>)</big><a class="headerlink" href="#mhlib.Folder" title="Permalink to this definition">¶</a></dt> <dd><p>The <a class="reference internal" href="#mhlib.Folder" title="mhlib.Folder"><tt class="xref py py-class docutils literal"><span class="pre">Folder</span></tt></a> class represents a single folder and its messages.</p> </dd></dl> <dl class="class"> <dt id="mhlib.Message"> <em class="property">class </em><tt class="descclassname">mhlib.</tt><tt class="descname">Message</tt><big>(</big><em>folder</em>, <em>number</em><span class="optional">[</span>, <em>name</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#mhlib.Message" title="Permalink to this definition">¶</a></dt> <dd><p><a class="reference internal" href="#mhlib.Message" title="mhlib.Message"><tt class="xref py py-class docutils literal"><span class="pre">Message</span></tt></a> objects represent individual messages in a folder. The Message class is derived from <a class="reference internal" href="mimetools.html#mimetools.Message" title="mimetools.Message"><tt class="xref py py-class docutils literal"><span class="pre">mimetools.Message</span></tt></a>.</p> </dd></dl> <div class="section" id="mh-objects"> <span id="id1"></span><h2>18.5.1. MH Objects<a class="headerlink" href="#mh-objects" title="Permalink to this headline">¶</a></h2> <p><a class="reference internal" href="#mhlib.MH" title="mhlib.MH"><tt class="xref py py-class docutils literal"><span class="pre">MH</span></tt></a> instances have the following methods:</p> <dl class="method"> <dt id="mhlib.MH.error"> <tt class="descclassname">MH.</tt><tt class="descname">error</tt><big>(</big><em>format</em><span class="optional">[</span>, <em>...</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#mhlib.MH.error" title="Permalink to this definition">¶</a></dt> <dd><p>Print an error message – can be overridden.</p> </dd></dl> <dl class="method"> <dt id="mhlib.MH.getprofile"> <tt class="descclassname">MH.</tt><tt class="descname">getprofile</tt><big>(</big><em>key</em><big>)</big><a class="headerlink" href="#mhlib.MH.getprofile" title="Permalink to this definition">¶</a></dt> <dd><p>Return a profile entry (<tt class="docutils literal"><span class="pre">None</span></tt> if not set).</p> </dd></dl> <dl class="method"> <dt id="mhlib.MH.getpath"> <tt class="descclassname">MH.</tt><tt class="descname">getpath</tt><big>(</big><big>)</big><a class="headerlink" href="#mhlib.MH.getpath" title="Permalink to this definition">¶</a></dt> <dd><p>Return the mailbox pathname.</p> </dd></dl> <dl class="method"> <dt id="mhlib.MH.getcontext"> <tt class="descclassname">MH.</tt><tt class="descname">getcontext</tt><big>(</big><big>)</big><a class="headerlink" href="#mhlib.MH.getcontext" title="Permalink to this definition">¶</a></dt> <dd><p>Return the current folder name.</p> </dd></dl> <dl class="method"> <dt id="mhlib.MH.setcontext"> <tt class="descclassname">MH.</tt><tt class="descname">setcontext</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#mhlib.MH.setcontext" title="Permalink to this definition">¶</a></dt> <dd><p>Set the current folder name.</p> </dd></dl> <dl class="method"> <dt id="mhlib.MH.listfolders"> <tt class="descclassname">MH.</tt><tt class="descname">listfolders</tt><big>(</big><big>)</big><a class="headerlink" href="#mhlib.MH.listfolders" title="Permalink to this definition">¶</a></dt> <dd><p>Return a list of top-level folders.</p> </dd></dl> <dl class="method"> <dt id="mhlib.MH.listallfolders"> <tt class="descclassname">MH.</tt><tt class="descname">listallfolders</tt><big>(</big><big>)</big><a class="headerlink" href="#mhlib.MH.listallfolders" title="Permalink to this definition">¶</a></dt> <dd><p>Return a list of all folders.</p> </dd></dl> <dl class="method"> <dt id="mhlib.MH.listsubfolders"> <tt class="descclassname">MH.</tt><tt class="descname">listsubfolders</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#mhlib.MH.listsubfolders" title="Permalink to this definition">¶</a></dt> <dd><p>Return a list of direct subfolders of the given folder.</p> </dd></dl> <dl class="method"> <dt id="mhlib.MH.listallsubfolders"> <tt class="descclassname">MH.</tt><tt class="descname">listallsubfolders</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#mhlib.MH.listallsubfolders" title="Permalink to this definition">¶</a></dt> <dd><p>Return a list of all subfolders of the given folder.</p> </dd></dl> <dl class="method"> <dt id="mhlib.MH.makefolder"> <tt class="descclassname">MH.</tt><tt class="descname">makefolder</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#mhlib.MH.makefolder" title="Permalink to this definition">¶</a></dt> <dd><p>Create a new folder.</p> </dd></dl> <dl class="method"> <dt id="mhlib.MH.deletefolder"> <tt class="descclassname">MH.</tt><tt class="descname">deletefolder</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#mhlib.MH.deletefolder" title="Permalink to this definition">¶</a></dt> <dd><p>Delete a folder – must have no subfolders.</p> </dd></dl> <dl class="method"> <dt id="mhlib.MH.openfolder"> <tt class="descclassname">MH.</tt><tt class="descname">openfolder</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#mhlib.MH.openfolder" title="Permalink to this definition">¶</a></dt> <dd><p>Return a new open folder object.</p> </dd></dl> </div> <div class="section" id="folder-objects"> <span id="mh-folder-objects"></span><h2>18.5.2. Folder Objects<a class="headerlink" href="#folder-objects" title="Permalink to this headline">¶</a></h2> <p><a class="reference internal" href="#mhlib.Folder" title="mhlib.Folder"><tt class="xref py py-class docutils literal"><span class="pre">Folder</span></tt></a> instances represent open folders and have the following methods:</p> <dl class="method"> <dt id="mhlib.Folder.error"> <tt class="descclassname">Folder.</tt><tt class="descname">error</tt><big>(</big><em>format</em><span class="optional">[</span>, <em>...</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#mhlib.Folder.error" title="Permalink to this definition">¶</a></dt> <dd><p>Print an error message – can be overridden.</p> </dd></dl> <dl class="method"> <dt id="mhlib.Folder.getfullname"> <tt class="descclassname">Folder.</tt><tt class="descname">getfullname</tt><big>(</big><big>)</big><a class="headerlink" href="#mhlib.Folder.getfullname" title="Permalink to this definition">¶</a></dt> <dd><p>Return the folder’s full pathname.</p> </dd></dl> <dl class="method"> <dt id="mhlib.Folder.getsequencesfilename"> <tt class="descclassname">Folder.</tt><tt class="descname">getsequencesfilename</tt><big>(</big><big>)</big><a class="headerlink" href="#mhlib.Folder.getsequencesfilename" title="Permalink to this definition">¶</a></dt> <dd><p>Return the full pathname of the folder’s sequences file.</p> </dd></dl> <dl class="method"> <dt id="mhlib.Folder.getmessagefilename"> <tt class="descclassname">Folder.</tt><tt class="descname">getmessagefilename</tt><big>(</big><em>n</em><big>)</big><a class="headerlink" href="#mhlib.Folder.getmessagefilename" title="Permalink to this definition">¶</a></dt> <dd><p>Return the full pathname of message <em>n</em> of the folder.</p> </dd></dl> <dl class="method"> <dt id="mhlib.Folder.listmessages"> <tt class="descclassname">Folder.</tt><tt class="descname">listmessages</tt><big>(</big><big>)</big><a class="headerlink" href="#mhlib.Folder.listmessages" title="Permalink to this definition">¶</a></dt> <dd><p>Return a list of messages in the folder (as numbers).</p> </dd></dl> <dl class="method"> <dt id="mhlib.Folder.getcurrent"> <tt class="descclassname">Folder.</tt><tt class="descname">getcurrent</tt><big>(</big><big>)</big><a class="headerlink" href="#mhlib.Folder.getcurrent" title="Permalink to this definition">¶</a></dt> <dd><p>Return the current message number.</p> </dd></dl> <dl class="method"> <dt id="mhlib.Folder.setcurrent"> <tt class="descclassname">Folder.</tt><tt class="descname">setcurrent</tt><big>(</big><em>n</em><big>)</big><a class="headerlink" href="#mhlib.Folder.setcurrent" title="Permalink to this definition">¶</a></dt> <dd><p>Set the current message number to <em>n</em>.</p> </dd></dl> <dl class="method"> <dt id="mhlib.Folder.parsesequence"> <tt class="descclassname">Folder.</tt><tt class="descname">parsesequence</tt><big>(</big><em>seq</em><big>)</big><a class="headerlink" href="#mhlib.Folder.parsesequence" title="Permalink to this definition">¶</a></dt> <dd><p>Parse msgs syntax into list of messages.</p> </dd></dl> <dl class="method"> <dt id="mhlib.Folder.getlast"> <tt class="descclassname">Folder.</tt><tt class="descname">getlast</tt><big>(</big><big>)</big><a class="headerlink" href="#mhlib.Folder.getlast" title="Permalink to this definition">¶</a></dt> <dd><p>Get last message, or <tt class="docutils literal"><span class="pre">0</span></tt> if no messages are in the folder.</p> </dd></dl> <dl class="method"> <dt id="mhlib.Folder.setlast"> <tt class="descclassname">Folder.</tt><tt class="descname">setlast</tt><big>(</big><em>n</em><big>)</big><a class="headerlink" href="#mhlib.Folder.setlast" title="Permalink to this definition">¶</a></dt> <dd><p>Set last message (internal use only).</p> </dd></dl> <dl class="method"> <dt id="mhlib.Folder.getsequences"> <tt class="descclassname">Folder.</tt><tt class="descname">getsequences</tt><big>(</big><big>)</big><a class="headerlink" href="#mhlib.Folder.getsequences" title="Permalink to this definition">¶</a></dt> <dd><p>Return dictionary of sequences in folder. The sequence names are used as keys, and the values are the lists of message numbers in the sequences.</p> </dd></dl> <dl class="method"> <dt id="mhlib.Folder.putsequences"> <tt class="descclassname">Folder.</tt><tt class="descname">putsequences</tt><big>(</big><em>dict</em><big>)</big><a class="headerlink" href="#mhlib.Folder.putsequences" title="Permalink to this definition">¶</a></dt> <dd><p>Return dictionary of sequences in folder name: list.</p> </dd></dl> <dl class="method"> <dt id="mhlib.Folder.removemessages"> <tt class="descclassname">Folder.</tt><tt class="descname">removemessages</tt><big>(</big><em>list</em><big>)</big><a class="headerlink" href="#mhlib.Folder.removemessages" title="Permalink to this definition">¶</a></dt> <dd><p>Remove messages in list from folder.</p> </dd></dl> <dl class="method"> <dt id="mhlib.Folder.refilemessages"> <tt class="descclassname">Folder.</tt><tt class="descname">refilemessages</tt><big>(</big><em>list</em>, <em>tofolder</em><big>)</big><a class="headerlink" href="#mhlib.Folder.refilemessages" title="Permalink to this definition">¶</a></dt> <dd><p>Move messages in list to other folder.</p> </dd></dl> <dl class="method"> <dt id="mhlib.Folder.movemessage"> <tt class="descclassname">Folder.</tt><tt class="descname">movemessage</tt><big>(</big><em>n</em>, <em>tofolder</em>, <em>ton</em><big>)</big><a class="headerlink" href="#mhlib.Folder.movemessage" title="Permalink to this definition">¶</a></dt> <dd><p>Move one message to a given destination in another folder.</p> </dd></dl> <dl class="method"> <dt id="mhlib.Folder.copymessage"> <tt class="descclassname">Folder.</tt><tt class="descname">copymessage</tt><big>(</big><em>n</em>, <em>tofolder</em>, <em>ton</em><big>)</big><a class="headerlink" href="#mhlib.Folder.copymessage" title="Permalink to this definition">¶</a></dt> <dd><p>Copy one message to a given destination in another folder.</p> </dd></dl> </div> <div class="section" id="message-objects"> <span id="mh-message-objects"></span><h2>18.5.3. Message Objects<a class="headerlink" href="#message-objects" title="Permalink to this headline">¶</a></h2> <p>The <a class="reference internal" href="#mhlib.Message" title="mhlib.Message"><tt class="xref py py-class docutils literal"><span class="pre">Message</span></tt></a> class adds one method to those of <a class="reference internal" href="mimetools.html#mimetools.Message" title="mimetools.Message"><tt class="xref py py-class docutils literal"><span class="pre">mimetools.Message</span></tt></a>:</p> <dl class="method"> <dt id="mhlib.Message.openmessage"> <tt class="descclassname">Message.</tt><tt class="descname">openmessage</tt><big>(</big><em>n</em><big>)</big><a class="headerlink" href="#mhlib.Message.openmessage" title="Permalink to this definition">¶</a></dt> <dd><p>Return a new open message object (costs a file descriptor).</p> </dd></dl> </div> </div> </div> </div> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h3><a href="../contents.html">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">18.5. <tt class="docutils literal"><span class="pre">mhlib</span></tt> — Access to MH mailboxes</a><ul> <li><a class="reference internal" href="#mh-objects">18.5.1. MH Objects</a></li> <li><a class="reference internal" href="#folder-objects">18.5.2. Folder Objects</a></li> <li><a class="reference internal" href="#message-objects">18.5.3. Message Objects</a></li> </ul> </li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="mailbox.html" title="previous chapter">18.4. <tt class="docutils literal"><span class="pre">mailbox</span></tt> — Manipulate mailboxes in various formats</a></p> <h4>Next topic</h4> <p class="topless"><a href="mimetools.html" title="next chapter">18.6. <tt class="docutils literal"><span class="pre">mimetools</span></tt> — Tools for parsing MIME messages</a></p> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../bugs.html">Report a Bug</a></li> <li><a href="../_sources/library/mhlib.txt" rel="nofollow">Show Source</a></li> </ul> <div id="searchbox" style="display: none"> <h3>Quick search</h3> <form class="search" action="../search.html" method="get"> <input type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> <p class="searchtip" style="font-size: 90%"> Enter search terms or a module, class or function name. </p> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" >index</a></li> <li class="right" > <a href="../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="mimetools.html" title="18.6. mimetools — Tools for parsing MIME messages" >next</a> |</li> <li class="right" > <a href="mailbox.html" title="18.4. mailbox — Manipulate mailboxes in various formats" >previous</a> |</li> <li><img src="../_static/py.png" alt="" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="http://www.python.org/">Python</a> »</li> <li> <a href="../index.html">Python 2.7.5 documentation</a> » </li> <li><a href="index.html" >The Python Standard Library</a> »</li> <li><a href="netdata.html" >18. Internet Data Handling</a> »</li> </ul> </div> <div class="footer"> © <a href="../copyright.html">Copyright</a> 1990-2019, Python Software Foundation. <br /> The Python Software Foundation is a non-profit corporation. <a href="http://www.python.org/psf/donations/">Please donate.</a> <br /> Last updated on Jul 03, 2019. <a href="../bugs.html">Found a bug</a>? <br /> Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3. </div> </body> </html>