builder.py 文件源码

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

项目:WXBotForPi 作者: nemoTyrant 项目源码 文件源码
def _get_writable(stream_or_path, mode):
    """This method returns a tuple containing the stream and a flag to indicate
    if the stream should be automatically closed.

    The `stream_or_path` parameter is returned if it is an open writable stream.
    Otherwise, it treats the `stream_or_path` parameter as a file path and
    opens it with the given mode.

    It is used by the svg and png methods to interpret the file parameter.

    :type stream_or_path: str | io.BufferedIOBase
    :type mode: str | unicode
    :rtype: (io.BufferedIOBase, bool)
    """
    is_stream = hasattr(stream_or_path, 'write')
    if not is_stream:
        # No stream provided, treat "stream_or_path" as path
        stream_or_path = open(stream_or_path, mode)
    return stream_or_path, not is_stream
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号