subflow.py 文件源码

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

项目:subflow 作者: amitness 项目源码 文件源码
def run(self, edit):
        for region in self.view.sel():
            line = self.view.line(region)
            cont = self.view.substr(line)

        if (len(cont) < 2):
            pass
        else:
            lang = " in " + self.get_syntax()
            cont = cont.strip()
            cont = cont + lang
            p = subprocess.Popen("howdoi " + cont,
                                 stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE,
                                 shell=True)
            output, errors = p.communicate()

            # Decode binary data for python 3
            output = output.decode('utf-8')

            # Remove CR for windows.
            if sublime.platform() == 'windows':
                output = output.replace('\r', '')

            self.view.replace(edit, line, output)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号