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()
评论列表
文章目录