def __new__(cls, name, bases, d):
        state = d.get('initial_state')

        if state == None:
            for base in bases:
                try:
                    state = base.initial_state
                    break
                except AttributeError:
                    pass

        before, after = [], []

        for name, func in d.items():
            try:
                after += [(start, end, func) for start, end in func.after]
            except AttributeError:
                pass

            try:
                before += [(start, end, func) for start, end in func.before]
            except __HOLE__:
                pass

        d['_after_transitions'] = after
        d['_before_transitions'] = before
        d['_state'] = state

        return type.__new__(cls, name, bases, d)

# Python 2/3 Metaclass
# http://mikewatkins.ca/2008/11/29/python-2-and-3-metaclasses/
dataset/ETHPy150Open kyleconroy/statemachine/statemachine.py/MetaMachine.__new__