1.2.6. fs_utilities

This module collects various useful file system utility functions that are used throughout the application.

1.2.6.1. Functions

access(path, mode, user=AUTOMATIC, group=AUTOMATIC)[source]

This is a high-level wrapper around os.access() to provide additional functionality. Similar to os.access this high-level wrapper will test the given path for a variety of access modes. Additionally user or group can be specified to test access for a specific user or group.

New in version 1.14.0.

Parameters:
  • path (str) – The path to test access for.
  • mode (int) – The mode to test access for. Set to os.R_OK to test for readability, os.W_OK for writability and os.X_OK to determine if path can be executed.
  • user (int, str, None, AUTOMATIC) – The user to test permissions for. If set to AUTOMATIC, the process’s current uid will be used.
  • group (int, str, None, AUTOMATIC) – The group to test permissions for. If set to AUTOMATIC, the group that user belongs too will be used.
Returns:

Returns True only if the user or group has the mode of permission specified else returns False.

Return type:

bool

chown(path, user=None, group=AUTOMATIC, recursive=True)[source]

This is a high-level wrapper around os.chown() to provide additional functionality. None can be specified as the user or group to leave the value unchanged. At least one of either user or group must be specified.

New in version 1.14.0.

Parameters:
  • path (str) – The path to change the owner information for.
  • user (int, str, None, AUTOMATIC) – The new owner to set for the path. If set to AUTOMATIC, the process’s current uid will be used.
  • group (int, str, None, AUTOMATIC) – The new group to set for the path. If set to AUTOMATIC, the group that user belongs too will be used.
  • recursive (bool) – Whether or not to recurse into directories.