From 3229cd0f94c75504e66e40cce088a3ed4c6edfec Mon Sep 17 00:00:00 2001 From: Robey Pointer Date: Sun, 20 May 2007 15:56:22 -0700 Subject: [PATCH] [project @ robey@lag.net-20070520225622-ozs9cguu8ipaxt85] patch from wesley augur: expose the 'longname' field from listdir_attr(). --- paramiko/sftp_attr.py | 4 +++- paramiko/sftp_client.py | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/paramiko/sftp_attr.py b/paramiko/sftp_attr.py index adf46d2..9c92862 100644 --- a/paramiko/sftp_attr.py +++ b/paramiko/sftp_attr.py @@ -90,11 +90,13 @@ class SFTPAttributes (object): ### internals... - def _from_msg(cls, msg, filename=None): + def _from_msg(cls, msg, filename=None, longname=None): attr = cls() attr._unpack(msg) if filename is not None: attr.filename = filename + if longname is not None: + attr.longname = longname return attr _from_msg = classmethod(_from_msg) diff --git a/paramiko/sftp_client.py b/paramiko/sftp_client.py index bb703ad..f79187d 100644 --- a/paramiko/sftp_client.py +++ b/paramiko/sftp_client.py @@ -114,7 +114,7 @@ class SFTPClient (BaseSFTP): """ self._log(INFO, 'sftp session closed.') self.sock.close() - + def listdir(self, path='.'): """ Return a list containing the names of the entries in the given C{path}. @@ -136,6 +136,11 @@ class SFTPClient (BaseSFTP): files in the given C{path}. The list is in arbitrary order. It does not include the special entries C{'.'} and C{'..'} even if they are present in the folder. + + The returned L{SFTPAttributes} objects will each have an additional + field: C{longname}, which may contain a formatted string of the file's + attributes, in unix format. The content of this string will probably + depend on the SFTP server implementation. @param path: path to list (defaults to C{'.'}) @type path: str @@ -163,7 +168,7 @@ class SFTPClient (BaseSFTP): for i in range(count): filename = _to_unicode(msg.get_string()) longname = _to_unicode(msg.get_string()) - attr = SFTPAttributes._from_msg(msg, filename) + attr = SFTPAttributes._from_msg(msg, filename, longname) if (filename != '.') and (filename != '..'): filelist.append(attr) self._request(CMD_CLOSE, handle)