macro.py 文件源码

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

项目:sardana 作者: sardana-org 项目源码 文件源码
def exec_(self):
        """**Internal method**. Execute macro as an iterator"""
        self._macro_thread = threading.current_thread()
        macro_status = self.getMacroStatus()

        # make sure a 0.0 progress is sent
        yield macro_status

        # allow any macro to be paused at the beginning of its execution
        self.pausePoint()

        # Run the macro or obtain a generator
        res = self.run(*self._in_pars)

        # If macro returns a generator then running the macro means go through
        # the generator steps, otherwise the macro has already ran
        if isinstance(res, types.GeneratorType):
            it = iter(res)
            for i in it:
                if operator.isMappingType(i):
                    new_range = i.get('range')
                    if new_range is not None:
                        macro_status['range'] = new_range
                    new_step = i.get('step')
                    if new_step is not None:
                        macro_status['step'] = new_step
                elif operator.isNumberType(i):
                    macro_status['step'] = i
                macro_status['state'] = 'step'
                yield macro_status
            # make sure a 'stop' progress is sent in case an exception occurs
            macro_status['state'] = 'stop'
        else:
            self._out_pars = res
            macro_status['step'] = 100.0
        macro_status['state'] = 'finish'
        yield macro_status
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号