示例#1
0
    def transform(self):
        """Transform the data as neccessary to fit our specs."""
        self.name = '"' + self.name + '"'
        # convert boolean to integer for sqlite
        self.is_mashed = (1 if self.is_mashed == 'true' else 0)
        # Sugar has a PPG of 46. Multiply the potential percent yield by 46 to
        # get PPG of a grain
        self.ppg = 46 * (self.potential / 100)

        self.country = convert_country(self.origin)

        # parse type
        if self.type == "Extract":
            self.type = "Liquid Malt Extract"
        elif self.type == "Dry Extract":
            self.type = "Dry Malt Extract"

        if len(self.type) == 0:
            self.type = "NULL"
        else:
            self.type = '"' + self.type + '"'

        # convert "None" notes to empty
        if self.notes is None:
            self.notes = '""'
        else:
            self.notes = '"' + self.notes + '"'
示例#2
0
    def transform(self):
        self.name = '"' + self.name + '"'
        self.type = '"' + self.type + '"'
        # convert "None" notes to empty
        if self.notes is None:
            self.notes = '""'
        else:
            self.notes = '"' + self.notes + '"'

        # change countries to valid ones
        lookup = {
            "England": "UK",
            "Czech Republic": "CZ",
            "Austria/Slovenia": "AT"
        }
        if self.origin in lookup:
            self.origin = lookup[self.origin]

        self.country = convert_country(self.origin)