Disk Util

This modules handles disk operations. Namely combining paths, checking them and creating folders..

git_sh_sync.util.disk.joined(*locs)

Joins paths together.

Parameters:locs – Single path elements to join together.
Returns:A full path combined by the following rules:
  • Leading slashes are stripped from all but the first element
  • Expanduser is applied (~)
  • Expandvars is applied (e.g. $HOME is then the same as ~)
  • Finally realpath is applied to resolve symlinks and return a full path
git_sh_sync.util.disk.spare(*locs, folder=False)

Checks if a path is not already occupied

Parameters:
  • locs – Input Parameter for joined()
  • folder – Flag to signal if to check for a file or folder
Returns:

True, False or None by the following rules:

  • If a folder is present and folder = True: False
  • If a folder is present and folder = False: None
  • If a file is present and folder = False: False
  • If a file is present and folder = True: None
  • If nothing is present: True
git_sh_sync.util.disk.ensured(*locs, folder=False)

Checks if the path already exists and creates (parent-)folders if necessary

Parameters:
  • locs – Input Parameter for spare()
  • folder – Treat locs Parameter as file or folder
Returns:

Output of joined()