main.py 文件源码

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

项目:labgrid 作者: labgrid-project 项目源码 文件源码
def _get_function(self, name, context):
        snippet = self.config.data['autoinstall'].get(name)
        if not snippet:
            return None

        code = 'def {}():\n{}'.format(name, textwrap.indent(snippet, ' '))
        tree = ast.parse(code, filename=self.env.config_file)
        ast.increment_lineno(tree, snippet.start_mark.line)
        co = compile(tree, filename=self.env.config_file, mode='exec')

        stage = {}
        exec(co, context, stage)
        return stage[name]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号