def check_filemode(filepath, mode):
    """Return True if 'file' matches ('permission') which should be entered in octal.
    """

    filemode = stat.S_IMODE(os.stat(filepath).st_mode)
    return (oct(filemode) == mode)
Return True if 'file' matches ('permission') which should be entered in octal.