# Path: xtuml/meta.py
# def navigate_many(instance_or_set):
#     '''
#     Initialize a navigation from an instance, or a set of instances, to 
#     associated instances across a one-to-many or many-to-many association.
#     
#     The resulting query will return a set of instances.
#     '''
#     return NavChain(instance_or_set)
# 
# Path: xtuml/meta.py
# def navigate_subtype(supertype, rel_id):
#     '''
#     Perform a navigation from *supertype* to its subtype across *rel_id*. The
#     navigated association must be modeled as a subtype-supertype association.
#     
#     The return value will an instance or None.
#     '''
#     if not supertype:
#         return
#     
#     if isinstance(rel_id, int):
#         rel_id = 'R%d' % rel_id
# 
#     metaclass = get_metaclass(supertype)
#     for kind, rel_id_candidate, _ in metaclass.links:
#         if rel_id != rel_id_candidate:
#             continue
#         
#         subtype = navigate_one(supertype).nav(kind, rel_id)()
#         if subtype:
#             return subtype
# 
# Path: bridgepoint/ooaofooa.py
# class OoaOfOoaException(Exception):
# class Domain(xtuml.MetaModel):
# class ModelLoader(xtuml.ModelLoader):
#     def __init__(self, id_generator=None):
#     def add_symbol(self, name, handle):
#     def find_symbol(self, name):
# def is_contained_in(pe_pe, root):
# def is_global(pe_pe):
# def get_defining_component(pe_pe):
# def get_attribute_type(o_attr):
# def _get_data_type_name(s_dt):
# def _get_related_attributes(r_rgo, r_rto):
# def mk_enum(s_edt):
# def mk_bridge(metamodel, s_brg):
# def mk_external_entity(metamodel, s_ee):
# def mk_function(metamodel, s_sync):
# def mk_constant(cnst_syc):
# def mk_operation(metaclass, o_tfr):
# def mk_derived_attribute(metaclass, o_dbattr):
# def mk_class(m, o_obj, derived_attributes=False):
# def mk_simple_association(m, r_simp):
# def mk_linked_association(m, r_assoc):
#     def _mk_assoc(side1, side2):
# def mk_subsuper_association(m, r_subsup):
# def mk_derived_association(m, r_comp):
# def mk_association(m, r_rel):
# def mk_component(bp_model, c_c=None, derived_attributes=False):
#     def __init__(self, load_globals=True):
#     def filename_input(self, path_or_filename):
#     def build_component(self, name=None, derived_attributes=False):
# def _mk_loader(resource, load_globals):
# def load_metamodel(resource=None, load_globals=True):
# def load_component(resource, name=None, load_globals=True):
# def delete_globals(m, disconnect=False):
#     EE = collections.namedtuple(s_ee.Key_Lett, names)


import sys
import xtuml
from xtuml import navigate_many as many
from xtuml import navigate_subtype as subtype
from bridgepoint import ooaofooa

class MyWalker(xtuml.Walker):
    '''
    Walk the ooaofooa packageable element tree-like structure
    '''
    
    def accept_S_SYS(self, inst):
        '''
        A System Model contains top-level packages
        '''
        for child in many(inst).EP_PKG[1401]():
            self.accept(child)
    
    def accept_PE_PE(self, inst):
        '''
        Packeable Element is the supertype of something packageable
        '''
        self.accept(subtype(inst, 8001))

    def accept_C_C(self, inst):
        '''
        A Component contains packageable elements
        '''
        for child in many(inst).PE_PE[8003]():
            self.accept(child)
            
    def accept_EP_PKG(self, inst):
        '''
        A Package contains packageable elements
        '''

# Path: xtuml/meta.py
# def navigate_many(instance_or_set):
#     '''
#     Initialize a navigation from an instance, or a set of instances, to 
#     associated instances across a one-to-many or many-to-many association.
#     
#     The resulting query will return a set of instances.
#     '''
#     return NavChain(instance_or_set)
# 
# Path: xtuml/meta.py
# def navigate_subtype(supertype, rel_id):
#     '''
#     Perform a navigation from *supertype* to its subtype across *rel_id*. The
#     navigated association must be modeled as a subtype-supertype association.
#     
#     The return value will an instance or None.
#     '''
#     if not supertype:
#         return
#     
#     if isinstance(rel_id, int):
#         rel_id = 'R%d' % rel_id
# 
#     metaclass = get_metaclass(supertype)
#     for kind, rel_id_candidate, _ in metaclass.links:
#         if rel_id != rel_id_candidate:
#             continue
#         
#         subtype = navigate_one(supertype).nav(kind, rel_id)()
#         if subtype:
#             return subtype
# 
# Path: bridgepoint/ooaofooa.py
# class OoaOfOoaException(Exception):
# class Domain(xtuml.MetaModel):
# class ModelLoader(xtuml.ModelLoader):
#     def __init__(self, id_generator=None):
#     def add_symbol(self, name, handle):
#     def find_symbol(self, name):
# def is_contained_in(pe_pe, root):
# def is_global(pe_pe):
# def get_defining_component(pe_pe):
# def get_attribute_type(o_attr):
# def _get_data_type_name(s_dt):
# def _get_related_attributes(r_rgo, r_rto):
# def mk_enum(s_edt):
# def mk_bridge(metamodel, s_brg):
# def mk_external_entity(metamodel, s_ee):
# def mk_function(metamodel, s_sync):
# def mk_constant(cnst_syc):
# def mk_operation(metaclass, o_tfr):
# def mk_derived_attribute(metaclass, o_dbattr):
# def mk_class(m, o_obj, derived_attributes=False):
# def mk_simple_association(m, r_simp):
# def mk_linked_association(m, r_assoc):
#     def _mk_assoc(side1, side2):
# def mk_subsuper_association(m, r_subsup):
# def mk_derived_association(m, r_comp):
# def mk_association(m, r_rel):
# def mk_component(bp_model, c_c=None, derived_attributes=False):
#     def __init__(self, load_globals=True):
#     def filename_input(self, path_or_filename):
#     def build_component(self, name=None, derived_attributes=False):
# def _mk_loader(resource, load_globals):
# def load_metamodel(resource=None, load_globals=True):
# def load_component(resource, name=None, load_globals=True):
# def delete_globals(m, disconnect=False):
#     EE = collections.namedtuple(s_ee.Key_Lett, names)


# Path: examples/print_packageable_elements.py
import sys
import xtuml
from xtuml import navigate_many as many
from xtuml import navigate_subtype as subtype
from bridgepoint import ooaofooa


class MyWalker(xtuml.Walker):
    '''
    Walk the ooaofooa packageable element tree-like structure
    '''
    
    def accept_S_SYS(self, inst):
        '''
        A System Model contains top-level packages
        '''
        for child in many(inst).EP_PKG[1401]():
            self.accept(child)
    
    def accept_PE_PE(self, inst):
        '''
        Packeable Element is the supertype of something packageable
        '''
        self.accept(subtype(inst, 8001))

    def accept_C_C(self, inst):
        '''
        A Component contains packageable elements
        '''
        for child in many(inst).PE_PE[8003]():
            self.accept(child)
            
    def accept_EP_PKG(self, inst):
        '''
        A Package contains packageable elements
        '''

        for child in many(inst).PE_PE[8000]():