Sophie

Sophie

distrib > Mandriva > 2010.1 > x86_64 > media > contrib-backports > by-pkgid > 3ba3bd1608c672ba2129b098a48e9e4d > files > 670

python3-docs-3.2.2-3mdv2010.2.noarch.rpm



<!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.1.10. email: Iterators &mdash; Python v3.2.2 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:     '3.2.2',
        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 v3.2.2 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 v3.2.2 documentation" href="../index.html" />
    <link rel="up" title="18.1. email — An email and MIME handling package" href="email.html" />
    <link rel="next" title="18.1.11. email: Examples" href="email-examples.html" />
    <link rel="prev" title="18.1.9. email: Miscellaneous utilities" href="email.util.html" />
    <link rel="shortcut icon" type="image/png" href="../_static/py.png" />
 

  </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="email-examples.html" title="18.1.11. email: Examples"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="email.util.html" title="18.1.9. email: Miscellaneous utilities"
             accesskey="P">previous</a> |</li>
        <li><img src="../_static/py.png" alt=""
                 style="vertical-align: middle; margin-top: -1px"/></li>
        <li><a href="../index.html">Python v3.2.2 documentation</a> &raquo;</li>

          <li><a href="index.html" >The Python Standard Library</a> &raquo;</li>
          <li><a href="netdata.html" >18. Internet Data Handling</a> &raquo;</li>
          <li><a href="email.html" accesskey="U">18.1. <tt class="docutils literal docutils literal docutils literal docutils literal docutils literal docutils literal docutils literal docutils literal"><span class="pre">email</span></tt> &#8212; An email and MIME handling package</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="module-email.iterators">
<span id="email-iterators"></span><h1>18.1.10. <a class="reference internal" href="email.html#module-email" title="email: Package supporting the parsing, manipulating, and generating email messages, including MIME documents."><tt class="xref py py-mod docutils literal"><span class="pre">email</span></tt></a>: Iterators<a class="headerlink" href="#module-email.iterators" title="Permalink to this headline">¶</a></h1>
<p>Iterating over a message object tree is fairly easy with the
<tt class="xref py py-meth docutils literal"><span class="pre">Message.walk()</span></tt> method.  The <a class="reference internal" href="#module-email.iterators" title="email.iterators: Iterate over a  message object tree."><tt class="xref py py-mod docutils literal"><span class="pre">email.iterators</span></tt></a> module provides some
useful higher level iterations over message object trees.</p>
<dl class="function">
<dt id="email.iterators.body_line_iterator">
<tt class="descclassname">email.iterators.</tt><tt class="descname">body_line_iterator</tt><big>(</big><em>msg</em>, <em>decode=False</em><big>)</big><a class="headerlink" href="#email.iterators.body_line_iterator" title="Permalink to this definition">¶</a></dt>
<dd><p>This iterates over all the payloads in all the subparts of <em>msg</em>, returning the
string payloads line-by-line.  It skips over all the subpart headers, and it
skips over any subpart with a payload that isn&#8217;t a Python string.  This is
somewhat equivalent to reading the flat text representation of the message from
a file using <a class="reference internal" href="readline.html#module-readline" title="readline: GNU readline support for Python. (Unix)"><tt class="xref py py-meth docutils literal"><span class="pre">readline()</span></tt></a>, skipping over all the intervening headers.</p>
<p>Optional <em>decode</em> is passed through to <tt class="xref py py-meth docutils literal"><span class="pre">Message.get_payload()</span></tt>.</p>
</dd></dl>

<dl class="function">
<dt id="email.iterators.typed_subpart_iterator">
<tt class="descclassname">email.iterators.</tt><tt class="descname">typed_subpart_iterator</tt><big>(</big><em>msg</em>, <em>maintype='text'</em>, <em>subtype=None</em><big>)</big><a class="headerlink" href="#email.iterators.typed_subpart_iterator" title="Permalink to this definition">¶</a></dt>
<dd><p>This iterates over all the subparts of <em>msg</em>, returning only those subparts that
match the MIME type specified by <em>maintype</em> and <em>subtype</em>.</p>
<p>Note that <em>subtype</em> is optional; if omitted, then subpart MIME type matching is
done only with the main type.  <em>maintype</em> is optional too; it defaults to
<em class="mimetype">text</em>.</p>
<p>Thus, by default <a class="reference internal" href="#email.iterators.typed_subpart_iterator" title="email.iterators.typed_subpart_iterator"><tt class="xref py py-func docutils literal"><span class="pre">typed_subpart_iterator()</span></tt></a> returns each subpart that has a
MIME type of <em class="mimetype">text/*</em>.</p>
</dd></dl>

<p>The following function has been added as a useful debugging tool.  It should
<em>not</em> be considered part of the supported public interface for the package.</p>
<dl class="function">
<dt id="email.iterators._structure">
<tt class="descclassname">email.iterators.</tt><tt class="descname">_structure</tt><big>(</big><em>msg</em>, <em>fp=None</em>, <em>level=0</em>, <em>include_default=False</em><big>)</big><a class="headerlink" href="#email.iterators._structure" title="Permalink to this definition">¶</a></dt>
<dd><p>Prints an indented representation of the content types of the message object
structure.  For example:</p>
<div class="highlight-python3"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">msg</span> <span class="o">=</span> <span class="n">email</span><span class="o">.</span><span class="n">message_from_file</span><span class="p">(</span><span class="n">somefile</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">_structure</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span>
<span class="go">multipart/mixed</span>
<span class="go">    text/plain</span>
<span class="go">    text/plain</span>
<span class="go">    multipart/digest</span>
<span class="go">        message/rfc822</span>
<span class="go">            text/plain</span>
<span class="go">        message/rfc822</span>
<span class="go">            text/plain</span>
<span class="go">        message/rfc822</span>
<span class="go">            text/plain</span>
<span class="go">        message/rfc822</span>
<span class="go">            text/plain</span>
<span class="go">        message/rfc822</span>
<span class="go">            text/plain</span>
<span class="go">    text/plain</span>
</pre></div>
</div>
<p>Optional <em>fp</em> is a file-like object to print the output to.  It must be
suitable for Python&#8217;s <a class="reference internal" href="functions.html#print" title="print"><tt class="xref py py-func docutils literal"><span class="pre">print()</span></tt></a> function.  <em>level</em> is used internally.
<em>include_default</em>, if true, prints the default type as well.</p>
</dd></dl>

</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h4>Previous topic</h4>
  <p class="topless"><a href="email.util.html"
                        title="previous chapter">18.1.9. <tt class="docutils literal docutils literal"><span class="pre">email</span></tt>: Miscellaneous utilities</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="email-examples.html"
                        title="next chapter">18.1.11. <tt class="docutils literal docutils literal"><span class="pre">email</span></tt>: Examples</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/email.iterators.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" size="18" />
      <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="email-examples.html" title="18.1.11. email: Examples"
             >next</a> |</li>
        <li class="right" >
          <a href="email.util.html" title="18.1.9. email: Miscellaneous utilities"
             >previous</a> |</li>
        <li><img src="../_static/py.png" alt=""
                 style="vertical-align: middle; margin-top: -1px"/></li>
        <li><a href="../index.html">Python v3.2.2 documentation</a> &raquo;</li>

          <li><a href="index.html" >The Python Standard Library</a> &raquo;</li>
          <li><a href="netdata.html" >18. Internet Data Handling</a> &raquo;</li>
          <li><a href="email.html" >18.1. <tt class="docutils literal docutils literal docutils literal docutils literal docutils literal docutils literal docutils literal docutils literal"><span class="pre">email</span></tt> &#8212; An email and MIME handling package</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
    &copy; <a href="../copyright.html">Copyright</a> 1990-2011, 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 Sep 04, 2011.
    <a href="../bugs.html">Found a bug</a>?
    <br />
    Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
    </div>

  </body>
</html>