# Path: xtuml/meta.py
# def navigate_one(self, instance):
#     '''
#     Navigate from *instance* across the link.
#     '''
#     return next(iter(self.navigate(instance)), None)
# 
# Path: xtuml/meta.py
# def navigate_any(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 an instance or None.
#     '''
#     return NavOneChain(instance_or_set)
# 
# 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: xtuml/tools.py
# class Walker(object):
#     '''
#     A walker may be used to walk a tree.
#     '''
#     def __init__(self):
#         #: A list of *visitors* to notify when visiting nodes.
#         self.visitors = list()
#         
#     def accept(self, node, **kwargs):
#         '''
#         Invoke the visitors before and after decending down the tree. 
#         The walker will also try to invoke a method matching the pattern 
#         *accept_<type name>*, where <type name> is the name of the accepted
#         *node*.
#         '''
#         if node is None:
#             return
#         
#         for v in self.visitors:
#             v.enter(node)
#         
#         name = 'accept_' + node.__class__.__name__
#         fn = getattr(self, name, self.default_accept)
#         r = fn(node, **kwargs)
#         
#         for v in self.visitors:
#             v.leave(node)
#         
#         return r
#     
#     def default_accept(self, node, **kwargs):
#         '''
#         The default accept behaviour is to decend into the iterable member
#         *node.children* (if available).
#         '''
#         if not hasattr(node, 'children'):
#             return
#         
#         for child in node.children:
#             self.accept(child, **kwargs)


import logging
from xtuml import navigate_one as one
from xtuml import navigate_any as any
from xtuml import navigate_many as many
from xtuml import navigate_subtype as subtype
from xtuml.tools import Walker
# Copyright (C) 2017 John Törnblom
#
# This file is part of pyxtuml.
#
# pyxtuml is free software: you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation, either
# version 3 of the License, or (at your option) any later version.
#
# pyxtuml is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with pyxtuml. If not, see <http://www.gnu.org/licenses/>.





logger = logging.getLogger(__name__)


class ActionTextGenWalker(Walker):
    '''
    Walk the bridgepoint metamodel and translate action code
    to its textual representation.
    '''
    def __init__(self, level=-1):

# Path: xtuml/meta.py
# def navigate_one(self, instance):
#     '''
#     Navigate from *instance* across the link.
#     '''
#     return next(iter(self.navigate(instance)), None)
# 
# Path: xtuml/meta.py
# def navigate_any(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 an instance or None.
#     '''
#     return NavOneChain(instance_or_set)
# 
# 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: xtuml/tools.py
# class Walker(object):
#     '''
#     A walker may be used to walk a tree.
#     '''
#     def __init__(self):
#         #: A list of *visitors* to notify when visiting nodes.
#         self.visitors = list()
#         
#     def accept(self, node, **kwargs):
#         '''
#         Invoke the visitors before and after decending down the tree. 
#         The walker will also try to invoke a method matching the pattern 
#         *accept_<type name>*, where <type name> is the name of the accepted
#         *node*.
#         '''
#         if node is None:
#             return
#         
#         for v in self.visitors:
#             v.enter(node)
#         
#         name = 'accept_' + node.__class__.__name__
#         fn = getattr(self, name, self.default_accept)
#         r = fn(node, **kwargs)
#         
#         for v in self.visitors:
#             v.leave(node)
#         
#         return r
#     
#     def default_accept(self, node, **kwargs):
#         '''
#         The default accept behaviour is to decend into the iterable member
#         *node.children* (if available).
#         '''
#         if not hasattr(node, 'children'):
#             return
#         
#         for child in node.children:
#             self.accept(child, **kwargs)


# Path: bridgepoint/sourcegen.py
import logging
from xtuml import navigate_one as one
from xtuml import navigate_any as any
from xtuml import navigate_many as many
from xtuml import navigate_subtype as subtype
from xtuml.tools import Walker

# Copyright (C) 2017 John Törnblom
#
# This file is part of pyxtuml.
#
# pyxtuml is free software: you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation, either
# version 3 of the License, or (at your option) any later version.
#
# pyxtuml is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with pyxtuml. If not, see <http://www.gnu.org/licenses/>.





logger = logging.getLogger(__name__)


class ActionTextGenWalker(Walker):
    '''
    Walk the bridgepoint metamodel and translate action code
    to its textual representation.
    '''
    def __init__(self, level=-1):

        Walker.__init__(self)