flow_graph.py 文件源码

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

项目:viewflow-extensions 作者: Thermondo 项目源码 文件源码
def handle(self, **options):
        flow_path = options.get('flow_path')
        output = options.get('output')
        graph_type = options.get('graph_type')
        try:
            file_path, flow_name = flow_path[0].rsplit('.', 1)
        except ValueError as e:
            raise CommandError("Please, specify the full path to your flow.") from e
        try:
            flows_file = importlib.import_module(file_path)
            flow_cls = getattr(flows_file, flow_name)
        except ImportError as e:
            raise CommandError("Could not find file %s" % (file_path,)) from e
        except (AttributeError, TypeError) as e:
            raise CommandError("Could not find the flow with the name %s" % (flow_name,)) from e

        grid = chart.calc_layout_data(flow_cls)
        if graph_type == SVG:
            graph = chart.grid_to_svg(grid)
        if graph_type == BPMN:
            graph = chart.grid_to_bpmn(grid)
        if output != '':
            with open(output, 'w') as f:
                f.write(graph)
        else:
            self.stdout.write(graph)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号