ieml/grammar/paths/tools.py
def _resolve_path(obj, path):
    """path is a mul of coord or a coord"""
    if obj.__class__ not in path.context.accept:
        result = set()
        for ctx in path.context.accept:
            result |= {e for u in obj[ctx] for e in _resolve_path(u, path)}

        return result

    if isinstance(obj, Text):
        if path.index is not None:
            return {obj.children[path.index]}

        return set(obj.children)

    if isinstance(obj, (Fact, Theory)):
        return _resolve_path_tree_graph(obj.tree_graph, path)

    if isinstance(obj, Topic):
        if path.kind == 'r':
            if path.index is not None:
                return {obj.root[path.index]}
            return set(obj.root)
        else:
            if path.index is not None:
                return {obj.flexing[path.index]}
            return set(obj.flexing)
def _resolve_path(obj, path):
    if obj.__class__ not in path.context.accept:
        result = set()
        for ctx in path.context.accept:
            result |= {e for u in obj[ctx] for e in _resolve_path(u, path)}

        return result

    if isinstance(obj, Text):
        if path.index is not None:
            return {obj.children[path.index]}

        return set(obj.children)

    if isinstance(obj, (Fact, Theory)):
        return _resolve_path_tree_graph(obj.tree_graph, path)

    if isinstance(obj, Topic):
        if path.kind == 'r':
            if path.index is not None:
                return {obj.root[path.index]}
            return set(obj.root)
        else:
            if path.index is not None:
                return {obj.flexing[path.index]}
            return set(obj.flexing)
def _resolve_path ( obj , path ) : if obj . __class__ not in path . context . accept : result = set ( ) for ctx in path . context . accept : result |= { e for u in obj [ ctx ] for e in _resolve_path ( u , path ) } return result if isinstance ( obj , Text ) : if path . index is not None : return { obj . children [ path . index ] } return set ( obj . children ) if isinstance ( obj , ( Fact , Theory ) ) : return _resolve_path_tree_graph ( obj . tree_graph , path ) if isinstance ( obj , Topic ) : if path . kind == 'r' : if path . index is not None : return { obj . root [ path . index ] } return set ( obj . root ) else : if path . index is not None : return { obj . flexing [ path . index ] } return set ( obj . flexing )
path is a mul of coord or a coord
path is a mul of coord or a coord