diff options
author | Michael Williamson <mike@zwobble.org> | 2013-09-29 17:56:41 +0100 |
---|---|---|
committer | Michael Williamson <mike@zwobble.org> | 2014-09-07 18:39:47 +0100 |
commit | 4c3b973c78b209170b2bbd7b50a0de1638a12e4a (patch) | |
tree | 6713a472775c728f17deb081738b04c603efd958 | |
parent | e0b323d7fb0d355bf7fcc469d3a24bd5a55f7ee4 (diff) |
Turn SFTPHandle into context managers
-rw-r--r-- | paramiko/sftp_handle.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/paramiko/sftp_handle.py b/paramiko/sftp_handle.py index 92dd9cfe..edceb5ad 100644 --- a/paramiko/sftp_handle.py +++ b/paramiko/sftp_handle.py @@ -22,9 +22,10 @@ Abstraction of an SFTP file handle (for server mode). import os from paramiko.sftp import SFTP_OP_UNSUPPORTED, SFTP_OK +from paramiko.util import ClosingContextManager -class SFTPHandle (object): +class SFTPHandle (ClosingContextManager): """ Abstract object representing a handle to an open file (or folder) in an SFTP server implementation. Each handle has a string representation used @@ -32,6 +33,8 @@ class SFTPHandle (object): Server implementations can (and should) subclass SFTPHandle to implement features of a file handle, like `stat` or `chattr`. + + Instances of this class may be used as context managers. """ def __init__(self, flags=0): """ |