# Path: core/ezdxf/tools/c23.py
# PY3 = sys.version_info.major > 2
# def isstring(s):
# 
# Path: core/ezdxf/queryparser.py
# LBRK = Suppress('[')
# RBRK = Suppress(']')


import re
import operator
from .tools.c23 import isstring, Sequence
from .queryparser import EntityQueryParser

    def __len__(self):
        """Count of result entities.
        """
        return len(self.entities)

    def __getitem__(self, item):
        return self.entities.__getitem__(item)

    def extend(self, entities, query='*', unique=True):
        """Extent the query container by entities matching a additional query.
        """
        self.entities.extend(EntityQuery(entities, query))
        if unique:
            self.entities = list(unique_entities(self.entities))
        return self

    def remove(self, query='*'):
        """Remove all entities from result container matching this additional query.
        """
        handles_of_entities_to_remove = frozenset(entity.dxf.handle for entity in self.query(query))
        self.entities = [entity for entity in self.entities if entity.dxf.handle not in handles_of_entities_to_remove]

    def query(self, query='*'):
        """Returns a new result container with all entities matching this additional query.
        """
        return EntityQuery(self.entities, query)


def entity_matcher(query):

# Path: core/ezdxf/tools/c23.py
# PY3 = sys.version_info.major > 2
# def isstring(s):
# 
# Path: core/ezdxf/queryparser.py
# LBRK = Suppress('[')
# RBRK = Suppress(']')


# Path: core/ezdxf/query.py
import re
import operator
from .tools.c23 import isstring, Sequence
from .queryparser import EntityQueryParser


    def __len__(self):
        """Count of result entities.
        """
        return len(self.entities)

    def __getitem__(self, item):
        return self.entities.__getitem__(item)

    def extend(self, entities, query='*', unique=True):
        """Extent the query container by entities matching a additional query.
        """
        self.entities.extend(EntityQuery(entities, query))
        if unique:
            self.entities = list(unique_entities(self.entities))
        return self

    def remove(self, query='*'):
        """Remove all entities from result container matching this additional query.
        """
        handles_of_entities_to_remove = frozenset(entity.dxf.handle for entity in self.query(query))
        self.entities = [entity for entity in self.entities if entity.dxf.handle not in handles_of_entities_to_remove]

    def query(self, query='*'):
        """Returns a new result container with all entities matching this additional query.
        """
        return EntityQuery(self.entities, query)


def entity_matcher(query):

    query_args = EntityQueryParser.parseString(query, parseAll=True)