Example #1
0
def pb_action_to_action(pb_action):
    """
    Convert a Protocol Buffer Action into an Action object.
    """
    action = Action(type='fold')
    keys = [key for key in dir(protocol.Action) if key.isupper()]
    for key in keys:
        if getattr(protocol.Action, key) == pb_action.type:
            action.type = key.lower()
            break
    else:
        raise Exception("Could not decode action type %d" % pb_action.type)
    if hasattr(pb_action, 'amount'):
        action.amount = pb_action.amount
    return action
Example #2
0
def pb_action_to_action(pb_action):
    """
    Convert a Protocol Buffer Action into an Action object.
    """
    action = Action(type='fold')
    keys = [key for key in dir(protocol.Action) if key.isupper()]
    for key in keys:
        if getattr(protocol.Action, key) == pb_action.type:
            action.type = key.lower()
            break
    else:
        raise Exception("Could not decode action type %d" % pb_action.type)
    if hasattr(pb_action, 'amount'):
        action.amount = pb_action.amount
    return action