'Return a folder hierarchy containing workflow objects for each workflow dictionary in the
received workflows list.  When this method is called from the tool shed, repository_metadata_id
will have a value and repository_id will be None.  When this method is called from Galaxy,
repository_id will have a value only if the repository is not currenlty being installed and
repository_metadata_id will be None.'

def build_workflows_folder(self, folder_id, workflows, repository_metadata_id=None, repository_id=None, label='Workflows'):

    if workflows:
        workflow_id = 0
        folder_id += 1
        workflows_root_folder = Folder(id=folder_id, key='root', label='root', parent=None)
        folder_id += 1
        folder = Folder(id=folder_id, key='workflows', label=label, parent=workflows_root_folder)
        workflows_root_folder.folders.append(folder)
        workflow_id += 1
        workflow = Workflow(id=workflow_id, workflow_name='Name', steps='steps', format_version='format-version', annotation='annotation', repository_metadata_id=repository_metadata_id, repository_id=repository_id)
        folder.workflows.append(workflow)
        for workflow_tup in workflows:
            workflow_dict = workflow_tup[1]
            steps = workflow_dict.get('steps', [])
            if steps:
                steps = str(len(steps))
            else:
                steps = 'unknown'
            workflow_id += 1
            workflow = Workflow(id=workflow_id, workflow_name=workflow_dict.get('name', ''), steps=steps, format_version=workflow_dict.get('format-version', ''), annotation=workflow_dict.get('annotation', ''), repository_metadata_id=repository_metadata_id, repository_id=repository_id)
            folder.workflows.append(workflow)
    else:
        workflows_root_folder = None
    return (folder_id, workflows_root_folder)
