Sophie

Sophie

distrib > Mageia > 6 > armv5tl > by-pkgid > a600cd26dfe6bfd8c11f12bce5cb0eee > files > 822

python3-docs-3.5.3-1.1.mga6.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>19.5. mimetypes — Map filenames to MIME types &mdash; Python 3.5.3 documentation</title>
    
    <link rel="stylesheet" href="../_static/pydoctheme.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.5.3',
        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 3.5.3 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 3.5.3 documentation" href="../contents.html" />
    <link rel="up" title="19. Internet Data Handling" href="netdata.html" />
    <link rel="next" title="19.6. base64 — Base16, Base32, Base64, Base85 Data Encodings" href="base64.html" />
    <link rel="prev" title="19.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>
    <script type="text/javascript" src="../_static/version_switch.js"></script>
    
    
 

  </head>
  <body role="document">  
    <div class="related" role="navigation" aria-label="related navigation">
      <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="base64.html" title="19.6. base64 — Base16, Base32, Base64, Base85 Data Encodings"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="mailbox.html" title="19.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="https://www.python.org/">Python</a> &raquo;</li>
        <li>
          <span class="version_switcher_placeholder">3.5.3</span>
          <a href="../index.html">Documentation </a> &raquo;
        </li>

          <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &raquo;</li>
          <li class="nav-item nav-item-2"><a href="netdata.html" accesskey="U">19. Internet Data Handling</a> &raquo;</li>
    <li class="right">
        

    <div class="inline-search" style="display: none" role="search">
        <form class="inline-search" action="../search.html" method="get">
          <input placeholder="Quick search" 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>
    </div>
    <script type="text/javascript">$('.inline-search').show(0);</script>
         |
    </li>

      </ul>
    </div>    

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="module-mimetypes">
<span id="mimetypes-map-filenames-to-mime-types"></span><h1>19.5. <a class="reference internal" href="#module-mimetypes" title="mimetypes: Mapping of filename extensions to MIME types."><code class="xref py py-mod docutils literal"><span class="pre">mimetypes</span></code></a> &#8212; Map filenames to MIME types<a class="headerlink" href="#module-mimetypes" title="Permalink to this headline">¶</a></h1>
<p><strong>Source code:</strong> <a class="reference external" href="https://hg.python.org/cpython/file/3.5/Lib/mimetypes.py">Lib/mimetypes.py</a></p>
<hr class="docutils" id="index-0" />
<p>The <a class="reference internal" href="#module-mimetypes" title="mimetypes: Mapping of filename extensions to MIME types."><code class="xref py py-mod docutils literal"><span class="pre">mimetypes</span></code></a> module converts between a filename or URL and the MIME type
associated with the filename extension.  Conversions are provided from filename
to MIME type and from MIME type to filename extension; encodings are not
supported for the latter conversion.</p>
<p>The module provides one class and a number of convenience functions. The
functions are the normal interface to this module, but some applications may be
interested in the class as well.</p>
<p>The functions described below provide the primary interface for this module.  If
the module has not been initialized, they will call <a class="reference internal" href="#mimetypes.init" title="mimetypes.init"><code class="xref py py-func docutils literal"><span class="pre">init()</span></code></a> if they rely on
the information <a class="reference internal" href="#mimetypes.init" title="mimetypes.init"><code class="xref py py-func docutils literal"><span class="pre">init()</span></code></a> sets up.</p>
<dl class="function">
<dt id="mimetypes.guess_type">
<code class="descclassname">mimetypes.</code><code class="descname">guess_type</code><span class="sig-paren">(</span><em>url</em>, <em>strict=True</em><span class="sig-paren">)</span><a class="headerlink" href="#mimetypes.guess_type" title="Permalink to this definition">¶</a></dt>
<dd><p id="index-1">Guess the type of a file based on its filename or URL, given by <em>url</em>.  The
return value is a tuple <code class="docutils literal"><span class="pre">(type,</span> <span class="pre">encoding)</span></code> where <em>type</em> is <code class="docutils literal"><span class="pre">None</span></code> if the
type can&#8217;t be guessed (missing or unknown suffix) or a string of the form
<code class="docutils literal"><span class="pre">'type/subtype'</span></code>, usable for a MIME <em class="mailheader">content-type</em> header.</p>
<p><em>encoding</em> is <code class="docutils literal"><span class="pre">None</span></code> for no encoding or the name of the program used to encode
(e.g. <strong class="program">compress</strong> or <strong class="program">gzip</strong>). The encoding is suitable for use
as a <em class="mailheader">Content-Encoding</em> header, <strong>not</strong> as a
<em class="mailheader">Content-Transfer-Encoding</em> header. The mappings are table driven.
Encoding suffixes are case sensitive; type suffixes are first tried case
sensitively, then case insensitively.</p>
<p>The optional <em>strict</em> argument is a flag specifying whether the list of known MIME types
is limited to only the official types <a class="reference external" href="https://www.iana.org/assignments/media-types/media-types.xhtml">registered with IANA</a>.
When <em>strict</em> is <code class="docutils literal"><span class="pre">True</span></code> (the default), only the IANA types are supported; when
<em>strict</em> is <code class="docutils literal"><span class="pre">False</span></code>, some additional non-standard but commonly used MIME types
are also recognized.</p>
</dd></dl>

<dl class="function">
<dt id="mimetypes.guess_all_extensions">
<code class="descclassname">mimetypes.</code><code class="descname">guess_all_extensions</code><span class="sig-paren">(</span><em>type</em>, <em>strict=True</em><span class="sig-paren">)</span><a class="headerlink" href="#mimetypes.guess_all_extensions" title="Permalink to this definition">¶</a></dt>
<dd><p>Guess the extensions for a file based on its MIME type, given by <em>type</em>. The
return value is a list of strings giving all possible filename extensions,
including the leading dot (<code class="docutils literal"><span class="pre">'.'</span></code>).  The extensions are not guaranteed to have
been associated with any particular data stream, but would be mapped to the MIME
type <em>type</em> by <a class="reference internal" href="#mimetypes.guess_type" title="mimetypes.guess_type"><code class="xref py py-func docutils literal"><span class="pre">guess_type()</span></code></a>.</p>
<p>The optional <em>strict</em> argument has the same meaning as with the <a class="reference internal" href="#mimetypes.guess_type" title="mimetypes.guess_type"><code class="xref py py-func docutils literal"><span class="pre">guess_type()</span></code></a> function.</p>
</dd></dl>

<dl class="function">
<dt id="mimetypes.guess_extension">
<code class="descclassname">mimetypes.</code><code class="descname">guess_extension</code><span class="sig-paren">(</span><em>type</em>, <em>strict=True</em><span class="sig-paren">)</span><a class="headerlink" href="#mimetypes.guess_extension" title="Permalink to this definition">¶</a></dt>
<dd><p>Guess the extension for a file based on its MIME type, given by <em>type</em>. The
return value is a string giving a filename extension, including the leading dot
(<code class="docutils literal"><span class="pre">'.'</span></code>).  The extension is not guaranteed to have been associated with any
particular data stream, but would be mapped to the MIME type <em>type</em> by
<a class="reference internal" href="#mimetypes.guess_type" title="mimetypes.guess_type"><code class="xref py py-func docutils literal"><span class="pre">guess_type()</span></code></a>.  If no extension can be guessed for <em>type</em>, <code class="docutils literal"><span class="pre">None</span></code> is
returned.</p>
<p>The optional <em>strict</em> argument has the same meaning as with the <a class="reference internal" href="#mimetypes.guess_type" title="mimetypes.guess_type"><code class="xref py py-func docutils literal"><span class="pre">guess_type()</span></code></a> function.</p>
</dd></dl>

<p>Some additional functions and data items are available for controlling the
behavior of the module.</p>
<dl class="function">
<dt id="mimetypes.init">
<code class="descclassname">mimetypes.</code><code class="descname">init</code><span class="sig-paren">(</span><em>files=None</em><span class="sig-paren">)</span><a class="headerlink" href="#mimetypes.init" title="Permalink to this definition">¶</a></dt>
<dd><p>Initialize the internal data structures.  If given, <em>files</em> must be a sequence
of file names which should be used to augment the default type map.  If omitted,
the file names to use are taken from <a class="reference internal" href="#mimetypes.knownfiles" title="mimetypes.knownfiles"><code class="xref py py-const docutils literal"><span class="pre">knownfiles</span></code></a>; on Windows, the
current registry settings are loaded.  Each file named in <em>files</em> or
<a class="reference internal" href="#mimetypes.knownfiles" title="mimetypes.knownfiles"><code class="xref py py-const docutils literal"><span class="pre">knownfiles</span></code></a> takes precedence over those named before it.  Calling
<a class="reference internal" href="#mimetypes.init" title="mimetypes.init"><code class="xref py py-func docutils literal"><span class="pre">init()</span></code></a> repeatedly is allowed.</p>
<p>Specifying an empty list for <em>files</em> will prevent the system defaults from
being applied: only the well-known values will be present from a built-in list.</p>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 3.2: </span>Previously, Windows registry settings were ignored.</p>
</div>
</dd></dl>

<dl class="function">
<dt id="mimetypes.read_mime_types">
<code class="descclassname">mimetypes.</code><code class="descname">read_mime_types</code><span class="sig-paren">(</span><em>filename</em><span class="sig-paren">)</span><a class="headerlink" href="#mimetypes.read_mime_types" title="Permalink to this definition">¶</a></dt>
<dd><p>Load the type map given in the file <em>filename</em>, if it exists.  The type map is
returned as a dictionary mapping filename extensions, including the leading dot
(<code class="docutils literal"><span class="pre">'.'</span></code>), to strings of the form <code class="docutils literal"><span class="pre">'type/subtype'</span></code>.  If the file <em>filename</em>
does not exist or cannot be read, <code class="docutils literal"><span class="pre">None</span></code> is returned.</p>
</dd></dl>

<dl class="function">
<dt id="mimetypes.add_type">
<code class="descclassname">mimetypes.</code><code class="descname">add_type</code><span class="sig-paren">(</span><em>type</em>, <em>ext</em>, <em>strict=True</em><span class="sig-paren">)</span><a class="headerlink" href="#mimetypes.add_type" title="Permalink to this definition">¶</a></dt>
<dd><p>Add a mapping from the MIME type <em>type</em> to the extension <em>ext</em>. When the
extension is already known, the new type will replace the old one. When the type
is already known the extension will be added to the list of known extensions.</p>
<p>When <em>strict</em> is <code class="docutils literal"><span class="pre">True</span></code> (the default), the mapping will be added to the
official MIME types, otherwise to the non-standard ones.</p>
</dd></dl>

<dl class="data">
<dt id="mimetypes.inited">
<code class="descclassname">mimetypes.</code><code class="descname">inited</code><a class="headerlink" href="#mimetypes.inited" title="Permalink to this definition">¶</a></dt>
<dd><p>Flag indicating whether or not the global data structures have been initialized.
This is set to <code class="docutils literal"><span class="pre">True</span></code> by <a class="reference internal" href="#mimetypes.init" title="mimetypes.init"><code class="xref py py-func docutils literal"><span class="pre">init()</span></code></a>.</p>
</dd></dl>

<dl class="data">
<dt id="mimetypes.knownfiles">
<code class="descclassname">mimetypes.</code><code class="descname">knownfiles</code><a class="headerlink" href="#mimetypes.knownfiles" title="Permalink to this definition">¶</a></dt>
<dd><p id="index-2">List of type map file names commonly installed.  These files are typically named
<code class="file docutils literal"><span class="pre">mime.types</span></code> and are installed in different locations by different
packages.</p>
</dd></dl>

<dl class="data">
<dt id="mimetypes.suffix_map">
<code class="descclassname">mimetypes.</code><code class="descname">suffix_map</code><a class="headerlink" href="#mimetypes.suffix_map" title="Permalink to this definition">¶</a></dt>
<dd><p>Dictionary mapping suffixes to suffixes.  This is used to allow recognition of
encoded files for which the encoding and the type are indicated by the same
extension.  For example, the <code class="file docutils literal"><span class="pre">.tgz</span></code> extension is mapped to <code class="file docutils literal"><span class="pre">.tar.gz</span></code>
to allow the encoding and type to be recognized separately.</p>
</dd></dl>

<dl class="data">
<dt id="mimetypes.encodings_map">
<code class="descclassname">mimetypes.</code><code class="descname">encodings_map</code><a class="headerlink" href="#mimetypes.encodings_map" title="Permalink to this definition">¶</a></dt>
<dd><p>Dictionary mapping filename extensions to encoding types.</p>
</dd></dl>

<dl class="data">
<dt id="mimetypes.types_map">
<code class="descclassname">mimetypes.</code><code class="descname">types_map</code><a class="headerlink" href="#mimetypes.types_map" title="Permalink to this definition">¶</a></dt>
<dd><p>Dictionary mapping filename extensions to MIME types.</p>
</dd></dl>

<dl class="data">
<dt id="mimetypes.common_types">
<code class="descclassname">mimetypes.</code><code class="descname">common_types</code><a class="headerlink" href="#mimetypes.common_types" title="Permalink to this definition">¶</a></dt>
<dd><p>Dictionary mapping filename extensions to non-standard, but commonly found MIME
types.</p>
</dd></dl>

<p>An example usage of the module:</p>
<div class="highlight-python3"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">mimetypes</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">mimetypes</span><span class="o">.</span><span class="n">init</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">mimetypes</span><span class="o">.</span><span class="n">knownfiles</span>
<span class="go">[&#39;/etc/mime.types&#39;, &#39;/etc/httpd/mime.types&#39;, ... ]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">mimetypes</span><span class="o">.</span><span class="n">suffix_map</span><span class="p">[</span><span class="s1">&#39;.tgz&#39;</span><span class="p">]</span>
<span class="go">&#39;.tar.gz&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">mimetypes</span><span class="o">.</span><span class="n">encodings_map</span><span class="p">[</span><span class="s1">&#39;.gz&#39;</span><span class="p">]</span>
<span class="go">&#39;gzip&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">mimetypes</span><span class="o">.</span><span class="n">types_map</span><span class="p">[</span><span class="s1">&#39;.tgz&#39;</span><span class="p">]</span>
<span class="go">&#39;application/x-tar-gz&#39;</span>
</pre></div>
</div>
<div class="section" id="mimetypes-objects">
<span id="id1"></span><h2>19.5.1. MimeTypes Objects<a class="headerlink" href="#mimetypes-objects" title="Permalink to this headline">¶</a></h2>
<p>The <a class="reference internal" href="#mimetypes.MimeTypes" title="mimetypes.MimeTypes"><code class="xref py py-class docutils literal"><span class="pre">MimeTypes</span></code></a> class may be useful for applications which may want more
than one MIME-type database; it provides an interface similar to the one of the
<a class="reference internal" href="#module-mimetypes" title="mimetypes: Mapping of filename extensions to MIME types."><code class="xref py py-mod docutils literal"><span class="pre">mimetypes</span></code></a> module.</p>
<dl class="class">
<dt id="mimetypes.MimeTypes">
<em class="property">class </em><code class="descclassname">mimetypes.</code><code class="descname">MimeTypes</code><span class="sig-paren">(</span><em>filenames=()</em>, <em>strict=True</em><span class="sig-paren">)</span><a class="headerlink" href="#mimetypes.MimeTypes" title="Permalink to this definition">¶</a></dt>
<dd><p>This class represents a MIME-types database.  By default, it provides access to
the same database as the rest of this module. The initial database is a copy of
that provided by the module, and may be extended by loading additional
<code class="file docutils literal"><span class="pre">mime.types</span></code>-style files into the database using the <a class="reference internal" href="#mimetypes.MimeTypes.read" title="mimetypes.MimeTypes.read"><code class="xref py py-meth docutils literal"><span class="pre">read()</span></code></a> or
<a class="reference internal" href="#mimetypes.MimeTypes.readfp" title="mimetypes.MimeTypes.readfp"><code class="xref py py-meth docutils literal"><span class="pre">readfp()</span></code></a> methods.  The mapping dictionaries may also be cleared before
loading additional data if the default data is not desired.</p>
<p>The optional <em>filenames</em> parameter can be used to cause additional files to be
loaded &#8220;on top&#8221; of the default database.</p>
</dd></dl>

<dl class="attribute">
<dt id="mimetypes.MimeTypes.suffix_map">
<code class="descclassname">MimeTypes.</code><code class="descname">suffix_map</code><a class="headerlink" href="#mimetypes.MimeTypes.suffix_map" title="Permalink to this definition">¶</a></dt>
<dd><p>Dictionary mapping suffixes to suffixes.  This is used to allow recognition of
encoded files for which the encoding and the type are indicated by the same
extension.  For example, the <code class="file docutils literal"><span class="pre">.tgz</span></code> extension is mapped to <code class="file docutils literal"><span class="pre">.tar.gz</span></code>
to allow the encoding and type to be recognized separately.  This is initially a
copy of the global <a class="reference internal" href="#mimetypes.suffix_map" title="mimetypes.suffix_map"><code class="xref py py-data docutils literal"><span class="pre">suffix_map</span></code></a> defined in the module.</p>
</dd></dl>

<dl class="attribute">
<dt id="mimetypes.MimeTypes.encodings_map">
<code class="descclassname">MimeTypes.</code><code class="descname">encodings_map</code><a class="headerlink" href="#mimetypes.MimeTypes.encodings_map" title="Permalink to this definition">¶</a></dt>
<dd><p>Dictionary mapping filename extensions to encoding types.  This is initially a
copy of the global <a class="reference internal" href="#mimetypes.encodings_map" title="mimetypes.encodings_map"><code class="xref py py-data docutils literal"><span class="pre">encodings_map</span></code></a> defined in the module.</p>
</dd></dl>

<dl class="attribute">
<dt id="mimetypes.MimeTypes.types_map">
<code class="descclassname">MimeTypes.</code><code class="descname">types_map</code><a class="headerlink" href="#mimetypes.MimeTypes.types_map" title="Permalink to this definition">¶</a></dt>
<dd><p>Tuple containing two dictionaries, mapping filename extensions to MIME types:
the first dictionary is for the non-standards types and the second one is for
the standard types. They are initialized by <a class="reference internal" href="#mimetypes.common_types" title="mimetypes.common_types"><code class="xref py py-data docutils literal"><span class="pre">common_types</span></code></a> and
<a class="reference internal" href="#mimetypes.types_map" title="mimetypes.types_map"><code class="xref py py-data docutils literal"><span class="pre">types_map</span></code></a>.</p>
</dd></dl>

<dl class="attribute">
<dt id="mimetypes.MimeTypes.types_map_inv">
<code class="descclassname">MimeTypes.</code><code class="descname">types_map_inv</code><a class="headerlink" href="#mimetypes.MimeTypes.types_map_inv" title="Permalink to this definition">¶</a></dt>
<dd><p>Tuple containing two dictionaries, mapping MIME types to a list of filename
extensions: the first dictionary is for the non-standards types and the
second one is for the standard types. They are initialized by
<a class="reference internal" href="#mimetypes.common_types" title="mimetypes.common_types"><code class="xref py py-data docutils literal"><span class="pre">common_types</span></code></a> and <a class="reference internal" href="#mimetypes.types_map" title="mimetypes.types_map"><code class="xref py py-data docutils literal"><span class="pre">types_map</span></code></a>.</p>
</dd></dl>

<dl class="method">
<dt id="mimetypes.MimeTypes.guess_extension">
<code class="descclassname">MimeTypes.</code><code class="descname">guess_extension</code><span class="sig-paren">(</span><em>type</em>, <em>strict=True</em><span class="sig-paren">)</span><a class="headerlink" href="#mimetypes.MimeTypes.guess_extension" title="Permalink to this definition">¶</a></dt>
<dd><p>Similar to the <a class="reference internal" href="#mimetypes.guess_extension" title="mimetypes.guess_extension"><code class="xref py py-func docutils literal"><span class="pre">guess_extension()</span></code></a> function, using the tables stored as part
of the object.</p>
</dd></dl>

<dl class="method">
<dt id="mimetypes.MimeTypes.guess_type">
<code class="descclassname">MimeTypes.</code><code class="descname">guess_type</code><span class="sig-paren">(</span><em>url</em>, <em>strict=True</em><span class="sig-paren">)</span><a class="headerlink" href="#mimetypes.MimeTypes.guess_type" title="Permalink to this definition">¶</a></dt>
<dd><p>Similar to the <a class="reference internal" href="#mimetypes.guess_type" title="mimetypes.guess_type"><code class="xref py py-func docutils literal"><span class="pre">guess_type()</span></code></a> function, using the tables stored as part of
the object.</p>
</dd></dl>

<dl class="method">
<dt id="mimetypes.MimeTypes.guess_all_extensions">
<code class="descclassname">MimeTypes.</code><code class="descname">guess_all_extensions</code><span class="sig-paren">(</span><em>type</em>, <em>strict=True</em><span class="sig-paren">)</span><a class="headerlink" href="#mimetypes.MimeTypes.guess_all_extensions" title="Permalink to this definition">¶</a></dt>
<dd><p>Similar to the <a class="reference internal" href="#mimetypes.guess_all_extensions" title="mimetypes.guess_all_extensions"><code class="xref py py-func docutils literal"><span class="pre">guess_all_extensions()</span></code></a> function, using the tables stored
as part of the object.</p>
</dd></dl>

<dl class="method">
<dt id="mimetypes.MimeTypes.read">
<code class="descclassname">MimeTypes.</code><code class="descname">read</code><span class="sig-paren">(</span><em>filename</em>, <em>strict=True</em><span class="sig-paren">)</span><a class="headerlink" href="#mimetypes.MimeTypes.read" title="Permalink to this definition">¶</a></dt>
<dd><p>Load MIME information from a file named <em>filename</em>.  This uses <a class="reference internal" href="#mimetypes.MimeTypes.readfp" title="mimetypes.MimeTypes.readfp"><code class="xref py py-meth docutils literal"><span class="pre">readfp()</span></code></a> to
parse the file.</p>
<p>If <em>strict</em> is <code class="docutils literal"><span class="pre">True</span></code>, information will be added to list of standard types,
else to the list of non-standard types.</p>
</dd></dl>

<dl class="method">
<dt id="mimetypes.MimeTypes.readfp">
<code class="descclassname">MimeTypes.</code><code class="descname">readfp</code><span class="sig-paren">(</span><em>fp</em>, <em>strict=True</em><span class="sig-paren">)</span><a class="headerlink" href="#mimetypes.MimeTypes.readfp" title="Permalink to this definition">¶</a></dt>
<dd><p>Load MIME type information from an open file <em>fp</em>.  The file must have the format of
the standard <code class="file docutils literal"><span class="pre">mime.types</span></code> files.</p>
<p>If <em>strict</em> is <code class="docutils literal"><span class="pre">True</span></code>, information will be added to the list of standard
types, else to the list of non-standard types.</p>
</dd></dl>

<dl class="method">
<dt id="mimetypes.MimeTypes.read_windows_registry">
<code class="descclassname">MimeTypes.</code><code class="descname">read_windows_registry</code><span class="sig-paren">(</span><em>strict=True</em><span class="sig-paren">)</span><a class="headerlink" href="#mimetypes.MimeTypes.read_windows_registry" title="Permalink to this definition">¶</a></dt>
<dd><p>Load MIME type information from the Windows registry.  Availability: Windows.</p>
<p>If <em>strict</em> is <code class="docutils literal"><span class="pre">True</span></code>, information will be added to the list of standard
types, else to the list of non-standard types.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.2.</span></p>
</div>
</dd></dl>

</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../contents.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">19.5. <code class="docutils literal"><span class="pre">mimetypes</span></code> &#8212; Map filenames to MIME types</a><ul>
<li><a class="reference internal" href="#mimetypes-objects">19.5.1. MimeTypes Objects</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="mailbox.html"
                        title="previous chapter">19.4. <code class="docutils literal"><span class="pre">mailbox</span></code> &#8212; Manipulate mailboxes in various formats</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="base64.html"
                        title="next chapter">19.6. <code class="docutils literal"><span class="pre">base64</span></code> &#8212; Base16, Base32, Base64, Base85 Data Encodings</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../bugs.html">Report a Bug</a></li>
      <li><a href="../_sources/library/mimetypes.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
  </div>
        </div>
      </div>
      <div class="clearer"></div>
    </div>  
    <div class="related" role="navigation" aria-label="related navigation">
      <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="base64.html" title="19.6. base64 — Base16, Base32, Base64, Base85 Data Encodings"
             >next</a> |</li>
        <li class="right" >
          <a href="mailbox.html" title="19.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="https://www.python.org/">Python</a> &raquo;</li>
        <li>
          <span class="version_switcher_placeholder">3.5.3</span>
          <a href="../index.html">Documentation </a> &raquo;
        </li>

          <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &raquo;</li>
          <li class="nav-item nav-item-2"><a href="netdata.html" >19. Internet Data Handling</a> &raquo;</li>
    <li class="right">
        

    <div class="inline-search" style="display: none" role="search">
        <form class="inline-search" action="../search.html" method="get">
          <input placeholder="Quick search" 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>
    </div>
    <script type="text/javascript">$('.inline-search').show(0);</script>
         |
    </li>

      </ul>
    </div>  
    <div class="footer">
    &copy; <a href="../copyright.html">Copyright</a> 2001-2017, Python Software Foundation.
    <br />
    The Python Software Foundation is a non-profit corporation.
    <a href="https://www.python.org/psf/donations/">Please donate.</a>
    <br />
    Last updated on Jan 20, 2017.
    <a href="../bugs.html">Found a bug</a>?
    <br />
    Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.3.3.
    </div>

  </body>
</html>