Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-updates > by-pkgid > e1011ddec34cda34f3a002b121247943 > files > 741

python-docs-2.7.17-1.1.mga7.noarch.rpm


<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta charset="utf-8" />
    <title>10.11. dircache — Cached directory listings &#8212; Python 2.7.17 documentation</title>
    <link rel="stylesheet" href="../_static/classic.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></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/language_data.js"></script>
    
    <script type="text/javascript" src="../_static/sidebar.js"></script>
    
    <link rel="search" type="application/opensearchdescription+xml"
          title="Search within Python 2.7.17 documentation"
          href="../_static/opensearch.xml"/>
    <link rel="author" title="About these documents" href="../about.html" />
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="copyright" title="Copyright" href="../copyright.html" />
    <link rel="next" title="10.12. macpath — Mac OS 9 path manipulation functions" href="macpath.html" />
    <link rel="prev" title="10.10. shutil — High-level file operations" href="shutil.html" />
    <link rel="shortcut icon" type="image/png" href="../_static/py.png" />
    <link rel="canonical" href="https://docs.python.org/2/library/dircache.html" />
    <script type="text/javascript" src="../_static/copybutton.js"></script>
    
 
    

  </head><body>  
    <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="macpath.html" title="10.12. macpath — Mac OS 9 path manipulation functions"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="shutil.html" title="10.10. shutil — High-level file operations"
             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> &#187;</li>
        <li>
          <a href="../index.html">Python 2.7.17 documentation</a> &#187;
        </li>

          <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="filesys.html" accesskey="U">10. File and Directory Access</a> &#187;</li> 
      </ul>
    </div>    

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="module-dircache">
<span id="dircache-cached-directory-listings"></span><h1>10.11. <a class="reference internal" href="#module-dircache" title="dircache: Return directory listing, with cache mechanism. (deprecated)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">dircache</span></code></a> — Cached directory listings<a class="headerlink" href="#module-dircache" title="Permalink to this headline">¶</a></h1>
<div class="deprecated">
<p><span class="versionmodified deprecated">Deprecated since version 2.6: </span>The <a class="reference internal" href="#module-dircache" title="dircache: Return directory listing, with cache mechanism. (deprecated)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">dircache</span></code></a> module has been removed in Python 3.</p>
</div>
<p>The <a class="reference internal" href="#module-dircache" title="dircache: Return directory listing, with cache mechanism. (deprecated)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">dircache</span></code></a> module defines a function for reading directory listing
using a cache, and cache invalidation using the <em>mtime</em> of the directory.
Additionally, it defines a function to annotate directories by appending a
slash.</p>
<p>The <a class="reference internal" href="#module-dircache" title="dircache: Return directory listing, with cache mechanism. (deprecated)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">dircache</span></code></a> module defines the following functions:</p>
<dl class="function">
<dt id="dircache.reset">
<code class="descclassname">dircache.</code><code class="descname">reset</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#dircache.reset" title="Permalink to this definition">¶</a></dt>
<dd><p>Resets the directory cache.</p>
</dd></dl>

<dl class="function">
<dt id="dircache.listdir">
<code class="descclassname">dircache.</code><code class="descname">listdir</code><span class="sig-paren">(</span><em>path</em><span class="sig-paren">)</span><a class="headerlink" href="#dircache.listdir" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a directory listing of <em>path</em>, as gotten from <a class="reference internal" href="os.html#os.listdir" title="os.listdir"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.listdir()</span></code></a>. Note
that unless <em>path</em> changes, further call to <a class="reference internal" href="#dircache.listdir" title="dircache.listdir"><code class="xref py py-func docutils literal notranslate"><span class="pre">listdir()</span></code></a> will not re-read the
directory structure.</p>
<p>Note that the list returned should be regarded as read-only. (Perhaps a future
version should change it to return a tuple?)</p>
</dd></dl>

<dl class="function">
<dt id="dircache.opendir">
<code class="descclassname">dircache.</code><code class="descname">opendir</code><span class="sig-paren">(</span><em>path</em><span class="sig-paren">)</span><a class="headerlink" href="#dircache.opendir" title="Permalink to this definition">¶</a></dt>
<dd><p>Same as <a class="reference internal" href="#dircache.listdir" title="dircache.listdir"><code class="xref py py-func docutils literal notranslate"><span class="pre">listdir()</span></code></a>. Defined for backwards compatibility.</p>
</dd></dl>

<dl class="function">
<dt id="dircache.annotate">
<code class="descclassname">dircache.</code><code class="descname">annotate</code><span class="sig-paren">(</span><em>head</em>, <em>list</em><span class="sig-paren">)</span><a class="headerlink" href="#dircache.annotate" title="Permalink to this definition">¶</a></dt>
<dd><p>Assume <em>list</em> is a list of paths relative to <em>head</em>, and append, in place, a
<code class="docutils literal notranslate"><span class="pre">'/'</span></code> to each path which points to a directory.</p>
</dd></dl>

<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">dircache</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">dircache</span><span class="o">.</span><span class="n">listdir</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">a</span><span class="p">[:]</span> <span class="c1"># Copy the return value so we can change &#39;a&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span>
<span class="go">[&#39;bin&#39;, &#39;boot&#39;, &#39;cdrom&#39;, &#39;dev&#39;, &#39;etc&#39;, &#39;floppy&#39;, &#39;home&#39;, &#39;initrd&#39;, &#39;lib&#39;, &#39;lost+</span>
<span class="go">found&#39;, &#39;mnt&#39;, &#39;proc&#39;, &#39;root&#39;, &#39;sbin&#39;, &#39;tmp&#39;, &#39;usr&#39;, &#39;var&#39;, &#39;vmlinuz&#39;]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dircache</span><span class="o">.</span><span class="n">annotate</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">,</span> <span class="n">a</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span>
<span class="go">[&#39;bin/&#39;, &#39;boot/&#39;, &#39;cdrom/&#39;, &#39;dev/&#39;, &#39;etc/&#39;, &#39;floppy/&#39;, &#39;home/&#39;, &#39;initrd/&#39;, &#39;lib/</span>
<span class="go">&#39;, &#39;lost+found/&#39;, &#39;mnt/&#39;, &#39;proc/&#39;, &#39;root/&#39;, &#39;sbin/&#39;, &#39;tmp/&#39;, &#39;usr/&#39;, &#39;var/&#39;, &#39;vm</span>
<span class="go">linuz&#39;]</span>
</pre></div>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h4>Previous topic</h4>
  <p class="topless"><a href="shutil.html"
                        title="previous chapter">10.10. <code class="xref py py-mod docutils literal notranslate"><span class="pre">shutil</span></code> — High-level file operations</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="macpath.html"
                        title="next chapter">10.12. <code class="xref py py-mod docutils literal notranslate"><span class="pre">macpath</span></code> — Mac OS 9 path manipulation functions</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../_sources/library/dircache.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </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="macpath.html" title="10.12. macpath — Mac OS 9 path manipulation functions"
             >next</a> |</li>
        <li class="right" >
          <a href="shutil.html" title="10.10. shutil — High-level file operations"
             >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> &#187;</li>
        <li>
          <a href="../index.html">Python 2.7.17 documentation</a> &#187;
        </li>

          <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="filesys.html" >10. File and Directory Access</a> &#187;</li> 
      </ul>
    </div>  
    <div class="footer">
    &copy; <a href="../copyright.html">Copyright</a> 1990-2019, 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 Oct 19, 2019.
    <a href="../bugs.html">Found a bug</a>?
    <br />
    Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 2.0.1.
    </div>

  </body>
</html>