# Path: pypet/pypetlogging.py
# class HasLogger(HasSlots):
#     """Abstract super class that automatically adds a logger to a class.
# 
#     To add a logger to a sub-class of yours simply call ``myobj._set_logger(name)``.
#     If ``name=None`` the logger is chosen as follows:
# 
#         ``self._logger = logging.getLogger(self.__class.__.__module__ + '.' + self.__class__.__name__)``
# 
#     The logger can be accessed via ``myobj._logger``.
# 
#     """
# 
#     __slots__ = ('_logger',)
# 
#     def __getstate__(self):
#         """Called for pickling.
# 
#         Removes the logger to allow pickling and returns a copy of `__dict__`.
# 
#         """
#         state_dict = super(HasLogger, self).__getstate__()
#         if '_logger' in state_dict:
#             # Pickling does not work with loggers objects,
#             # so we just keep the logger's name:
#             state_dict['_logger'] = self._logger.name
#         return state_dict
# 
#     def __setstate__(self, statedict):
#         """Called after loading a pickle dump.
# 
#         Restores `__dict__` from `statedict` and adds a new logger.
# 
#         """
#         super(HasLogger, self).__setstate__(statedict)
#         if '_logger' in statedict:
#             # If we re-instantiate the component the
#             # logger attribute only contains a name,
#             # so we also need to re-create the logger:
#             self._set_logger(statedict['_logger'])
# 
#     def _set_logger(self, name=None):
#         """Adds a logger with a given `name`.
# 
#         If no name is given, name is constructed as
#         `type(self).__name__`.
# 
#         """
#         if name is None:
#             cls = self.__class__
#             name = '%s.%s' % (cls.__module__, cls.__name__)
#         self._logger = logging.getLogger(name)
# 
# Path: pypet/slots.py
# class HasSlots(object, metaclass=MetaSlotMachine):
#     """Top-class that allows mixing of classes with and without slots.
# 
#     Takes care that instances can still be pickled with the lowest
#     protocol. Moreover, provides a generic `__dir__` method that
#     lists all slots.
# 
#     """
#     __slots__ = ('__weakref__',)
# 
#     def __getstate__(self):
#         if hasattr(self, '__dict__'):
#             # We don't require that all sub-classes also define slots,
#             # so they may provide a dictionary
#             statedict = self.__dict__.copy()
#         else:
#             statedict = {}
#         # Get all slots of potential parent classes
#         for slot in self.__all_slots__:
#             try:
#                 value = getattr(self, slot)
#                 statedict[slot] = value
#             except AttributeError:
#                 pass
#         # Pop slots that cannot or should not be pickled
#         statedict.pop('__dict__', None)
#         statedict.pop('__weakref__', None)
#         return statedict
# 
#     def __setstate__(self, state):
#         """Recalls state for items with slots"""
#         for key in state:
#             setattr(self, key, state[key])
# 
#     def __dir__(self):
#         """Includes all slots in the `dir` method"""
#         result = set()
#         result.update(dir(self.__class__), self.__all_slots__)
#         if hasattr(self, '__dict__'):
#             result.update(self.__dict__.keys())
#         return list(result)


from pypet.pypetlogging import HasLogger
from pypet.slots import HasSlots
            valstr = self._translate_key(idx)
            self.f_set_single(valstr, arg)

        for key, arg in kwargs.items():
            self.f_set_single(key, arg)

    def f_remove(self, key):
        """Removes `key` from annotations"""
        key = self._translate_key(key)
        try:
            del self._dict[key]
        except KeyError:
            raise AttributeError('Your annotations do not contain %s' % key)


    def f_set_single(self, name, data):
        """ Sets a single annotation. """
        self._dict[name] = data

    def f_ann_to_str(self):
        """Returns all annotations lexicographically sorted as a concatenated string."""
        resstr = ''
        for key in sorted(self._dict.keys()):
            resstr += '%s=%s; ' % (key, str(self._dict[key]))
        return resstr[:-2]

    def __str__(self):
        return self.f_ann_to_str()



# Path: pypet/pypetlogging.py
# class HasLogger(HasSlots):
#     """Abstract super class that automatically adds a logger to a class.
# 
#     To add a logger to a sub-class of yours simply call ``myobj._set_logger(name)``.
#     If ``name=None`` the logger is chosen as follows:
# 
#         ``self._logger = logging.getLogger(self.__class.__.__module__ + '.' + self.__class__.__name__)``
# 
#     The logger can be accessed via ``myobj._logger``.
# 
#     """
# 
#     __slots__ = ('_logger',)
# 
#     def __getstate__(self):
#         """Called for pickling.
# 
#         Removes the logger to allow pickling and returns a copy of `__dict__`.
# 
#         """
#         state_dict = super(HasLogger, self).__getstate__()
#         if '_logger' in state_dict:
#             # Pickling does not work with loggers objects,
#             # so we just keep the logger's name:
#             state_dict['_logger'] = self._logger.name
#         return state_dict
# 
#     def __setstate__(self, statedict):
#         """Called after loading a pickle dump.
# 
#         Restores `__dict__` from `statedict` and adds a new logger.
# 
#         """
#         super(HasLogger, self).__setstate__(statedict)
#         if '_logger' in statedict:
#             # If we re-instantiate the component the
#             # logger attribute only contains a name,
#             # so we also need to re-create the logger:
#             self._set_logger(statedict['_logger'])
# 
#     def _set_logger(self, name=None):
#         """Adds a logger with a given `name`.
# 
#         If no name is given, name is constructed as
#         `type(self).__name__`.
# 
#         """
#         if name is None:
#             cls = self.__class__
#             name = '%s.%s' % (cls.__module__, cls.__name__)
#         self._logger = logging.getLogger(name)
# 
# Path: pypet/slots.py
# class HasSlots(object, metaclass=MetaSlotMachine):
#     """Top-class that allows mixing of classes with and without slots.
# 
#     Takes care that instances can still be pickled with the lowest
#     protocol. Moreover, provides a generic `__dir__` method that
#     lists all slots.
# 
#     """
#     __slots__ = ('__weakref__',)
# 
#     def __getstate__(self):
#         if hasattr(self, '__dict__'):
#             # We don't require that all sub-classes also define slots,
#             # so they may provide a dictionary
#             statedict = self.__dict__.copy()
#         else:
#             statedict = {}
#         # Get all slots of potential parent classes
#         for slot in self.__all_slots__:
#             try:
#                 value = getattr(self, slot)
#                 statedict[slot] = value
#             except AttributeError:
#                 pass
#         # Pop slots that cannot or should not be pickled
#         statedict.pop('__dict__', None)
#         statedict.pop('__weakref__', None)
#         return statedict
# 
#     def __setstate__(self, state):
#         """Recalls state for items with slots"""
#         for key in state:
#             setattr(self, key, state[key])
# 
#     def __dir__(self):
#         """Includes all slots in the `dir` method"""
#         result = set()
#         result.update(dir(self.__class__), self.__all_slots__)
#         if hasattr(self, '__dict__'):
#             result.update(self.__dict__.keys())
#         return list(result)


# Path: pypet/annotations.py
from pypet.pypetlogging import HasLogger
from pypet.slots import HasSlots

            valstr = self._translate_key(idx)
            self.f_set_single(valstr, arg)

        for key, arg in kwargs.items():
            self.f_set_single(key, arg)

    def f_remove(self, key):
        """Removes `key` from annotations"""
        key = self._translate_key(key)
        try:
            del self._dict[key]
        except KeyError:
            raise AttributeError('Your annotations do not contain %s' % key)


    def f_set_single(self, name, data):
        """ Sets a single annotation. """
        self._dict[name] = data

    def f_ann_to_str(self):
        """Returns all annotations lexicographically sorted as a concatenated string."""
        resstr = ''
        for key in sorted(self._dict.keys()):
            resstr += '%s=%s; ' % (key, str(self._dict[key]))
        return resstr[:-2]

    def __str__(self):
        return self.f_ann_to_str()



class WithAnnotations(HasLogger):