def from_stat(cls, obj, filename=None):
attr = cls()<EOL>attr.st_size = obj.st_size<EOL>attr.st_uid = obj.st_uid<EOL>attr.st_gid = obj.st_gid<EOL>attr.st_mode = obj.st_mode<EOL>attr.st_atime = obj.st_atime<EOL>attr.st_mtime = obj.st_mtime<EOL>if filename is not None:<EOL><INDENT>attr.filename = filename<EOL><DEDENT>return attr<EOL>
Create an SFTPAttributes object from an existing C{stat} object (an
object returned by C{os.stat}).

@param obj: an object returned by C{os.stat} (or equivalent).
@type obj: object
@param filename: the filename associated with this file.
@type filename: str
@return: new L{SFTPAttributes} object with the same attribute fields.
@rtype: L{SFTPAttributes}