Browse Source

Command execution

pull/41/head
Jure Šorn 6 years ago
parent
commit
f9f99689b9
3 changed files with 15 additions and 12 deletions
  1. 15
      README.md
  2. 11
      index.html
  3. 1
      parse.js

15
README.md

@ -1594,23 +1594,24 @@ Command Execution
----------------- -----------------
### Files and Directories ### Files and Directories
* **Paths can be either strings, Paths, or DirEntry objects.** * **Paths can be either strings, Paths, or DirEntry objects.**
* **All exceptions are either 'OSError' or its subclasses.**
* **All exceptions are either OSError or its subclasses.**
```python ```python
import os
import os, shutil
<str> = os.getcwd() # Returns the current working directory. <str> = os.getcwd() # Returns the current working directory.
os.chdir(<path>) # Changes current working directory. os.chdir(<path>) # Changes current working directory.
``` ```
```python ```python
os.remove(<path>) # Deletes the file.
os.rmdir(<path>) # Deletes empty directory.
shutil.rmtree(<path>) # Deletes the entire directory tree.
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.
``` ```
```python ```python
os.rename(from, to) # Renames the file or directory.
os.replace(from, to) # Same, but overwrites 'to' if it exists.
os.remove(<path>) # Deletes the file.
os.rmdir(<path>) # Deletes empty directory.
shutil.rmtree(<path>) # Deletes the entire directory tree.
``` ```
```python ```python

11
index.html

@ -1445,21 +1445,22 @@ value = args.&lt;name&gt;
</code></pre> </code></pre>
<div><h2 id="commandexecution"><a href="#commandexecution" name="commandexecution">#</a>Command Execution</h2><div><h3 id="filesanddirectories">Files and Directories</h3><ul> <div><h2 id="commandexecution"><a href="#commandexecution" name="commandexecution">#</a>Command Execution</h2><div><h3 id="filesanddirectories">Files and Directories</h3><ul>
<li><strong>Paths can be either strings, Paths, or DirEntry objects.</strong></li> <li><strong>Paths can be either strings, Paths, or DirEntry objects.</strong></li>
<li><strong>All exceptions are either 'OSError' or its subclasses.</strong></li>
</ul><pre><code class="python language-python hljs"><span class="hljs-keyword">import</span> os
<li><strong>All exceptions are either OSError or its subclasses.</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> &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> os.chdir(&lt;path&gt;) <span class="hljs-comment"># Changes current working directory.</span>
</code></pre></div></div> </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>
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> <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> 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> shutil.rmtree(&lt;path&gt;) <span class="hljs-comment"># Deletes the entire directory tree.</span>
</code></pre> </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.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">os.mkdir(&lt;path&gt;, mode=<span class="hljs-number">0o777</span>) <span class="hljs-comment"># Creates a 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> &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> </code></pre>

1
parse.js

@ -195,6 +195,7 @@ const DIAGRAM_7_B =
'┗━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━━━┛\n'; '┗━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━━━┛\n';
const OS_RENAME = const OS_RENAME =
'shutil.copy(from, to) <span class="hljs-comment"># Copies the file.</span>\n' +
'os.rename(from, to) <span class="hljs-comment"># Renames the file or directory.</span>\n' + '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'; 'os.replace(from, to) <span class="hljs-comment"># Same, but overwrites \'to\' if it exists.</span>\n';

Loading…
Cancel
Save