# Path: alephnull/protocol.py
# DATASOURCE_TYPE = Enum(
#     'AS_TRADED_EQUITY',
#     'MERGER',
#     'SPLIT',
#     'DIVIDEND',
#     'TRADE',
#     'TRANSACTION',
#     'ORDER',
#     'EMPTY',
#     'DONE',
#     'CUSTOM',
#     'BENCHMARK',
#     'COMMISSION'
# )
# 
# Path: alephnull/protocol.py
# class Event(object):
# 
#     def __init__(self, initial_values=None):
#         if initial_values:
#             self.__dict__ = initial_values
# 
#     def __getitem__(self, name):
#         return getattr(self, name)
# 
#     def __setitem__(self, name, value):
#         setattr(self, name, value)
# 
#     def __delitem__(self, name):
#         delattr(self, name)
# 
#     def keys(self):
#         return self.__dict__.keys()
# 
#     def __eq__(self, other):
#         return self.__dict__ == other.__dict__
# 
#     def __contains__(self, name):
#         return name in self.__dict__
# 
#     def __repr__(self):
#         return "Event({0})".format(self.__dict__)


from abc import (
    ABCMeta,
    abstractproperty
)
from alephnull.protocol import DATASOURCE_TYPE
from alephnull.protocol import Event
        """
        An iterator that yields the raw datasource,
        in chronological order of data, one event at a time.
        """
        NotImplemented

    @abstractproperty
    def instance_hash(self):
        """
        A hash that represents the unique args to the source.
        """
        pass

    def get_hash(self):
        return self.__class__.__name__ + "-" + self.instance_hash

    def apply_mapping(self, raw_row):
        """
        Override this to hand craft conversion of row.
        """
        row = {target: mapping_func(raw_row[source_key])
               for target, (mapping_func, source_key)
               in self.mapping.items()}
        row.update({'source_id': self.get_hash()})
        row.update({'type': self.event_type})
        return row

    @property
    def mapped_data(self):
        for row in self.raw_data:

# Path: alephnull/protocol.py
# DATASOURCE_TYPE = Enum(
#     'AS_TRADED_EQUITY',
#     'MERGER',
#     'SPLIT',
#     'DIVIDEND',
#     'TRADE',
#     'TRANSACTION',
#     'ORDER',
#     'EMPTY',
#     'DONE',
#     'CUSTOM',
#     'BENCHMARK',
#     'COMMISSION'
# )
# 
# Path: alephnull/protocol.py
# class Event(object):
# 
#     def __init__(self, initial_values=None):
#         if initial_values:
#             self.__dict__ = initial_values
# 
#     def __getitem__(self, name):
#         return getattr(self, name)
# 
#     def __setitem__(self, name, value):
#         setattr(self, name, value)
# 
#     def __delitem__(self, name):
#         delattr(self, name)
# 
#     def keys(self):
#         return self.__dict__.keys()
# 
#     def __eq__(self, other):
#         return self.__dict__ == other.__dict__
# 
#     def __contains__(self, name):
#         return name in self.__dict__
# 
#     def __repr__(self):
#         return "Event({0})".format(self.__dict__)


# Path: alephnull/sources/data_source.py
from abc import (
    ABCMeta,
    abstractproperty
)
from alephnull.protocol import DATASOURCE_TYPE
from alephnull.protocol import Event

        """
        An iterator that yields the raw datasource,
        in chronological order of data, one event at a time.
        """
        NotImplemented

    @abstractproperty
    def instance_hash(self):
        """
        A hash that represents the unique args to the source.
        """
        pass

    def get_hash(self):
        return self.__class__.__name__ + "-" + self.instance_hash

    def apply_mapping(self, raw_row):
        """
        Override this to hand craft conversion of row.
        """
        row = {target: mapping_func(raw_row[source_key])
               for target, (mapping_func, source_key)
               in self.mapping.items()}
        row.update({'source_id': self.get_hash()})
        row.update({'type': self.event_type})
        return row

    @property
    def mapped_data(self):
        for row in self.raw_data:

            yield Event(self.apply_mapping(row))