# Path: sofia/workflow_template/load_template.py
# def load_template(root):
#     entities, parser, provided_entities = load_entity_set(os.path.join(root, 'entities.json'))
#     steps = load_steps(os.path.join(root, 'steps'))
#     steps.update(get_extractors(entities))
#     attributes = load_attributes(os.path.join(root, 'attributes'))
# 
#     template = Template(entities=entities, steps=steps, attributes=attributes, parser=parser)
#     for entity in provided_entities:
#         entity.attributes['filename'] = {os.path.join(root, 'data', list(entity.attributes['filename'])[0])}
#         template.provide_entity(entity)
#     return template


import argparse
import pickle
import os
import sys
    import inspect
from sofia.workflow_template import load_template



def build(template_directories):
    """
    Build a template from the source template directories.

    :param template_directories: source template directories
    :return: template workflow
    """
    template = load_template(template_directories[0])
    for directory in template_directories[1:]:

# Path: sofia/workflow_template/load_template.py
# def load_template(root):
#     entities, parser, provided_entities = load_entity_set(os.path.join(root, 'entities.json'))
#     steps = load_steps(os.path.join(root, 'steps'))
#     steps.update(get_extractors(entities))
#     attributes = load_attributes(os.path.join(root, 'attributes'))
# 
#     template = Template(entities=entities, steps=steps, attributes=attributes, parser=parser)
#     for entity in provided_entities:
#         entity.attributes['filename'] = {os.path.join(root, 'data', list(entity.attributes['filename'])[0])}
#         template.provide_entity(entity)
#     return template


# Path: sofia/tools/build.py
import argparse
import pickle
import os
import sys
    import inspect
from sofia.workflow_template import load_template




def build(template_directories):
    """
    Build a template from the source template directories.

    :param template_directories: source template directories
    :return: template workflow
    """
    template = load_template(template_directories[0])
    for directory in template_directories[1:]:

        template.update(load_template(directory))