def import_interface(filename, working_dir):
    import converter.box_interface_parser as parser
    filepath = os.path.join(working_dir, filename)
    result = parser.generate_tree_from_filename(filepath)
    if not result:
        print "Loading of %s failed!" % filename
        return None

    # then import dependency
    for content in result.contents:
        if content.content_type == xar_types.ContentType.ANIMATION:
            content.impl = import_animation(content.path,
                                            working_dir)
        elif content.content_type == xar_types.ContentType.FLOW_DIAGRAM:
            content.impl = import_flow_diagram(content.path,
                                               working_dir)
        elif content.content_type == xar_types.ContentType.BEHAVIOR_SEQUENCE:
            content.impl = import_sequence(content.path,
                                           working_dir)
        elif content.content_type == xar_types.ContentType.PYTHON_SCRIPT:
            content.impl = import_script_content(content.path,
                                                 working_dir)
        elif content.content_type == xar_types.ContentType.QICHAT_SCRIPT:
            content.impl = import_script_content(content.path,
                                                 working_dir)
        else:
            raise Exception("Unknown box implementation type: "
                            + str(content.content_type))

    return result
Пример #2
0
def test_parseNewAnimationFormat(parse_args):
    """ code to parse <animation>.anim and get root
        looking for no throw and root not None
    """
    filename = os.path.abspath(parse_args[4])
    root_node = animation_parser.generate_tree_from_filename(filename)
    assert root_node
def import_animation(filename, working_dir):
    import converter.animation_parser as parser
    filepath = os.path.join(working_dir, filename)
    result = parser.generate_tree_from_filename(filepath)
    if not result:
        print "Loading of %s failed!" % filename
    return result
Пример #4
0
def test_parseNewAnimationFormat(parse_args):
    """ code to parse <animation>.anim and get root
        looking for no throw and root not None
    """
    filename = os.path.abspath(parse_args[4])
    root_node = animation_parser.generate_tree_from_filename(filename)
    assert root_node
def import_sequence(filename, working_dir):
    import converter.behavior_sequence_parser as parser
    filepath = os.path.join(working_dir, filename)
    result = parser.generate_tree_from_filename(filepath)
    if result is None:
        print "Loading of %s failed!" % filename
        return None

    for layer in result.behavior_layers:
        for keyframe in layer.behavior_keyframes:
            keyframe.diagram = import_flow_diagram(keyframe.path,
                                                   working_dir)

    return result
def import_flow_diagram(filename, working_dir):
    import converter.flow_diagram_parser as parser
    filepath = os.path.join(working_dir, filename)
    result = parser.generate_tree_from_filename(filepath)
    if not result:
        print "Loading of %s failed!" % filename
        return None

    # then import dependency
    for instance in result.box_instances:
        instance.interface = import_interface(instance.path,
                                              working_dir)

    return result
def import_behavior(filename):
    import converter.behavior_parser as parser
    result = parser.generate_tree_from_filename(filename)
    if not result:
        print "Loading of %s failed!" % filename
        return None

    # then import dependency
    rootBox = result.root_box
    working_dir = os.path.dirname(filename)
    rootBox.interface = import_interface(rootBox.path,
                                         working_dir)

    return result