Exemplo n.º 1
0
def generate_drink_from_data(data):
    f, success = try_parse_float(data[0].strip())
    if not success:
        return None

    d = Drink()
    time = int(f)
    d.time_of_drink = datetime.fromtimestamp(time)
    d.drinker = data[1].strip()
    d.abv, success = try_parse_float(data[2])
    if not success:
        return None

    d.volume_oz, success = try_parse_float(data[3])
    if not success:
        return None

    return d
Exemplo n.º 2
0
def generate_dummy_drink_data(drinker_name='n', start_time=None):
    dummy_drinks = []

    if start_time is None:
        t = datetime.now().replace(hour=12)
    else:
        t = start_time

    for i in range(10):

        d = Drink()
        d.time_of_drink = t
        d.drinker = drinker_name
        d.volume_oz = 12.0 + (random.randint(0, 1) * 4.0)
        d.abv = 5.0 + (random.random() * 5.5) - 1.0
        dummy_drinks.append(d)
        minute_delta = (random.random() * 20) + 30
        t = t + timedelta(minutes=minute_delta)
    return calculate_bac_curve(dummy_drinks)