command.py 文件源码

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

项目:jiveplot 作者: haavee 项目源码 文件源码
def __enter__(self):
        # we only do something if we have readline
        if not haveReadline:
            return self
        ## Set up the new history context
        self.historyFile      = os.path.join( os.getenv('HOME'), ".{0}.history".format(self.basename)) 
        (h, self.oldhistFile) = tempfile.mkstemp(prefix=self.basename, suffix=".hist", dir="/tmp")
        # only need the filename, really
        os.close(h)
        readline.write_history_file(self.oldhistFile)
        readline.clear_history()

        # if reading the old history fails, fail silently
        # (the file might not exist yet)
        try:
            readline.read_history_file(self.historyFile)
        except:
            pass

        # store the old completer, install our own one
        readline.parse_and_bind("tab: complete")
        #readline.parse_and_bind("C-c: backward-kill-line")
        self.oldCompleter = readline.get_completer()
        readline.set_completer(self.completer)
        return self

    # clean up the context
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号