encoding.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:aws-encryption-sdk-cli 作者: awslabs 项目源码 文件源码
def _passthrough_interactive_check(self, method_name, mode):
        # type: (str, str) -> bool
        """Attempt to call the specified method on the wrapped stream and return the result.
        If the method is not found on the wrapped stream, returns False.

        .. note::

            Special Case: If wrapped stream is a Python 2 file, inspect the file mode.

        :param str method_name: Name of method to call
        :param str mode: Python 2 mode character
        :rtype: bool
        """
        try:
            method = getattr(self.__wrapped, method_name)
        except AttributeError:
            if six.PY2 and isinstance(self.__wrapped, file):  # noqa pylint: disable=undefined-variable
                if mode in self.__wrapped.mode:
                    return True
            return False
        else:
            return method()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号