Skip to content

Commit 533836d

Browse files
committed
Command execution
1 parent 31a0965 commit 533836d

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,7 +1177,7 @@ class MyOpen():
11771177
Hello World!
11781178
```
11791179

1180-
#### List of existing context managers:
1180+
#### List of covered context managers:
11811181
```python
11821182
with open('<path>') as file: ...
11831183
with wave.open('<path>') as wave_file: ...
@@ -1615,12 +1615,14 @@ Command Execution
16151615

16161616
```python
16171617
import os, shutil
1618-
<str> = os.getcwd() # Returns the current working directory.
1618+
```
1619+
1620+
```python
16191621
os.chdir(<path>) # Changes current working directory.
1622+
os.mkdir(<path>, mode=0o777) # Creates a directory.
16201623
```
16211624

16221625
```python
1623-
shutil.copy(from, to) # Copies the file.
16241626
os.rename(from, to) # Renames the file or directory.
16251627
os.replace(from, to) # Same, but overwrites 'to' if it exists.
16261628
```
@@ -1632,7 +1634,12 @@ shutil.rmtree(<path>) # Deletes the entire directory tree.
16321634
```
16331635

16341636
```python
1635-
os.mkdir(<path>, mode=0o777) # Creates a directory.
1637+
shutil.copy(from, to) # Copies the file.
1638+
shutil.copytree(from, to) # Copies the entire directory tree.
1639+
```
1640+
1641+
```python
1642+
<str> = os.getcwd() # Returns the current working directory.
16361643
<iter> = os.scandir(path='.') # Returns os.DirEntry objects located at path.
16371644
```
16381645

index.html

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,7 +1114,7 @@
11141114
<span class="hljs-meta">... </span> print(file.read())
11151115
Hello World!
11161116
</code></pre>
1117-
<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: ...
1117+
<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: ...
11181118
<span class="hljs-keyword">with</span> wave.open(<span class="hljs-string">'&lt;path&gt;'</span>) <span class="hljs-keyword">as</span> wave_file: ...
11191119
<span class="hljs-keyword">with</span> memoryview(&lt;bytes/bytearray/array&gt;) <span class="hljs-keyword">as</span> view: ...
11201120
<span class="hljs-keyword">with</span> concurrent.futures.ThreadPoolExecutor() <span class="hljs-keyword">as</span> executor: ...
@@ -1470,21 +1470,24 @@
14701470
<li><strong>Paths can be either strings, Paths, or DirEntry objects.</strong></li>
14711471
<li><strong>Functions report OS related errors by raising either OSError or one of its <a href="#exceptions-1">subclasses</a>.</strong></li>
14721472
</ul><pre><code class="python language-python hljs"><span class="hljs-keyword">import</span> os, shutil
1473-
&lt;str&gt; = os.getcwd() <span class="hljs-comment"># Returns the current working directory.</span>
1474-
os.chdir(&lt;path&gt;) <span class="hljs-comment"># Changes current working directory.</span>
14751473
</code></pre></div></div>
14761474

14771475

14781476

1479-
<pre><code class="python language-python hljs">shutil.copy(from, to) <span class="hljs-comment"># Copies the file.</span>
1480-
os.rename(from, to) <span class="hljs-comment"># Renames the file or directory.</span>
1477+
<pre><code class="python language-python hljs">os.chdir(&lt;path&gt;) <span class="hljs-comment"># Changes current working directory.</span>
1478+
os.mkdir(&lt;path&gt;, mode=<span class="hljs-number">0o777</span>) <span class="hljs-comment"># Creates a directory.</span>
1479+
</code></pre>
1480+
<pre><code class="python language-python hljs">os.rename(from, to) <span class="hljs-comment"># Renames the file or directory.</span>
14811481
os.replace(from, to) <span class="hljs-comment"># Same, but overwrites 'to' if it exists.</span>
14821482
</code></pre>
14831483
<pre><code class="python language-python hljs">os.remove(&lt;path&gt;) <span class="hljs-comment"># Deletes the file.</span>
14841484
os.rmdir(&lt;path&gt;) <span class="hljs-comment"># Deletes empty directory.</span>
14851485
shutil.rmtree(&lt;path&gt;) <span class="hljs-comment"># Deletes the entire directory tree.</span>
14861486
</code></pre>
1487-
<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>
1487+
<pre><code class="python language-python hljs">shutil.copy(from, to) <span class="hljs-comment"># Copies the file.</span>
1488+
shutil.copytree(from, to) <span class="hljs-comment"># Copies the entire directory tree.</span>
1489+
</code></pre>
1490+
<pre><code class="python language-python hljs">&lt;str&gt; = os.getcwd() <span class="hljs-comment"># Returns the current working directory.</span>
14881491
&lt;iter&gt; = os.scandir(path=<span class="hljs-string">'.'</span>) <span class="hljs-comment"># Returns os.DirEntry objects located at path.</span>
14891492
</code></pre>
14901493
<div><h4 id="direntry">DirEntry:</h4><pre><code class="python language-python hljs">&lt;bool&gt; = &lt;DirEntry&gt;.is_file()

parse.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,14 @@ const DIAGRAM_7_B =
194194
'┃ count() │ │ │ │ ✓ ┃\n' +
195195
'┗━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━━━┛\n';
196196

197-
const OS_RENAME =
198-
'shutil.copy(from, to) <span class="hljs-comment"># Copies the file.</span>\n' +
197+
const OS_RENAME =
199198
'os.rename(from, to) <span class="hljs-comment"># Renames the file or directory.</span>\n' +
200199
'os.replace(from, to) <span class="hljs-comment"># Same, but overwrites \'to\' if it exists.</span>\n';
201200

201+
const SHUTIL_COPY =
202+
'shutil.copy(from, to) <span class="hljs-comment"># Copies the file.</span>\n' +
203+
'shutil.copytree(from, to) <span class="hljs-comment"># Copies the entire directory tree.</span>\n';
204+
202205
const EVAL =
203206
'<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> ast <span class="hljs-keyword">import</span> literal_eval\n' +
204207
'<span class="hljs-meta">&gt;&gt;&gt; </span>literal_eval(<span class="hljs-string">\'1 + 2\'</span>)\n' +
@@ -316,6 +319,7 @@ function fixClasses() {
316319

317320
function fixHighlights() {
318321
$(`code:contains(os.rename)`).html(OS_RENAME);
322+
$(`code:contains(shutil.copy)`).html(SHUTIL_COPY);
319323
$(`code:contains(ValueError: malformed node)`).html(EVAL);
320324
$(`code:contains(@lru_cache(maxsize=None))`).html(LRU_CACHE);
321325
$(`code:contains(<class_name>, <parents_tuple>, <attributes_dict>)`).html(TYPE);

0 commit comments

Comments
 (0)