[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:
parent
2f3228dd88
commit
920df7d0ae
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue