buffer_manager.py 文件源码

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

项目:ci_edit 作者: google 项目源码 文件源码
def readStdin(self):
    app.log.info('reading from stdin')
    # Create a new input stream for the file data.
    # Fd is short for file descriptor. os.dup and os.dup2 will duplicate file
    # descriptors.
    stdinFd = sys.stdin.fileno()
    newFd = os.dup(stdinFd)
    newStdin = open("/dev/tty")
    os.dup2(newStdin.fileno(), stdinFd)
    # Create a text buffer to read from alternate stream.
    textBuffer = self.newTextBuffer()
    try:
      with io.open(newFd, "r") as fileInput:
        textBuffer.fileFilter(fileInput.read())
    except Exception as e:
      app.log.exception(e)
    app.log.info('finished reading from stdin')
    return textBuffer
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号