# 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__)
# 
# DATASOURCE_TYPE = Enum(
#     'AS_TRADED_EQUITY',
#     'MERGER',
#     'SPLIT',
#     'DIVIDEND',
#     'TRADE',
#     'TRANSACTION',
#     'ORDER',
#     'EMPTY',
#     'DONE',
#     'CUSTOM',
#     'BENCHMARK',
#     'COMMISSION'
# )
# 
# Path: alephnull/gens/utils.py
# def hash_args(*args, **kwargs):
#     """Define a unique string for any set of representable args."""
#     arg_string = '_'.join([str(arg) for arg in args])
#     kwarg_string = '_'.join([str(key) + '=' + str(value)
#                              for key, value in kwargs.iteritems()])
#     combined = ':'.join([arg_string, kwarg_string])
# 
#     hasher = md5()
#     hasher.update(combined)
#     return hasher.hexdigest()


import pytz
import numpy as np
from itertools import cycle, ifilter, izip
from datetime import datetime, timedelta
from alephnull.protocol import (
    Event,
    DATASOURCE_TYPE
)
from alephnull.gens.utils import hash_args
from alephnull.utils.tradingcalendar import trading_days

        if self.event_list is not None:
            # If event_list is provided, extract parameters from there
            # This isn't really clean and ultimately I think this
            # class should serve a single purpose (either take an
            # event_list or autocreate events).
            self.count = kwargs.get('count', len(self.event_list))
            self.sids = kwargs.get(
                'sids',
                np.unique([event.sid for event in self.event_list]).tolist())
            self.start = kwargs.get('start', self.event_list[0].dt)
            self.end = kwargs.get('start', self.event_list[-1].dt)
            self.delta = kwargs.get(
                'delta',
                self.event_list[1].dt - self.event_list[0].dt)
            self.concurrent = kwargs.get('concurrent', False)

        else:
            # Unpack config dictionary with default values.
            self.count = kwargs.get('count', 500)
            self.sids = kwargs.get('sids', [1, 2])
            self.start = kwargs.get(
                'start',
                datetime(2008, 6, 6, 15, tzinfo=pytz.utc))
            self.delta = kwargs.get(
                'delta',
                timedelta(minutes=1))
            self.concurrent = kwargs.get('concurrent', False)

        # Hash_value for downstream sorting.

# 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__)
# 
# DATASOURCE_TYPE = Enum(
#     'AS_TRADED_EQUITY',
#     'MERGER',
#     'SPLIT',
#     'DIVIDEND',
#     'TRADE',
#     'TRANSACTION',
#     'ORDER',
#     'EMPTY',
#     'DONE',
#     'CUSTOM',
#     'BENCHMARK',
#     'COMMISSION'
# )
# 
# Path: alephnull/gens/utils.py
# def hash_args(*args, **kwargs):
#     """Define a unique string for any set of representable args."""
#     arg_string = '_'.join([str(arg) for arg in args])
#     kwarg_string = '_'.join([str(key) + '=' + str(value)
#                              for key, value in kwargs.iteritems()])
#     combined = ':'.join([arg_string, kwarg_string])
# 
#     hasher = md5()
#     hasher.update(combined)
#     return hasher.hexdigest()


# Path: alephnull/sources/test_source.py
import pytz
import numpy as np
from itertools import cycle, ifilter, izip
from datetime import datetime, timedelta
from alephnull.protocol import (
    Event,
    DATASOURCE_TYPE
)
from alephnull.gens.utils import hash_args
from alephnull.utils.tradingcalendar import trading_days


        if self.event_list is not None:
            # If event_list is provided, extract parameters from there
            # This isn't really clean and ultimately I think this
            # class should serve a single purpose (either take an
            # event_list or autocreate events).
            self.count = kwargs.get('count', len(self.event_list))
            self.sids = kwargs.get(
                'sids',
                np.unique([event.sid for event in self.event_list]).tolist())
            self.start = kwargs.get('start', self.event_list[0].dt)
            self.end = kwargs.get('start', self.event_list[-1].dt)
            self.delta = kwargs.get(
                'delta',
                self.event_list[1].dt - self.event_list[0].dt)
            self.concurrent = kwargs.get('concurrent', False)

        else:
            # Unpack config dictionary with default values.
            self.count = kwargs.get('count', 500)
            self.sids = kwargs.get('sids', [1, 2])
            self.start = kwargs.get(
                'start',
                datetime(2008, 6, 6, 15, tzinfo=pytz.utc))
            self.delta = kwargs.get(
                'delta',
                timedelta(minutes=1))
            self.concurrent = kwargs.get('concurrent', False)

        # Hash_value for downstream sorting.

        self.arg_string = hash_args(*args, **kwargs)