utils.unix.files module
Unix file and file-listing utilities
- utils.unix.files.perms_to_octal(perms: str)
Convert a Unix perm string of the from “rwxrwxrwx.” to numeric
- utils.unix.files.perms_to_octal_set(perm_str: str)
Convert a single three-char section of Unix perms
- utils.unix.files.simplify_ls(ls_output: str, show_total: bool = False, **kwargs) str
Given an ls -l output, simplifies it to the important parts
kwargs are passed to simplify_ls_line
- utils.unix.files.simplify_ls_line(line: str, convert_perms: bool = True, show_perms: bool = True, show_links: bool = False, show_user: bool = True, show_group: bool = True, show_size: bool = False, show_date: bool = False, show_filename: bool = True, raise_exception: bool = False) str
Takes a single line in standard ls -l format and removes unimportant pieces
If convert_perms is True, will return perms as an octal permission set. If raise_exception is True, will raise a ValueError instead of returning the line as-is.
Expected format: -rw-r–r– 1 traherom traherom 62 Sep 27 10:06 ansible.cfg