From d1784b26c37daab09ef1e3cb5d2800cde5111394 Mon Sep 17 00:00:00 2001 From: Eddie Hebert Date: Tue, 1 Jan 2013 22:59:25 -0500 Subject: [PATCH] Adds an init to protocol.Event to enable setting of initial values. So that an Event can use an initial dict to set all values, instead of needing to set initial values one by one. i.e. enables: ``` foo = Event({'bar': 1, 'baz': 2}) ``` in favor of: ``` foo = Event() foo.bar = 1 foo.baz = 2 ``` --- zipline/protocol.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/zipline/protocol.py b/zipline/protocol.py index 184988ec..52c7ecc2 100644 --- a/zipline/protocol.py +++ b/zipline/protocol.py @@ -31,6 +31,10 @@ DATASOURCE_TYPE = Enum( class Event(object): + def __init__(self, initial_values=None): + if initial_values: + self.__dict__ = initial_values + def __getitem__(self, name): return getattr(self, name)