Ejemplo n.º 1
0
def prime(ctx, beer, vol, temp):
    """
    Calculates the amount of table sugar, corn sugar, or DME needed to achieve
    the requested CO2 volumes
    """
    if not beer:
        unit = ctx.obj["units"]["vol"]
        beer = utils.get_input("Volume of beer to prime ({}): ".format(unit),
                               lambda x: float(x))
    if not vol:
        vol = utils.get_input("Desired volumes of CO2: ", lambda x: float(x))

    if not temp:
        unit = ctx.obj["units"]["temp"]
        temp = utils.get_input("Temperature of beer ({}): ".format(unit),
                               lambda x: float(x))

    if ctx.obj['unit'] == 'metric':
        temp = bm.c_to_f(temp)
        beer = bm.l_to_g(beer)

    sugar = bm.priming(temp, beer, vol)
    if ctx.obj['unit'] == 'imperial':
        sugar = bm.g_to_oz(sugar)

    unit = ctx.obj["units"]["weight"]
    print()
    print("Use only one of the following:")
    print("Table sugar: {0:.2f}{1}".format(sugar, unit))
    print("Corn Sugar: {0:.2f}{1}".format(sugar * 1.099421965317919, unit))
    print("DME: {0:.2f}{1}".format(sugar * 1.4705202312138728, unit))
Ejemplo n.º 2
0
def prime(ctx, beer, vol, temp):
    """
    Calculates the amount of table sugar, corn sugar, or DME needed to achieve
    the requested CO2 volumes for bottle priming
    """
    if not beer:
        beer = inputs.get_unit_input(ctx.obj["units"]["vol"],
                                     "Volume of beer to prime")
    if not vol:
        vol = inputs.get_input("Desired volumes of CO2: ", lambda x: float(x))
    if not temp:
        temp = temp = inputs.get_unit_input(ctx.obj["units"]["temp"],
                                            "Temperature of beer")

    if is_metric(ctx):
        temp = bm.c_to_f(temp)
        beer = bm.l_to_g(beer)

    sugar = bm.priming(temp, beer, vol)
    if is_imperial(ctx):
        sugar = bm.g_to_oz(sugar)

    unit = ctx.obj["units"]["weight"]
    print()
    print("Use only one of the following:")
    print("Table sugar: {0:.2f}{1}".format(sugar, unit))
    print("Corn Sugar: {0:.2f}{1}".format(sugar * 1.099421965317919, unit))
    print("DME: {0:.2f}{1}".format(sugar * 1.4705202312138728, unit))
Ejemplo n.º 3
0
def print_mass(value: float) -> None:
    print("{0} kg => {1:.3f} lbs".format(value, bm.kg_to_lbs(value)))
    print("{0} g => {1:.3f} oz".format(value, bm.g_to_oz(value)))
    print("{0} lbs => {1:.3f} kg".format(value, bm.lbs_to_kg(value)))
    print("{0} oz => {1:.3f} g".format(value, bm.oz_to_g(value)))
Ejemplo n.º 4
0
def test_g_to_oz():
    oz = bm.g_to_oz(34)
    assert oz == pytest.approx(1.199, 0.001)