brew.parsers

class brew.parsers.DataLoader(data_dir)

Base class for loading data from data files inside the data_dir.

DATA = {}
EXT = ''
classmethod format_name(name)

Reformat a given name to match the filename of a data file.

get_item(dir_suffix, item_name)
classmethod read_data(filename)
class brew.parsers.JSONDataLoader(data_dir)

Load data from JSON files inside the data_dir.

DATA = {}
EXT = 'json'
format_name(name)

Reformat a given name to match the filename of a data file.

get_item(dir_suffix, item_name)
classmethod read_data(filename)
parsers.parse_cereals(cereal, loader)

Parse grains data from a recipe

Grain must have the following top level attributes: - name (str) - weight (float) - data (dict) (optional)

Additionally grains may contain override data in the ‘data’ attribute with the following keys: - color (float) - ppg (int)

parsers.parse_hops(hop, loader)

Parse hops data from a recipe

Hops must have the following top level attributes: - name (str) - weight (float) - boil_time (float) - data (dict) (optional)

Additionally hops may contain override data in the ‘data’ attribute with the following keys: - percent_alpha_acids (float)

parsers.parse_yeast(yeast, loader)

Parse yeast data from a recipe

Yeast must have the following top level attributes: - name (str) - data (dict) (optional)

Additionally yeast may contain override data in the ‘data’ attribute with the following keys: - percent_attenuation (float)

parsers.parse_recipe(recipe, loader, cereals_loader=None, hops_loader=None, yeast_loader=None)

Parse a recipe from a python Dict

recipe: a python dict describing the recipe loader: a data loader class that loads data from data files

A recipe must have the following top level attributes: - name (str) - start_volume (float) - final_volume (float) - grains (list(dict)) - hops (list(dict)) - yeast (dict)

Additionally the recipe may contain override data in the ‘data’ attribute with the following keys: - percent_brew_house_yield (float) - units (str)

All other fields will be ignored and may be used for other metadata.

The dict objects in the grains, hops, and yeast values are required to have the key ‘name’ and the remaining attributes will be looked up in the data directory if they are not provided.