def ensure_fs_mode(filepath, desired_mode=S_IWRITE):
 mode = stat(filepath)[ST_MODE]
 if (not (mode & desired_mode)):
  chmod(filepath, (mode | desired_mode))

def ensure_fs_mode ( filepath , desired_mode = S_IWRITE ) : mode = stat ( filepath ) [ ST_MODE ] if ( not ( mode & desired_mode ) ) : chmod ( filepath , ( mode | desired_mode ) )
check that the given file has the given mode(s) set .