io.html 14.1 KB
Newer Older
fred.perso's avatar
fred.perso committed
1 2 3 4 5 6 7 8 9 10


<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
11
  <title>io &mdash; Documentation dbchiro[web] 20180330</title>
fred.perso's avatar
fred.perso committed
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
  

  
  
  
  

  

  
  
    

  

  
  
    <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
  

  

  
        <link rel="index" title="Index"
              href="../genindex.html"/>
        <link rel="search" title="Recherche" href="../search.html"/>
38
    <link rel="top" title="Documentation dbchiro[web] 20180330" href="../index.html"/>
fred.perso's avatar
fred.perso committed
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
        <link rel="up" title="Code du module" href="index.html"/> 

  
  <script src="../_static/js/modernizr.min.js"></script>

</head>

<body class="wy-body-for-nav" role="document">

   
  <div class="wy-grid-for-nav">

    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search">
          

          
            <a href="../index.html" class="icon icon-home"> dbchiro[web]
          

          
          </a>

          
            
            
              <div class="version">
68
                20180330
fred.perso's avatar
fred.perso committed
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286
              </div>
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <p class="caption"><span class="caption-text">Contents:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../installation.html">Installation</a></li>
</ul>

            
          
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" role="navigation" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../index.html">dbchiro[web]</a>
        
      </nav>


      
      <div class="wy-nav-content">
        <div class="rst-content">
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../index.html">Docs</a> &raquo;</li>
        
          <li><a href="index.html">Code du module</a> &raquo;</li>
        
      <li>io</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <h1>Code source de io</h1><div class="highlight"><pre>
<span></span><span class="sd">&quot;&quot;&quot;The io module provides the Python interfaces to stream handling. The</span>
<span class="sd">builtin open function is defined in this module.</span>

<span class="sd">At the top of the I/O hierarchy is the abstract base class IOBase. It</span>
<span class="sd">defines the basic interface to a stream. Note, however, that there is no</span>
<span class="sd">separation between reading and writing to streams; implementations are</span>
<span class="sd">allowed to raise an OSError if they do not support a given operation.</span>

<span class="sd">Extending IOBase is RawIOBase which deals simply with the reading and</span>
<span class="sd">writing of raw bytes to a stream. FileIO subclasses RawIOBase to provide</span>
<span class="sd">an interface to OS files.</span>

<span class="sd">BufferedIOBase deals with buffering on a raw byte stream (RawIOBase). Its</span>
<span class="sd">subclasses, BufferedWriter, BufferedReader, and BufferedRWPair buffer</span>
<span class="sd">streams that are readable, writable, and both respectively.</span>
<span class="sd">BufferedRandom provides a buffered interface to random access</span>
<span class="sd">streams. BytesIO is a simple stream of in-memory bytes.</span>

<span class="sd">Another IOBase subclass, TextIOBase, deals with the encoding and decoding</span>
<span class="sd">of streams into text. TextIOWrapper, which extends it, is a buffered text</span>
<span class="sd">interface to a buffered raw stream (`BufferedIOBase`). Finally, StringIO</span>
<span class="sd">is an in-memory stream for text.</span>

<span class="sd">Argument names are not part of the specification, and only the arguments</span>
<span class="sd">of open() are intended to be used as keyword arguments.</span>

<span class="sd">data:</span>

<span class="sd">DEFAULT_BUFFER_SIZE</span>

<span class="sd">   An int containing the default buffer size used by the module&#39;s buffered</span>
<span class="sd">   I/O classes. open() uses the file&#39;s blksize (as obtained by os.stat) if</span>
<span class="sd">   possible.</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="c1"># New I/O library conforming to PEP 3116.</span>

<span class="n">__author__</span> <span class="o">=</span> <span class="p">(</span><span class="s2">&quot;Guido van Rossum &lt;guido@python.org&gt;, &quot;</span>
              <span class="s2">&quot;Mike Verdone &lt;mike.verdone@gmail.com&gt;, &quot;</span>
              <span class="s2">&quot;Mark Russell &lt;mark.russell@zen.co.uk&gt;, &quot;</span>
              <span class="s2">&quot;Antoine Pitrou &lt;solipsis@pitrou.net&gt;, &quot;</span>
              <span class="s2">&quot;Amaury Forgeot d&#39;Arc &lt;amauryfa@gmail.com&gt;, &quot;</span>
              <span class="s2">&quot;Benjamin Peterson &lt;benjamin@python.org&gt;&quot;</span><span class="p">)</span>

<span class="n">__all__</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;BlockingIOError&quot;</span><span class="p">,</span> <span class="s2">&quot;open&quot;</span><span class="p">,</span> <span class="s2">&quot;IOBase&quot;</span><span class="p">,</span> <span class="s2">&quot;RawIOBase&quot;</span><span class="p">,</span> <span class="s2">&quot;FileIO&quot;</span><span class="p">,</span>
           <span class="s2">&quot;BytesIO&quot;</span><span class="p">,</span> <span class="s2">&quot;StringIO&quot;</span><span class="p">,</span> <span class="s2">&quot;BufferedIOBase&quot;</span><span class="p">,</span>
           <span class="s2">&quot;BufferedReader&quot;</span><span class="p">,</span> <span class="s2">&quot;BufferedWriter&quot;</span><span class="p">,</span> <span class="s2">&quot;BufferedRWPair&quot;</span><span class="p">,</span>
           <span class="s2">&quot;BufferedRandom&quot;</span><span class="p">,</span> <span class="s2">&quot;TextIOBase&quot;</span><span class="p">,</span> <span class="s2">&quot;TextIOWrapper&quot;</span><span class="p">,</span>
           <span class="s2">&quot;UnsupportedOperation&quot;</span><span class="p">,</span> <span class="s2">&quot;SEEK_SET&quot;</span><span class="p">,</span> <span class="s2">&quot;SEEK_CUR&quot;</span><span class="p">,</span> <span class="s2">&quot;SEEK_END&quot;</span><span class="p">]</span>


<span class="kn">import</span> <span class="nn">_io</span>
<span class="kn">import</span> <span class="nn">abc</span>

<span class="kn">from</span> <span class="nn">_io</span> <span class="k">import</span> <span class="p">(</span><span class="n">DEFAULT_BUFFER_SIZE</span><span class="p">,</span> <span class="ne">BlockingIOError</span><span class="p">,</span> <span class="n">UnsupportedOperation</span><span class="p">,</span>
                 <span class="nb">open</span><span class="p">,</span> <span class="n">FileIO</span><span class="p">,</span> <span class="n">BytesIO</span><span class="p">,</span> <span class="n">StringIO</span><span class="p">,</span> <span class="n">BufferedReader</span><span class="p">,</span>
                 <span class="n">BufferedWriter</span><span class="p">,</span> <span class="n">BufferedRWPair</span><span class="p">,</span> <span class="n">BufferedRandom</span><span class="p">,</span>
                 <span class="n">IncrementalNewlineDecoder</span><span class="p">,</span> <span class="n">TextIOWrapper</span><span class="p">)</span>

<span class="n">OpenWrapper</span> <span class="o">=</span> <span class="n">_io</span><span class="o">.</span><span class="n">open</span> <span class="c1"># for compatibility with _pyio</span>

<span class="c1"># Pretend this exception was created here.</span>
<span class="n">UnsupportedOperation</span><span class="o">.</span><span class="vm">__module__</span> <span class="o">=</span> <span class="s2">&quot;io&quot;</span>

<span class="c1"># for seek()</span>
<span class="n">SEEK_SET</span> <span class="o">=</span> <span class="mi">0</span>
<span class="n">SEEK_CUR</span> <span class="o">=</span> <span class="mi">1</span>
<span class="n">SEEK_END</span> <span class="o">=</span> <span class="mi">2</span>

<span class="c1"># Declaring ABCs in C is tricky so we do it here.</span>
<span class="c1"># Method descriptions and default implementations are inherited from the C</span>
<span class="c1"># version however.</span>
<div class="viewcode-block" id="IOBase"><a class="viewcode-back" href="../index.html#io.IOBase">[docs]</a><span class="k">class</span> <span class="nc">IOBase</span><span class="p">(</span><span class="n">_io</span><span class="o">.</span><span class="n">_IOBase</span><span class="p">,</span> <span class="n">metaclass</span><span class="o">=</span><span class="n">abc</span><span class="o">.</span><span class="n">ABCMeta</span><span class="p">):</span>
    <span class="vm">__doc__</span> <span class="o">=</span> <span class="n">_io</span><span class="o">.</span><span class="n">_IOBase</span><span class="o">.</span><span class="vm">__doc__</span></div>

<div class="viewcode-block" id="RawIOBase"><a class="viewcode-back" href="../index.html#io.RawIOBase">[docs]</a><span class="k">class</span> <span class="nc">RawIOBase</span><span class="p">(</span><span class="n">_io</span><span class="o">.</span><span class="n">_RawIOBase</span><span class="p">,</span> <span class="n">IOBase</span><span class="p">):</span>
    <span class="vm">__doc__</span> <span class="o">=</span> <span class="n">_io</span><span class="o">.</span><span class="n">_RawIOBase</span><span class="o">.</span><span class="vm">__doc__</span></div>

<div class="viewcode-block" id="BufferedIOBase"><a class="viewcode-back" href="../index.html#io.BufferedIOBase">[docs]</a><span class="k">class</span> <span class="nc">BufferedIOBase</span><span class="p">(</span><span class="n">_io</span><span class="o">.</span><span class="n">_BufferedIOBase</span><span class="p">,</span> <span class="n">IOBase</span><span class="p">):</span>
    <span class="vm">__doc__</span> <span class="o">=</span> <span class="n">_io</span><span class="o">.</span><span class="n">_BufferedIOBase</span><span class="o">.</span><span class="vm">__doc__</span></div>

<div class="viewcode-block" id="TextIOBase"><a class="viewcode-back" href="../index.html#io.TextIOBase">[docs]</a><span class="k">class</span> <span class="nc">TextIOBase</span><span class="p">(</span><span class="n">_io</span><span class="o">.</span><span class="n">_TextIOBase</span><span class="p">,</span> <span class="n">IOBase</span><span class="p">):</span>
    <span class="vm">__doc__</span> <span class="o">=</span> <span class="n">_io</span><span class="o">.</span><span class="n">_TextIOBase</span><span class="o">.</span><span class="vm">__doc__</span></div>

<span class="n">RawIOBase</span><span class="o">.</span><span class="n">register</span><span class="p">(</span><span class="n">FileIO</span><span class="p">)</span>

<span class="k">for</span> <span class="n">klass</span> <span class="ow">in</span> <span class="p">(</span><span class="n">BytesIO</span><span class="p">,</span> <span class="n">BufferedReader</span><span class="p">,</span> <span class="n">BufferedWriter</span><span class="p">,</span> <span class="n">BufferedRandom</span><span class="p">,</span>
              <span class="n">BufferedRWPair</span><span class="p">):</span>
    <span class="n">BufferedIOBase</span><span class="o">.</span><span class="n">register</span><span class="p">(</span><span class="n">klass</span><span class="p">)</span>

<span class="k">for</span> <span class="n">klass</span> <span class="ow">in</span> <span class="p">(</span><span class="n">StringIO</span><span class="p">,</span> <span class="n">TextIOWrapper</span><span class="p">):</span>
    <span class="n">TextIOBase</span><span class="o">.</span><span class="n">register</span><span class="p">(</span><span class="n">klass</span><span class="p">)</span>
<span class="k">del</span> <span class="n">klass</span>
</pre></div>

           </div>
           <div class="articleComments">
            
           </div>
          </div>
          <footer>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright 2018, Frédéric CLOITRE.

    </p>
  </div>
  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  


  

    <script type="text/javascript">
        var DOCUMENTATION_OPTIONS = {
            URL_ROOT:'../',
287
            VERSION:'20180330',
fred.perso's avatar
fred.perso committed
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316
            COLLAPSE_INDEX:false,
            FILE_SUFFIX:'.html',
            HAS_SOURCE:  true,
            SOURCELINK_SUFFIX: '.txt'
        };
    </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/translations.js"></script>

  

  
  
    <script type="text/javascript" src="../_static/js/theme.js"></script>
  

  
  
  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.StickyNav.enable();
      });
  </script>
   

</body>
</html>