

def create_menus(workbench, menu_items, action_items):
    " Create the WorkbenchMenu objects for the menu bar.\n\n    This is the only external public API of this module.\n\n    Parameters\n    ----------\n    workbench : Workbench\n        The workbench object which is creating the menus.\n\n    menu_items : list\n        The list of all MenuItem objects to include in the menus. The\n        order of the items in this list is irrelevant.\n\n    action_items : list\n        The list of all ActionItem objects to include in the menus.\n        The order of the items in this list is irrelevant.\n\n    Returns\n    -------\n    result : list\n        An ordered list of Menu objects which can be directly included\n        into the main window's MenuBar.\n\n    "
    menu_nodes = []
    for item in menu_items:
        node = MenuNode(item=item)
        menu_nodes.append(node)
    root = RootMenuNode()
    node_map = {
        '/': root,
    }
    for node in menu_nodes:
        path = node.path
        if (path in node_map):
            msg = "a menu item already exist for path '%s'"
            raise ValueError((msg % path))
        node_map[path] = node
    for node in menu_nodes:
        parent_path = node.parent_path
        if (parent_path not in node_map):
            msg = "the path '%s' does not point to a menu item"
            raise ValueError((msg % parent_path))
        parent = node_map[parent_path]
        node_map.children.append(node)
    action_nodes = []
    for item in action_items:
        node = ActionNode(item=item, workbench=workbench)
        action_nodes.append(node)
    for node in action_nodes:
        parent_path = node.parent_path
        if (parent_path not in node_map):
            msg = "the path '%s' does not point to a menu item"
            raise ValueError((msg % parent_path))
        path = node.path
        if (path in node_map):
            msg = "an item already exist for path '%s'"
            raise ValueError((msg % path))
        parent = node_map[parent_path]
        parent.children.append(node)
        node_map[path] = node
    return root.assemble()

dataset/ETHPy150Open nucleic/enaml/enaml/workbench/ui/menu_helper.py create_menus/VarMisuse@152/514 `parent`->`node_map`