Skip to content

Commit f9f9968

Browse files
committed
Command execution
1 parent 7680be3 commit f9f9968

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,23 +1594,24 @@ Command Execution
15941594
-----------------
15951595
### Files and Directories
15961596
* **Paths can be either strings, Paths, or DirEntry objects.**
1597-
* **All exceptions are either 'OSError' or its subclasses.**
1597+
* **All exceptions are either OSError or its subclasses.**
15981598

15991599
```python
1600-
import os
1600+
import os, shutil
16011601
<str> = os.getcwd() # Returns the current working directory.
16021602
os.chdir(<path>) # Changes current working directory.
16031603
```
16041604

16051605
```python
1606-
os.remove(<path>) # Deletes the file.
1607-
os.rmdir(<path>) # Deletes empty directory.
1608-
shutil.rmtree(<path>) # Deletes the entire directory tree.
1606+
shutil.copy(from, to) # Copies the file.
1607+
os.rename(from, to) # Renames the file or directory.
1608+
os.replace(from, to) # Same, but overwrites 'to' if it exists.
16091609
```
16101610

16111611
```python
1612-
os.rename(from, to) # Renames the file or directory.
1613-
os.replace(from, to) # Same, but overwrites 'to' if it exists.
1612+
os.remove(<path>) # Deletes the file.
1613+
os.rmdir(<path>) # Deletes empty directory.
1614+
shutil.rmtree(<path>) # Deletes the entire directory tree.
16141615
```
16151616

16161617
```python

index.html

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1445,21 +1445,22 @@
14451445
</code></pre>
14461446
<div><h2 id="commandexecution"><a href="#commandexecution" name="commandexecution">#</a>Command Execution</h2><div><h3 id="filesanddirectories">Files and Directories</h3><ul>
14471447
<li><strong>Paths can be either strings, Paths, or DirEntry objects.</strong></li>
1448-
<li><strong>All exceptions are either 'OSError' or its subclasses.</strong></li>
1449-
</ul><pre><code class="python language-python hljs"><span class="hljs-keyword">import</span> os
1448+
<li><strong>All exceptions are either OSError or its subclasses.</strong></li>
1449+
</ul><pre><code class="python language-python hljs"><span class="hljs-keyword">import</span> os, shutil
14501450
&lt;str&gt; = os.getcwd() <span class="hljs-comment"># Returns the current working directory.</span>
14511451
os.chdir(&lt;path&gt;) <span class="hljs-comment"># Changes current working directory.</span>
14521452
</code></pre></div></div>
14531453

14541454

14551455

1456+
<pre><code class="python language-python hljs">shutil.copy(from, to) <span class="hljs-comment"># Copies the file.</span>
1457+
os.rename(from, to) <span class="hljs-comment"># Renames the file or directory.</span>
1458+
os.replace(from, to) <span class="hljs-comment"># Same, but overwrites 'to' if it exists.</span>
1459+
</code></pre>
14561460
<pre><code class="python language-python hljs">os.remove(&lt;path&gt;) <span class="hljs-comment"># Deletes the file.</span>
14571461
os.rmdir(&lt;path&gt;) <span class="hljs-comment"># Deletes empty directory.</span>
14581462
shutil.rmtree(&lt;path&gt;) <span class="hljs-comment"># Deletes the entire directory tree.</span>
14591463
</code></pre>
1460-
<pre><code class="python language-python hljs">os.rename(from, to) <span class="hljs-comment"># Renames the file or directory.</span>
1461-
os.replace(from, to) <span class="hljs-comment"># Same, but overwrites 'to' if it exists.</span>
1462-
</code></pre>
14631464
<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>
14641465
&lt;iter&gt; = os.scandir(path=<span class="hljs-string">'.'</span>) <span class="hljs-comment"># Returns os.DirEntry objects located at path.</span>
14651466
</code></pre>

parse.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ const DIAGRAM_7_B =
195195
'┗━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━━━┛\n';
196196

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

0 commit comments

Comments
 (0)