def convert_errno(e):
if e == errno.EACCES:<EOL><INDENT>return SFTP_PERMISSION_DENIED<EOL><DEDENT>elif (e == errno.ENOENT) or (e == errno.ENOTDIR):<EOL><INDENT>return SFTP_NO_SUCH_FILE<EOL><DEDENT>else:<EOL><INDENT>return SFTP_FAILURE<EOL><DEDENT>
Convert an errno value (as from an C{OSError} or C{IOError}) into a
standard SFTP result code.  This is a convenience function for trapping
exceptions in server code and returning an appropriate result.

@param e: an errno code, as from C{OSError.errno}.
@type e: int
@return: an SFTP error code like L{SFTP_NO_SUCH_FILE}.
@rtype: int