diff --git a/README.md b/README.md index 102b5eb..8c28b93 100644 --- a/README.md +++ b/README.md @@ -1493,13 +1493,13 @@ value = args. Open ---- -**Opens a file and returns a corresponding file object.** +**Opens the file and returns a corresponding file object.** ```python = open('', mode='r', encoding=None, newline=None) ``` * **`'encoding=None'` means default encoding is used, which is platform dependent. Best practice is to use `'encoding="utf-8"'` whenever possible.** -* **`'newline=None'` means all different end of line combinations are converted to '\n' on read, while on write all '\n' characters are converted to system's default line separator.** +* **`'newline=None'` means all different end of line combinations are converted to '\n' on read, while on write all '\n' characters are converted to the system's default line separator.** * **`'newline=""'` means no conversions take place, but input is still broken into chunks by readline() and readlines() on either '\n', '\r' or '\r\n'.** ### Modes @@ -1570,8 +1570,8 @@ from glob import glob ``` ```python - = listdir('') # List of filenames located at path. - = glob('') # Filenames matching the wildcard pattern. + = listdir('') # List of filenames located at path. + = glob('') # Filenames matching the wildcard pattern. ``` ### Pathlib @@ -1592,22 +1592,22 @@ cwd = Path() ``` ```python - = .iterdir() # Returns dir contents as Path objects. - = .glob('') # Returns Paths matching the wildcard pattern. + = .iterdir() # Returns dir contents as Path objects. + = .glob('') # Returns Paths matching the wildcard pattern. ``` ```python - = str() # Path as a string. - = .name # Final component. - = .stem # Final component without extension. - = .suffix # Final component's extension. - = .parts # All components as strings. + = str() # Path as a string. + = .name # Final component. + = .stem # Final component without extension. + = .suffix # Final component's extension. + = .parts # All components as strings. ``` ```python - = .resolve() # Returns absolute path without symlinks. - = .parent # Returns path without final component. - = open() # Opens the file and returns a file object. + = .resolve() # Returns absolute path without symlinks. + = .parent # Returns path without final component. + = open() # Opens the file and returns a file object. ``` @@ -1622,29 +1622,29 @@ import os, shutil ``` ```python -os.chdir() # Changes current working directory. -os.mkdir(, mode=0o777) # Creates a directory. +os.chdir() # Changes current working directory. +os.mkdir(, mode=0o777) # Creates a directory. ``` ```python -os.rename(from, to) # Renames the file or directory. -os.replace(from, to) # Same, but overwrites 'to' if it exists. +os.rename(from, to) # Renames the file or directory. +os.replace(from, to) # Same, but overwrites 'to' if it exists. ``` ```python -os.remove() # Deletes the file. -os.rmdir() # Deletes empty directory. -shutil.rmtree() # Deletes the entire directory tree. +os.remove() # Deletes the file. +os.rmdir() # Deletes empty directory. +shutil.rmtree() # Deletes the entire directory tree. ``` ```python -shutil.copy(from, to) # Copies the file. -shutil.copytree(from, to) # Copies the entire directory tree. +shutil.copy(from, to) # Copies the file. +shutil.copytree(from, to) # Copies the entire directory tree. ``` ```python - = os.getcwd() # Returns the current working directory. - = os.scandir(path='.') # Returns os.DirEntry objects located at path. + = os.getcwd() # Returns the current working directory. + = os.scandir(path='.') # Returns os.DirEntry objects located at path. ``` #### DirEntry: @@ -1654,13 +1654,13 @@ shutil.copytree(from, to) # Copies the entire directory tree. ``` ```python - = .path # Path as a string. - = .name # Final component. + = .path # Path as a string. + = .name # Final component. ``` ```python - = Path() # Path object. - = open() # File object. + = Path() # Path object. + = open() # File object. ``` ### Shell Commands diff --git a/index.html b/index.html index 94d9c36..284c06d 100644 --- a/index.html +++ b/index.html @@ -1381,13 +1381,13 @@ value = args.<name>
  • Use 'default=<el>' to set the default value.
  • Use 'type=FileType(<mode>)' for files.
  • -

    #Open

    Opens a file and returns a corresponding file object.

    <file> = open('<path>', mode='r', encoding=None, newline=None)
    +

    #Open

    Opens the file and returns a corresponding file object.

    <file> = open('<path>', mode='r', encoding=None, newline=None)
     
    • 'encoding=None' means default encoding is used, which is platform dependent. Best practice is to use 'encoding="utf-8"' whenever possible.
    • -
    • 'newline=None' means all different end of line combinations are converted to '\n' on read, while on write all '\n' characters are converted to system's default line separator.
    • +
    • 'newline=None' means all different end of line combinations are converted to '\n' on read, while on write all '\n' characters are converted to the system's default line separator.
    • 'newline=""' means no conversions take place, but input is still broken into chunks by readline() and readlines() on either '\n', '\r' or '\r\n'.

    Modes

      @@ -1445,8 +1445,8 @@ value = args.<name> <bool> = path.isfile('<path>') <bool> = path.isdir('<path>')
    -
    <list> = listdir('<path>')         # List of filenames located at path.
    -<list> = glob('<pattern>')         # Filenames matching the wildcard pattern.
    +
    <list> = listdir('<path>')          # List of filenames located at path.
    +<list> = glob('<pattern>')          # Filenames matching the wildcard pattern.
     

    Pathlib

    from pathlib import Path
     
    @@ -1459,18 +1459,18 @@ value = args.<name> <bool> = <Path>.is_file() <bool> = <Path>.is_dir()
    -
    <iter> = <Path>.iterdir()          # Returns dir contents as Path objects.
    -<iter> = <Path>.glob('<pattern>')  # Returns Paths matching the wildcard pattern.
    +
    <iter> = <Path>.iterdir()           # Returns dir contents as Path objects.
    +<iter> = <Path>.glob('<pattern>')   # Returns Paths matching the wildcard pattern.
     
    -
    <str>  = str(<Path>)               # Path as a string.
    -<str>  = <Path>.name               # Final component.
    -<str>  = <Path>.stem               # Final component without extension.
    -<str>  = <Path>.suffix             # Final component's extension.
    -<tup.> = <Path>.parts              # All components as strings.
    +
    <str>  = str(<Path>)                # Path as a string.
    +<str>  = <Path>.name                # Final component.
    +<str>  = <Path>.stem                # Final component without extension.
    +<str>  = <Path>.suffix              # Final component's extension.
    +<tup.> = <Path>.parts               # All components as strings.
     
    -
    <Path> = <Path>.resolve()          # Returns absolute path without symlinks.
    -<Path> = <Path>.parent             # Returns path without final component.
    -<file> = open(<Path>)              # Opens the file and returns a file object.
    +
    <Path> = <Path>.resolve()           # Returns absolute path without symlinks.
    +<Path> = <Path>.parent              # Returns path without final component.
    +<file> = open(<Path>)               # Opens the file and returns a file object.
     

    #OS Commands

    Files and Directories

    • Paths can be either strings, Paths, or DirEntry objects.
    • @@ -1480,31 +1480,31 @@ value = args.<name> -
      os.chdir(<path>)                   # Changes current working directory.
      -os.mkdir(<path>, mode=0o777)       # Creates a directory.
      +
      os.chdir(<path>)                    # Changes current working directory.
      +os.mkdir(<path>, mode=0o777)        # Creates a directory.
       
      -
      os.rename(from, to)                # Renames the file or directory.
      -os.replace(from, to)               # Same, but overwrites 'to' if it exists.
      +
      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.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.
      -shutil.copytree(from, to)          # Copies the entire directory tree.
      +
      shutil.copy(from, to)               # Copies the file.
      +shutil.copytree(from, to)           # Copies the entire directory tree.
       
      -
      <str>  = os.getcwd()               # Returns the current working directory.
      -<iter> = os.scandir(path='.')      # Returns os.DirEntry objects located at path.
      +
      <str>  = os.getcwd()                # Returns the current working directory.
      +<iter> = os.scandir(path='.')       # Returns os.DirEntry objects located at path.
       

      DirEntry:

      <bool> = <DirEntry>.is_file()
       <bool> = <DirEntry>.is_dir()
       
      -
      <str>  = <DirEntry>.path           # Path as a string.
      -<str>  = <DirEntry>.name           # Final component.
      +
      <str>  = <DirEntry>.path            # Path as a string.
      +<str>  = <DirEntry>.name            # Final component.
       
      -
      <Path> = Path(<DirEntry>)          # Path object.
      -<file> = open(<DirEntry>)          # File object.
      +
      <Path> = Path(<DirEntry>)           # Path object.
      +<file> = open(<DirEntry>)           # File object.
       

      Shell Commands

      import os
       <str> = os.popen('<shell_command>').read()
      diff --git a/parse.js b/parse.js
      index ccd257f..8cee01c 100755
      --- a/parse.js
      +++ b/parse.js
      @@ -195,12 +195,12 @@ const DIAGRAM_7_B =
         '┗━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━━━┛\n';
       
       const OS_RENAME =
      -  'os.rename(from, to)                # Renames the file or directory.\n' +
      -  'os.replace(from, to)               # Same, but overwrites \'to\' if it exists.\n';
      +  'os.rename(from, to)                 # Renames the file or directory.\n' +
      +  'os.replace(from, to)                # Same, but overwrites \'to\' if it exists.\n';
       
       const SHUTIL_COPY = 
      -  'shutil.copy(from, to)              # Copies the file.\n' +
      -  'shutil.copytree(from, to)          # Copies the entire directory tree.\n';
      +  'shutil.copy(from, to)               # Copies the file.\n' +
      +  'shutil.copytree(from, to)           # Copies the entire directory tree.\n';
       
       const EVAL =
         '>>> from ast import literal_eval\n' +