# Path: alephnull/protocol.py
# DATASOURCE_TYPE = Enum(
#     'AS_TRADED_EQUITY',
#     'MERGER',
#     'SPLIT',
#     'DIVIDEND',
#     'TRADE',
#     'TRANSACTION',
#     'ORDER',
#     'EMPTY',
#     'DONE',
#     'CUSTOM',
#     'BENCHMARK',
#     'COMMISSION'
# )


import pytz
import numbers
from hashlib import md5
from datetime import datetime
from alephnull.protocol import DATASOURCE_TYPE
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.





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()


def assert_datasource_protocol(event):
    """Assert that an event meets the protocol for datasource outputs."""

    assert isinstance(event.source_id, basestring)
    assert event.type in DATASOURCE_TYPE

    # Done packets have no dt.

# Path: alephnull/protocol.py
# DATASOURCE_TYPE = Enum(
#     'AS_TRADED_EQUITY',
#     'MERGER',
#     'SPLIT',
#     'DIVIDEND',
#     'TRADE',
#     'TRANSACTION',
#     'ORDER',
#     'EMPTY',
#     'DONE',
#     'CUSTOM',
#     'BENCHMARK',
#     'COMMISSION'
# )


# Path: alephnull/gens/utils.py
import pytz
import numbers
from hashlib import md5
from datetime import datetime
from alephnull.protocol import DATASOURCE_TYPE

#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.





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()


def assert_datasource_protocol(event):
    """Assert that an event meets the protocol for datasource outputs."""

    assert isinstance(event.source_id, basestring)
    assert event.type in DATASOURCE_TYPE

    # Done packets have no dt.

    if not event.type == DATASOURCE_TYPE.DONE: