From f9f99689b9ac2571aa9de20d4787ac91415d0a89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Tue, 23 Jul 2019 22:34:30 +0200 Subject: [PATCH] Command execution --- README.md | 15 ++++++++------- index.html | 11 ++++++----- parse.js | 1 + 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 3829990..8016854 100644 --- a/README.md +++ b/README.md @@ -1594,23 +1594,24 @@ Command Execution ----------------- ### Files and Directories * **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 -import os +import os, shutil = os.getcwd() # Returns the current working directory. os.chdir() # Changes current working directory. ``` ```python -os.remove() # Deletes the file. -os.rmdir() # Deletes empty directory. -shutil.rmtree() # 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 -os.rename(from, to) # Renames the file or directory. -os.replace(from, to) # Same, but overwrites 'to' if it exists. +os.remove() # Deletes the file. +os.rmdir() # Deletes empty directory. +shutil.rmtree() # Deletes the entire directory tree. ``` ```python diff --git a/index.html b/index.html index bd82e5b..b32946c 100644 --- a/index.html +++ b/index.html @@ -1445,21 +1445,22 @@ value = args.<name>

#Command Execution

Files and Directories

  • Paths can be either strings, Paths, or DirEntry objects.
  • -
  • All exceptions are either 'OSError' or its subclasses.
  • -
import os
+
  • All exceptions are either OSError or its subclasses.
  • +
    import os, shutil
     <str> = os.getcwd()                # Returns the current working directory.
     os.chdir(<path>)                   # Changes current working directory.
     
    +
    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.
    +
    os.remove(<path>)                  # Deletes the file.
     os.rmdir(<path>)                   # Deletes empty directory.
     shutil.rmtree(<path>)              # Deletes the entire directory tree.
     
    -
    os.rename(from, to)                # Renames the file or directory.
    -os.replace(from, to)               # Same, but overwrites 'to' if it exists.
    -
    os.mkdir(<path>, mode=0o777)       # Creates a directory.
     <iter> = os.scandir(path='.')      # Returns os.DirEntry objects located at path.
     
    diff --git a/parse.js b/parse.js index 5fadeae..6836b5e 100755 --- a/parse.js +++ b/parse.js @@ -195,6 +195,7 @@ const DIAGRAM_7_B = '┗━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━━━┛\n'; const OS_RENAME = + 'shutil.copy(from, to) # Copies the file.\n' + 'os.rename(from, to) # Renames the file or directory.\n' + 'os.replace(from, to) # Same, but overwrites \'to\' if it exists.\n';