def set_file_attr(filename, attr):
if sys.platform != '<STR_LIT:win32>':<EOL><INDENT>if attr._flags & attr.FLAG_PERMISSIONS:<EOL><INDENT>os.chmod(filename, attr.st_mode)<EOL><DEDENT>if attr._flags & attr.FLAG_UIDGID:<EOL><INDENT>os.chown(filename, attr.st_uid, attr.st_gid)<EOL><DEDENT><DEDENT>if attr._flags & attr.FLAG_AMTIME:<EOL><INDENT>os.utime(filename, (attr.st_atime, attr.st_mtime))<EOL><DEDENT>if attr._flags & attr.FLAG_SIZE:<EOL><INDENT>open(filename, '<STR_LIT>').truncate(attr.st_size)<EOL><DEDENT>
Change a file's attributes on the local filesystem.  The contents of
C{attr} are used to change the permissions, owner, group ownership,
and/or modification & access time of the file, depending on which
attributes are present in C{attr}.

This is meant to be a handy helper function for translating SFTP file
requests into local file operations.

@param filename: name of the file to alter (should usually be an
    absolute path).
@type filename: str
@param attr: attributes to change.
@type attr: L{SFTPAttributes}