Set permissions for a file or directory.

    :param file_path: Path to a file or directory
    :param code: Permission code in absolute notation (octal)
    :return:

def set_permissions_mode_from_octal(file_path, code):
    """
    Set permissions for a file or directory.

    :param file_path: Path to a file or directory
    :param code: Permission code in absolute notation (octal)
    :return:
    """
    # Unpack permissions tuple
    user, group, other = tuple(str(code[-3:])) if len(str(code)) > 3 else tuple(str(code))
    user, group, other = int(user), int(group), int(other)
    mode = get_permissions_mode(user,
                                'user') & get_permissions_mode(group, 'group') & get_permissions_mode(other, 'other')
    os.chmod(file_path, mode)