# Path: pyhaystack/client/entity/model.py
# class TaggingModel(object):
#     """
#     A base class for representing tagging models.  The tagging model
#     is responsible for considering the tags present on a new entity then
#     instantiating an appropriate data type based on those tags seen.
#     """
# 
#     def __init__(self, session):
#         """
#         Initialise a new tagging model.
#         """
#         # Session instance
#         self._session = weakref.ref(session)
# 
#         # Existing types, identified by name.
#         self._types = {}
# 
#     def create_entity(self, entity_id, tags):
#         """
#         Create an Entity instance based on the tags present.
#         """
#         session = self._session()
#         (class_name, types) = self._identify_types(tags)
# 
#         # Does the session instance support CRUD?  Add the appropriate base
#         # class to the end of the types list.
#         if hasattr(session, "delete"):
#             types += [DeletableEntity]
#         else:
#             types += [Entity]
# 
#         try:
#             class_type = self._types[class_name]
#         except KeyError:
#             class_type = type(class_name, tuple(types), {})
#             self._types[class_name] = class_type
# 
#         entity = class_type(session, entity_id)
#         entity._update_tags(tags)
#         return entity
# 
#     def _identify_types(self, tags):
#         """
#         Inspect the tags on the to-be-created object and return a tuple
#         consisting of:
#         - the suggested class name
#         - a list of class instances that represent the add-on types for
#           that object.
#         """
#         raise NotImplementedError("To be implemented in %s" % self.__class__.__name__)
# 
# Path: pyhaystack/client/entity/mixins/tz.py
# @property
# def tz(self):
#     """
#     Return the timezone information (datetime.tzinfo) for this entity.
#     """
#     return pytz.timezone(self.iana_tz)
# 
# Path: pyhaystack/client/entity/mixins/site.py
# class SiteMixin(object):
# class SiteRefMixin(object):
#     def find_entity(self, filter_expr=None, single=False, limit=None, callback=None):
#     def __getitem__(self, key):
#     def __iter__(self):
#     def equipments(self):
#     def refresh(self):
#     def _add_equip(self):
#     def get_site(self, callback=None):
# 
# Path: pyhaystack/client/entity/mixins/equip.py
# class EquipMixin(object):
# class EquipRefMixin(object):
#     def find_entity(self, filter_expr=None, limit=None, single=False, callback=None):
#     def __getitem__(self, key):
#     def __iter__(self):
#     def points(self):
#     def refresh(self):
#     def _add_points(self):
#     def get_equip(self, callback=None):
# 
# Path: pyhaystack/client/entity/mixins/point.py
# class HisMixin(object):
# class PointMixin(object):
#     def his(self, rng="today", tz=None, series_format=None, callback=None):
#     def his_read_series(self, rng, tz=None, series_format=None, callback=None):
#     def his_write_series(self, series, tz=None, callback=None):
#     def value(self):


import hszinc
from ..model import TaggingModel
from ..mixins import tz, site, equip, point
"""



class HaystackTaggingModel(TaggingModel):
    """
    An implementation of the Project Haystack tagging model.
    """

    def _identify_types(self, tags):
        """
        Inspect the tags on the to-be-created object and return a tuple
        consisting of:
        - the suggested class name
        - a list of class instances that represent the add-on types for
          that object.
        """
        types = []
        names = []
        if "tz" in tags:
            # We have a timezone
            types.append(tz.TzMixin)
            names.append("Tz")

        if "site" in tags:
            # This is a site
            types.append(site.SiteMixin)
            names.append("Site")
        elif "siteRef" in tags:
            # This links to a site

# Path: pyhaystack/client/entity/model.py
# class TaggingModel(object):
#     """
#     A base class for representing tagging models.  The tagging model
#     is responsible for considering the tags present on a new entity then
#     instantiating an appropriate data type based on those tags seen.
#     """
# 
#     def __init__(self, session):
#         """
#         Initialise a new tagging model.
#         """
#         # Session instance
#         self._session = weakref.ref(session)
# 
#         # Existing types, identified by name.
#         self._types = {}
# 
#     def create_entity(self, entity_id, tags):
#         """
#         Create an Entity instance based on the tags present.
#         """
#         session = self._session()
#         (class_name, types) = self._identify_types(tags)
# 
#         # Does the session instance support CRUD?  Add the appropriate base
#         # class to the end of the types list.
#         if hasattr(session, "delete"):
#             types += [DeletableEntity]
#         else:
#             types += [Entity]
# 
#         try:
#             class_type = self._types[class_name]
#         except KeyError:
#             class_type = type(class_name, tuple(types), {})
#             self._types[class_name] = class_type
# 
#         entity = class_type(session, entity_id)
#         entity._update_tags(tags)
#         return entity
# 
#     def _identify_types(self, tags):
#         """
#         Inspect the tags on the to-be-created object and return a tuple
#         consisting of:
#         - the suggested class name
#         - a list of class instances that represent the add-on types for
#           that object.
#         """
#         raise NotImplementedError("To be implemented in %s" % self.__class__.__name__)
# 
# Path: pyhaystack/client/entity/mixins/tz.py
# @property
# def tz(self):
#     """
#     Return the timezone information (datetime.tzinfo) for this entity.
#     """
#     return pytz.timezone(self.iana_tz)
# 
# Path: pyhaystack/client/entity/mixins/site.py
# class SiteMixin(object):
# class SiteRefMixin(object):
#     def find_entity(self, filter_expr=None, single=False, limit=None, callback=None):
#     def __getitem__(self, key):
#     def __iter__(self):
#     def equipments(self):
#     def refresh(self):
#     def _add_equip(self):
#     def get_site(self, callback=None):
# 
# Path: pyhaystack/client/entity/mixins/equip.py
# class EquipMixin(object):
# class EquipRefMixin(object):
#     def find_entity(self, filter_expr=None, limit=None, single=False, callback=None):
#     def __getitem__(self, key):
#     def __iter__(self):
#     def points(self):
#     def refresh(self):
#     def _add_points(self):
#     def get_equip(self, callback=None):
# 
# Path: pyhaystack/client/entity/mixins/point.py
# class HisMixin(object):
# class PointMixin(object):
#     def his(self, rng="today", tz=None, series_format=None, callback=None):
#     def his_read_series(self, rng, tz=None, series_format=None, callback=None):
#     def his_write_series(self, series, tz=None, callback=None):
#     def value(self):


# Path: pyhaystack/client/entity/models/haystack.py
import hszinc
from ..model import TaggingModel
from ..mixins import tz, site, equip, point

"""



class HaystackTaggingModel(TaggingModel):
    """
    An implementation of the Project Haystack tagging model.
    """

    def _identify_types(self, tags):
        """
        Inspect the tags on the to-be-created object and return a tuple
        consisting of:
        - the suggested class name
        - a list of class instances that represent the add-on types for
          that object.
        """
        types = []
        names = []
        if "tz" in tags:
            # We have a timezone
            types.append(tz.TzMixin)
            names.append("Tz")

        if "site" in tags:
            # This is a site
            types.append(site.SiteMixin)
            names.append("Site")
        elif "siteRef" in tags:
            # This links to a site

            types.append(site.SiteRefMixin)