예제 #1
0
	def test_kg_to_kg(self):
		assert to_kg(*(5, 'KILOGRAM')) == 5
예제 #2
0
	def test_pound_to_kg(self):
		assert to_kg(*(5, 'POUND')) == 2.2679618500000003
예제 #3
0
	def test_gram_to_kg(self):
		assert to_kg(*(5, 'GRAM')) == 0.005
예제 #4
0
    def to_xml(self):
        from draughtcraft.lib.beerxml import export

        if self.hop:

            kw = {
                'name'   : self.hop.name,
                'alpha'  : self.hop.alpha_acid,
                'amount' : to_kg(self.amount, self.unit),
                'time'   : self.minutes,
                'notes'  : self.hop.description,
                'form'   : self.form.capitalize(),
                'origin' : self.hop.printed_origin
            }

            kw['use'] = {
                'MASH'       : 'Mash',
                'FIRST WORT' : 'First Wort',
                'BOIL'       : 'Boil',
                'POST-BOIL'  : 'Aroma',
                'FLAME OUT'  : 'Aroma',
                'PRIMARY'    : 'Dry Hop',
                'SECONDARY'  : 'Dry Hop',
                'TERTIARY'   : 'Dry Hop'
            }.get(self.use)

            return export.Hop(**kw)

        if self.fermentable:
            kw = {
                'name'           : self.fermentable.name,
                'amount'         : to_kg(self.amount, self.unit),
                'yield'          : self.fermentable.percent_yield,
                'color'          : self.fermentable.lovibond,
                'add_after_boil' : self.step == 'fermentation',
                'origin'         : self.fermentable.printed_origin,
                'notes'          : self.fermentable.description
            }

            kw['type'] = {
                'MALT'    : 'Grain',
                'GRAIN'   : 'Grain',
                'ADJUNCT' : 'Adjunct',
                'EXTRACT' : 'Extract',
                'SUGAR'   : 'Sugar'
            }.get(self.fermentable.type)

            if self.fermentable.type == 'EXTRACT' and 'DME' in self.fermentable.name:
                kw['type'] = 'Dry Extract'

            return export.Fermentable(**kw)

        if self.yeast:
            kw = {
                'name'        : self.yeast.name,
                'form'        : self.yeast.form.capitalize(),
                'attenuation' : self.yeast.attenuation * 100.00,
                'notes'       : self.yeast.description
            }

            # Map types as appropriately as possible to BeerXML <TYPE>'s.
            kw['type'] = {
                'ALE'   : 'Ale',
                'LAGER' : 'Lager',
                'WILD'  : 'Ale',
                'MEAD'  : 'Wine',
                'CIDER' : 'Wine',
                'WINE'  : 'Wine'
            }.get(self.yeast.type)

            if self.yeast.form == 'LIQUID':
                #
                # If the yeast is liquid, it's probably a activator/vial.  For
                # simplicity, we'll assume Wyeast's volume, 125ml.
                #
                kw['amount'] = 0.125
            else:
                #
                # If the yeast is dry, it's probably a small packet.  For
                # simplicity, we'll assume a standard weight of 11.5g.
                #
                kw['amount'] = 0.0115
                kw['amount_is_weight'] = True

            if self.use in ('SECONDARY', 'TERTIARY'):
                kw['add_to_secondary'] = True

            return export.Yeast(**kw)

        if self.extra:
            kw = {
                'name'  : self.extra.name,
                'type'  : string.capwords(self.extra.type),
                'time'  : self.minutes,
                'notes' : self.extra.description
            }

            kw['use'] = {
                'MASH'       : 'Mash',
                'FIRST WORT' : 'Boil',
                'BOIL'       : 'Boil',
                'POST-BOIL'  : 'Boil',
                'FLAME OUT'  : 'Boil',
                'PRIMARY'    : 'Primary',
                'SECONDARY'  : 'Secondary',
                'TERTIARY'   : 'Secondary'
            }.get(self.use)

            if self.unit is None:
                #
                # If there's no unit (meaning it's just one "unit"), assume
                # a weight of 15 grams.
                #
                kw['amount'] = 0.015
                kw['amount_is_weight'] = True
            elif self.extra.liquid:
                kw['amount'] = to_l(self.amount, self.unit)
            else:
                kw['amount'] = to_kg(self.amount, self.unit)
                kw['amount_is_weight'] = True

            return export.Misc(**kw)
예제 #5
0
	def test_ounces_to_kg(self):
		assert to_kg(*(16, 'OUNCE')) == 2.2679618500000003
예제 #6
0
 def test_gram_to_kg(self):
     assert to_kg(*(5, "GRAM")) == 0.005
예제 #7
0
 def test_kg_to_kg(self):
     assert to_kg(*(5, "KILOGRAM")) == 5
예제 #8
0
    def to_xml(self):
        from draughtcraft.lib.beerxml import export

        if self.hop:

            kw = {
                'name': self.hop.name,
                'alpha': self.hop.alpha_acid,
                'amount': to_kg(self.amount, self.unit),
                'time': self.minutes,
                'notes': self.hop.description,
                'form': self.form.capitalize(),
                'origin': self.hop.printed_origin
            }

            kw['use'] = {
                'MASH': 'Mash',
                'FIRST WORT': 'First Wort',
                'BOIL': 'Boil',
                'POST-BOIL': 'Aroma',
                'FLAME OUT': 'Aroma',
                'PRIMARY': 'Dry Hop',
                'SECONDARY': 'Dry Hop',
                'TERTIARY': 'Dry Hop'
            }.get(self.use)

            return export.Hop(**kw)

        if self.fermentable:
            kw = {
                'name': self.fermentable.name,
                'amount': to_kg(self.amount, self.unit),
                'yield': self.fermentable.percent_yield,
                'color': self.fermentable.lovibond,
                'add_after_boil': self.step == 'fermentation',
                'origin': self.fermentable.printed_origin,
                'notes': self.fermentable.description
            }

            kw['type'] = {
                'MALT': 'Grain',
                'GRAIN': 'Grain',
                'ADJUNCT': 'Adjunct',
                'EXTRACT': 'Extract',
                'SUGAR': 'Sugar'
            }.get(self.fermentable.type)

            if self.fermentable.type == 'EXTRACT' and \
                    'DME' in self.fermentable.name:
                kw['type'] = 'Dry Extract'

            return export.Fermentable(**kw)

        if self.yeast:
            kw = {
                'name': self.yeast.name,
                'form': self.yeast.form.capitalize(),
                'attenuation': self.yeast.attenuation * 100.00,
                'notes': self.yeast.description
            }

            # Map types as appropriately as possible to BeerXML <TYPE>'s.
            kw['type'] = {
                'ALE': 'Ale',
                'LAGER': 'Lager',
                'WILD': 'Ale',
                'MEAD': 'Wine',
                'CIDER': 'Wine',
                'WINE': 'Wine'
            }.get(self.yeast.type)

            if self.yeast.form == 'LIQUID':
                #
                # If the yeast is liquid, it's probably a activator/vial.  For
                # simplicity, we'll assume Wyeast's volume, 125ml.
                #
                kw['amount'] = 0.125
            else:
                #
                # If the yeast is dry, it's probably a small packet.  For
                # simplicity, we'll assume a standard weight of 11.5g.
                #
                kw['amount'] = 0.0115
                kw['amount_is_weight'] = True

            if self.use in ('SECONDARY', 'TERTIARY'):
                kw['add_to_secondary'] = True

            return export.Yeast(**kw)

        if self.extra:
            kw = {
                'name': self.extra.name,
                'type': string.capwords(self.extra.type),
                'time': self.minutes,
                'notes': self.extra.description
            }

            kw['use'] = {
                'MASH': 'Mash',
                'FIRST WORT': 'Boil',
                'BOIL': 'Boil',
                'POST-BOIL': 'Boil',
                'FLAME OUT': 'Boil',
                'PRIMARY': 'Primary',
                'SECONDARY': 'Secondary',
                'TERTIARY': 'Secondary'
            }.get(self.use)

            if self.unit is None:
                #
                # If there's no unit (meaning it's just one "unit"), assume
                # a weight of 15 grams.
                #
                kw['amount'] = 0.015
                kw['amount_is_weight'] = True
            elif self.extra.liquid:
                kw['amount'] = to_l(self.amount, self.unit)
            else:
                kw['amount'] = to_kg(self.amount, self.unit)
                kw['amount_is_weight'] = True

            return export.Misc(**kw)
예제 #9
0
 def test_kg_to_kg(self):
     assert to_kg(*(5, 'KILOGRAM')) == 5
예제 #10
0
 def test_gram_to_kg(self):
     assert to_kg(*(5, 'GRAM')) == 0.005
예제 #11
0
 def test_pound_to_kg(self):
     assert to_kg(*(5, 'POUND')) == 2.2679618500000003
예제 #12
0
 def test_ounces_to_kg(self):
     assert to_kg(*(16, 'OUNCE')) == 2.2679618500000003