Browse Source

Command execution

pull/44/head
Jure Šorn 5 years ago
parent
commit
533836d58b
3 changed files with 26 additions and 12 deletions
  1. 15
      README.md
  2. 15
      index.html
  3. 8
      parse.js

15
README.md

@ -1177,7 +1177,7 @@ class MyOpen():
Hello World!
```
#### List of existing context managers:
#### List of covered context managers:
```python
with open('<path>') as file: ...
with wave.open('<path>') as wave_file: ...
@ -1615,12 +1615,14 @@ Command Execution
```python
import os, shutil
<str> = os.getcwd() # Returns the current working directory.
```
```python
os.chdir(<path>) # Changes current working directory.
os.mkdir(<path>, mode=0o777) # Creates a directory.
```
```python
shutil.copy(from, to) # Copies the file.
os.rename(from, to) # Renames the file or directory.
os.replace(from, to) # Same, but overwrites 'to' if it exists.
```
@ -1632,7 +1634,12 @@ shutil.rmtree(<path>) # Deletes the entire directory tree.
```
```python
os.mkdir(<path>, mode=0o777) # Creates a directory.
shutil.copy(from, to) # Copies the file.
shutil.copytree(from, to) # Copies the entire directory tree.
```
```python
<str> = os.getcwd() # Returns the current working directory.
<iter> = os.scandir(path='.') # Returns os.DirEntry objects located at path.
```

15
index.html

@ -1114,7 +1114,7 @@ Z = dataclasses.make_dataclass(<span class="hljs-string">'Z'</span>, [<span clas
<span class="hljs-meta">... </span> print(file.read())
Hello World!
</code></pre>
<div><h4 id="listofexistingcontextmanagers">List of existing context managers:</h4><pre><code class="python language-python hljs"><span class="hljs-keyword">with</span> open(<span class="hljs-string">'&lt;path&gt;'</span>) <span class="hljs-keyword">as</span> file: ...
<div><h4 id="listofcoveredcontextmanagers">List of covered context managers:</h4><pre><code class="python language-python hljs"><span class="hljs-keyword">with</span> open(<span class="hljs-string">'&lt;path&gt;'</span>) <span class="hljs-keyword">as</span> file: ...
<span class="hljs-keyword">with</span> wave.open(<span class="hljs-string">'&lt;path&gt;'</span>) <span class="hljs-keyword">as</span> wave_file: ...
<span class="hljs-keyword">with</span> memoryview(&lt;bytes/bytearray/array&gt;) <span class="hljs-keyword">as</span> view: ...
<span class="hljs-keyword">with</span> concurrent.futures.ThreadPoolExecutor() <span class="hljs-keyword">as</span> executor: ...
@ -1470,21 +1470,24 @@ value = args.&lt;name&gt;
<li><strong>Paths can be either strings, Paths, or DirEntry objects.</strong></li>
<li><strong>Functions report OS related errors by raising either OSError or one of its <a href="#exceptions-1">subclasses</a>.</strong></li>
</ul><pre><code class="python language-python hljs"><span class="hljs-keyword">import</span> os, shutil
&lt;str&gt; = os.getcwd() <span class="hljs-comment"># Returns the current working directory.</span>
os.chdir(&lt;path&gt;) <span class="hljs-comment"># Changes current working directory.</span>
</code></pre></div></div>
<pre><code class="python language-python hljs">shutil.copy(from, to) <span class="hljs-comment"># Copies the file.</span>
os.rename(from, to) <span class="hljs-comment"># Renames the file or directory.</span>
<pre><code class="python language-python hljs">os.chdir(&lt;path&gt;) <span class="hljs-comment"># Changes current working directory.</span>
os.mkdir(&lt;path&gt;, mode=<span class="hljs-number">0o777</span>) <span class="hljs-comment"># Creates a directory.</span>
</code></pre>
<pre><code class="python language-python hljs">os.rename(from, to) <span class="hljs-comment"># Renames the file or directory.</span>
os.replace(from, to) <span class="hljs-comment"># Same, but overwrites 'to' if it exists.</span>
</code></pre>
<pre><code class="python language-python hljs">os.remove(&lt;path&gt;) <span class="hljs-comment"># Deletes the file.</span>
os.rmdir(&lt;path&gt;) <span class="hljs-comment"># Deletes empty directory.</span>
shutil.rmtree(&lt;path&gt;) <span class="hljs-comment"># Deletes the entire directory tree.</span>
</code></pre>
<pre><code class="python language-python hljs">os.mkdir(&lt;path&gt;, mode=<span class="hljs-number">0o777</span>) <span class="hljs-comment"># Creates a directory.</span>
<pre><code class="python language-python hljs">shutil.copy(from, to) <span class="hljs-comment"># Copies the file.</span>
shutil.copytree(from, to) <span class="hljs-comment"># Copies the entire directory tree.</span>
</code></pre>
<pre><code class="python language-python hljs">&lt;str&gt; = os.getcwd() <span class="hljs-comment"># Returns the current working directory.</span>
&lt;iter&gt; = os.scandir(path=<span class="hljs-string">'.'</span>) <span class="hljs-comment"># Returns os.DirEntry objects located at path.</span>
</code></pre>
<div><h4 id="direntry">DirEntry:</h4><pre><code class="python language-python hljs">&lt;bool&gt; = &lt;DirEntry&gt;.is_file()

8
parse.js

@ -194,11 +194,14 @@ const DIAGRAM_7_B =
'┃ count() │ │ │ │ ✓ ┃\n' +
'┗━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━━━┛\n';
const OS_RENAME =
'shutil.copy(from, to) <span class="hljs-comment"># Copies the file.</span>\n' +
const OS_RENAME =
'os.rename(from, to) <span class="hljs-comment"># Renames the file or directory.</span>\n' +
'os.replace(from, to) <span class="hljs-comment"># Same, but overwrites \'to\' if it exists.</span>\n';
const SHUTIL_COPY =
'shutil.copy(from, to) <span class="hljs-comment"># Copies the file.</span>\n' +
'shutil.copytree(from, to) <span class="hljs-comment"># Copies the entire directory tree.</span>\n';
const EVAL =
'<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> ast <span class="hljs-keyword">import</span> literal_eval\n' +
'<span class="hljs-meta">&gt;&gt;&gt; </span>literal_eval(<span class="hljs-string">\'1 + 2\'</span>)\n' +
@ -316,6 +319,7 @@ function fixClasses() {
function fixHighlights() {
$(`code:contains(os.rename)`).html(OS_RENAME);
$(`code:contains(shutil.copy)`).html(SHUTIL_COPY);
$(`code:contains(ValueError: malformed node)`).html(EVAL);
$(`code:contains(@lru_cache(maxsize=None))`).html(LRU_CACHE);
$(`code:contains(<class_name>, <parents_tuple>, <attributes_dict>)`).html(TYPE);

Loading…
Cancel
Save