omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    List of sub-workflows

    Editorial
    2
    3
    2143
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • tguillemin
      tguillemin last edited by

      This is, of course , inspired by the question "List of workflows"
      [https://forum.omz-software.com/topic/3994/list-of-workflows](link url)

      I wondered if it would be possible to obtain the list of all sub-workflows in the different main workflows, e.g. :

      workflowfoo:subworkflowbar
      workflowfoo:subworkflowbaz

      Although this would help me keeping organized (some workflows are used as sub-workflows in more than one other workflow), this is, alas, far beyond my competences…

      Thanks in advance

      1 Reply Last reply Reply Quote 0
      • omz
        omz last edited by

        Something like this should work for common cases. It won't show sub-workflows within sub-workflows though, just sub-workflows that are embedded directly.

        #coding: utf-8
        import workflow
        import editor
        import os
        import json
        
        cmd_path = os.path.join(editor.get_workflows_path(), 'Commands.edcmd')
        with open(cmd_path, 'r') as f:
        	workflows = json.load(f)
        	for wf_info in workflows:
        		print wf_info['title']
        		with open(wf_info['filename'], 'r') as wf_file:
        			wf = json.load(wf_file)
        			actions = wf['actions']
        			for a in actions:
        				if a['class'] == 'WorkflowActionRunSubWorkflow':
        					sub_wf_name = a['parameters']['workflow'].get('name')
        					print '...', sub_wf_name
        					
        
        1 Reply Last reply Reply Quote 0
        • tguillemin
          tguillemin last edited by

          Thank you very much for your answer.

          It works, of course, beautifully.

          Thanks again

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Powered by NodeBB Forums | Contributors