@classmethod<EOL><INDENT>def from_stat(cls, obj, filename=None):<DEDENT>
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 ``stat`` object (an
object returned by `os.stat`).

:param object obj: an object returned by `os.stat` (or equivalent).
:param str filename: the filename associated with this file.
:return: new `.SFTPAttributes` object with the same attribute fields.