Browse Source

Command execution

pull/40/head
Jure Šorn 5 years ago
parent
commit
af74510cfc
3 changed files with 14 additions and 5 deletions
  1. 2
      README.md
  2. 6
      index.html
  3. 11
      parse.js

2
README.md

@ -1591,7 +1591,7 @@ cwd = Path()
Command Execution
-----------------
### Files and Directories Commands
### Files and Directories
* **Paths can be either strings or Path objects.**
* **All exceptions are either 'OSError' or its subclasses.**

6
index.html

@ -1431,7 +1431,7 @@ value = args.<name>
&lt;Path&gt; = &lt;Path&gt;.parent <span class="hljs-comment"># Path without final component.</span>
</code></pre>
<h2 id="commandexecution"><a href="#commandexecution" name="commandexecution">#</a>Command Execution</h2>
<h3 id="filesanddirectoriescommands">Files and Directories Commands</h3>
<h3 id="filesanddirectories">Files and Directories</h3>
<ul>
<li><strong>Paths can be either strings or Path objects.</strong></li>
<li><strong>All exceptions are either 'OSError' or its subclasses.</strong></li>
@ -1444,8 +1444,8 @@ os.chdir(&lt;path&gt;) <span class="hljs-comment"># Changes th
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.rename(<span class="hljs-keyword">from</span>, to) <span class="hljs-comment"># Renames the file or directory.</span>
os.replace(<span class="hljs-keyword">from</span>, to) <span class="hljs-comment"># Same, but overwrites 'to' if it exists.</span>
<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>
&lt;iter&gt; = os.scandir(path=<span class="hljs-string">'.'</span>) <span class="hljs-comment"># Returns os.DirEntry objects located at path.</span>

11
parse.js

@ -194,6 +194,10 @@ const DIAGRAM_7_B =
'┃ count() │ │ │ │ ✓ ┃\n' +
'┗━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━━━┛\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';
function main() {
const html = getMd();
@ -273,7 +277,8 @@ function highlightCode() {
$('code').each(function(index) {
hljs.highlightBlock(this);
});
fixClasses()
fixClasses();
fixFroms();
}
function setApaches(elements) {
@ -287,6 +292,10 @@ function fixClasses() {
$('.hljs-class').filter(':contains(class \')').find(':first-child').removeClass('hljs-keyword').addClass('hljs-title')
}
function fixFroms() {
$(`code:contains(os.rename)`).html(OS_RENAME);
}
function readFile(filename) {
try {
return fs.readFileSync(filename, 'utf8');

Loading…
Cancel
Save