diff options
author | Robey Pointer <robey@lag.net> | 2007-05-20 15:56:22 -0700 |
---|---|---|
committer | Robey Pointer <robey@lag.net> | 2007-05-20 15:56:22 -0700 |
commit | 3229cd0f94c75504e66e40cce088a3ed4c6edfec (patch) | |
tree | bf98125ac5240b2558a448d82d79c1fc374b71b9 | |
parent | 920b1723606f5cf3cf16155dedeaa9c1b633af82 (diff) |
[project @ robey@lag.net-20070520225622-ozs9cguu8ipaxt85]
patch from wesley augur: expose the 'longname' field from listdir_attr().
-rw-r--r-- | paramiko/sftp_attr.py | 4 | ||||
-rw-r--r-- | 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 adf46d2f..9c928623 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 bb703adb..f79187d3 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) |