# Path: baroque/datastructures/bags.py
# class EventTypesBag:
#     """A type-aware collection of event types
# 
#     Args:
#         eventtypes (collection, optional): collection of :obj:`baroque.entities.eventtypes.EventType` items.
# 
#     """
#     def __init__(self, eventtypes=None):
#         self.types = set()
#         if eventtypes is not None:
#             self.add(eventtypes)
# 
#     def add(self, eventtypes):
#         """Adds a collection of eventtypes to this bag.
# 
#         Args:
#             `list` of (:obj:`baroque.entities.eventtypes.EventType`): the event types to be added
# 
#         Raises:
#             `AssertionError`: when the supplied arg is not a collection or its items are not :obj:`baroque.entities.eventtypes.EventType` instances or :obj:`baroque.entities.eventtypes.EventType` subclasses 
# 
#         """
#         assert not isinstance(eventtypes, str)
#         assert isinstance(eventtypes, collections.Iterable)
#         assert all([isinstance(et, EventType) or type(et) == type
#                     for et in eventtypes])
#         self.types.update(set([type(et) for et in eventtypes]))
# 
#     def __len__(self):
#         return len(self.types)
# 
#     def __iter__(self):
#         return (et for et in self.types)
# 
#     def __contains__(self, item):
#         return type(item) in self.types
# 
# Path: baroque/utils/timestamp.py
# TIME_FORMAT = '%Y-%m-%dT%H:%M:%SZ'
# def utc_now():
# def stringify(timestamp):


import uuid
import hashlib
import collections
from json import dumps
from baroque.datastructures.bags import EventTypesBag
from baroque.utils import timestamp as ts
        self.owner = owner
        if tags is not None:
            assert not isinstance(tags, str)
            assert isinstance(tags, collections.Iterable)
            self.tags = set(tags)
        else:
            self.tags = set()
        self.id = str(uuid.uuid4())
        self.timestamp = None
        self.touch()

    @property
    def eventtypes(self):
        """:obj:`baroque.datastructures.bags.EventTypesBag`: bag containing the
         event types of this topic"""
        return self.types

    def touch(self):
        """Sets the current time as timestamp of this topic"""
        self.timestamp = ts.utc_now()

    def json(self):
        """Dumps this object to a JSON string.

        Returns:
            str

        """
        data = dict(id=self.id, owner=self.owner, description=self.description,
                    eventtypes=[str(et) for et in self.types],

# Path: baroque/datastructures/bags.py
# class EventTypesBag:
#     """A type-aware collection of event types
# 
#     Args:
#         eventtypes (collection, optional): collection of :obj:`baroque.entities.eventtypes.EventType` items.
# 
#     """
#     def __init__(self, eventtypes=None):
#         self.types = set()
#         if eventtypes is not None:
#             self.add(eventtypes)
# 
#     def add(self, eventtypes):
#         """Adds a collection of eventtypes to this bag.
# 
#         Args:
#             `list` of (:obj:`baroque.entities.eventtypes.EventType`): the event types to be added
# 
#         Raises:
#             `AssertionError`: when the supplied arg is not a collection or its items are not :obj:`baroque.entities.eventtypes.EventType` instances or :obj:`baroque.entities.eventtypes.EventType` subclasses 
# 
#         """
#         assert not isinstance(eventtypes, str)
#         assert isinstance(eventtypes, collections.Iterable)
#         assert all([isinstance(et, EventType) or type(et) == type
#                     for et in eventtypes])
#         self.types.update(set([type(et) for et in eventtypes]))
# 
#     def __len__(self):
#         return len(self.types)
# 
#     def __iter__(self):
#         return (et for et in self.types)
# 
#     def __contains__(self, item):
#         return type(item) in self.types
# 
# Path: baroque/utils/timestamp.py
# TIME_FORMAT = '%Y-%m-%dT%H:%M:%SZ'
# def utc_now():
# def stringify(timestamp):


# Path: baroque/entities/topic.py
import uuid
import hashlib
import collections
from json import dumps
from baroque.datastructures.bags import EventTypesBag
from baroque.utils import timestamp as ts

        self.owner = owner
        if tags is not None:
            assert not isinstance(tags, str)
            assert isinstance(tags, collections.Iterable)
            self.tags = set(tags)
        else:
            self.tags = set()
        self.id = str(uuid.uuid4())
        self.timestamp = None
        self.touch()

    @property
    def eventtypes(self):
        """:obj:`baroque.datastructures.bags.EventTypesBag`: bag containing the
         event types of this topic"""
        return self.types

    def touch(self):
        """Sets the current time as timestamp of this topic"""
        self.timestamp = ts.utc_now()

    def json(self):
        """Dumps this object to a JSON string.

        Returns:
            str

        """
        data = dict(id=self.id, owner=self.owner, description=self.description,
                    eventtypes=[str(et) for et in self.types],

                    tags=list(self.tags), timestamp=ts.stringify(self.timestamp))