[project @ Arch-1:robey@lag.net--2003-public%secsh--dev--1.0--patch-108]

add filename to SFTPAttributes
add filename to the attributes stored in an SFTPAttributes object.
This commit is contained in:
Robey Pointer 2004-11-07 02:51:42 +00:00
parent 2f3228dd88
commit 920df7d0ae
1 changed files with 5 additions and 1 deletions

View File

@ -54,13 +54,15 @@ class SFTPAttributes (object):
self._flags = 0
self.attr = {}
def from_stat(cls, obj):
def from_stat(cls, obj, filename=None):
"""
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}
"""
@ -71,6 +73,8 @@ class SFTPAttributes (object):
attr.st_mode = obj.st_mode
attr.st_atime = obj.st_atime
attr.st_mtime = obj.st_mtime
if filename is not None:
attr.filename = filename
return attr
from_stat = classmethod(from_stat)