# Path: brew/parsers.py
# class JSONDataLoader(DataLoader):
#     """
#     Load data from JSON files inside the data_dir.
#     """
# 
#     #: The JSON file extension
#     EXT = "json"
# 
#     @classmethod
#     def read_data(cls, filename):
#         """
#         :param str filename: The filename of the file to read
#         :return: The data loaded from a JSON file
#         """
#         data = None
#         with open(filename, "r") as data_file:
#             data = json.loads(data_file.read())
#         return data
# 
# Path: brew/parsers.py
# def parse_recipe(
#     recipe,
#     loader,
#     cereals_loader=None,
#     hops_loader=None,
#     yeast_loader=None,
#     cereals_dir_suffix="cereals/",
#     hops_dir_suffix="hops/",
#     yeast_dir_suffix="yeast/",
# ):
#     """
#     Parse a recipe from a python Dict
# 
#     :param dict recipe: A representation of a recipe
#     :param DataLoader loader: A class to load additional information
#     :param DataLoader cereal_loader: A class to load additional information specific to cereals
#     :param DataLoader hops_loader: A class to load additional information specific to hops
#     :param DataLoader yeast_loader: A class to load additional information specific to yeast
# 
#     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:
# 
#     * 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.
#     """  # noqa
#     if cereals_loader is None:
#         cereals_loader = loader
#     if hops_loader is None:
#         hops_loader = loader
#     if yeast_loader is None:
#         yeast_loader = loader
# 
#     Recipe.validate(recipe)
# 
#     grain_additions = []
#     for grain in recipe[u"grains"]:
#         grain_additions.append(
#             parse_cereals(grain, cereals_loader, dir_suffix=cereals_dir_suffix)
#         )
# 
#     hop_additions = []
#     for hop in recipe[u"hops"]:
#         hop_additions.append(parse_hops(hop, hops_loader, dir_suffix=hops_dir_suffix))
# 
#     yeast = parse_yeast(recipe[u"yeast"], yeast_loader, dir_suffix=yeast_dir_suffix)
# 
#     recipe_kwargs = {
#         u"grain_additions": grain_additions,
#         u"hop_additions": hop_additions,
#         u"yeast": yeast,
#         u"start_volume": recipe[u"start_volume"],
#         u"final_volume": recipe[u"final_volume"],
#     }
#     if u"data" in recipe:
#         if u"brew_house_yield" in recipe[u"data"]:
#             recipe_kwargs[u"brew_house_yield"] = recipe[u"data"][u"brew_house_yield"]
#         if u"units" in recipe[u"data"]:
#             recipe_kwargs[u"units"] = recipe[u"data"][u"units"]
# 
#     beer = Recipe(recipe[u"name"], **recipe_kwargs)
#     return beer


import os
from brew.parsers import JSONDataLoader
from brew.parsers import parse_recipe
                u"name": u"caramel crystal malt 120l",
                u"weight": 0.375,
                u"grain_type": u"specialty",
            },
        ],
        u"hops": [
            {
                u"name": u"challenger",
                u"data": {u"percent_alpha_acids": 0.08},
                u"weight": 1.43,
                u"boil_time": 60.0,
            },
            {
                u"name": u"fuggle",
                u"data": {u"percent_alpha_acids": 0.05},
                u"weight": 1.5,
                u"boil_time": 10.0,
            },
            {
                u"name": u"east kent golding",
                u"data": {u"percent_alpha_acids": 0.05},
                u"weight": 1.5,
                u"boil_time": 0.0,
            },
        ],
        u"yeast": {u"name": u"Wyeast 1028", u"data": {u"percent_attenuation": 0.74}},
        u"data": {u"brew_house_yield": 0.70, u"units": u"imperial"},
    }

    data_dir = os.path.abspath(os.path.join(os.getcwd(), "data/"))

# Path: brew/parsers.py
# class JSONDataLoader(DataLoader):
#     """
#     Load data from JSON files inside the data_dir.
#     """
# 
#     #: The JSON file extension
#     EXT = "json"
# 
#     @classmethod
#     def read_data(cls, filename):
#         """
#         :param str filename: The filename of the file to read
#         :return: The data loaded from a JSON file
#         """
#         data = None
#         with open(filename, "r") as data_file:
#             data = json.loads(data_file.read())
#         return data
# 
# Path: brew/parsers.py
# def parse_recipe(
#     recipe,
#     loader,
#     cereals_loader=None,
#     hops_loader=None,
#     yeast_loader=None,
#     cereals_dir_suffix="cereals/",
#     hops_dir_suffix="hops/",
#     yeast_dir_suffix="yeast/",
# ):
#     """
#     Parse a recipe from a python Dict
# 
#     :param dict recipe: A representation of a recipe
#     :param DataLoader loader: A class to load additional information
#     :param DataLoader cereal_loader: A class to load additional information specific to cereals
#     :param DataLoader hops_loader: A class to load additional information specific to hops
#     :param DataLoader yeast_loader: A class to load additional information specific to yeast
# 
#     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:
# 
#     * 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.
#     """  # noqa
#     if cereals_loader is None:
#         cereals_loader = loader
#     if hops_loader is None:
#         hops_loader = loader
#     if yeast_loader is None:
#         yeast_loader = loader
# 
#     Recipe.validate(recipe)
# 
#     grain_additions = []
#     for grain in recipe[u"grains"]:
#         grain_additions.append(
#             parse_cereals(grain, cereals_loader, dir_suffix=cereals_dir_suffix)
#         )
# 
#     hop_additions = []
#     for hop in recipe[u"hops"]:
#         hop_additions.append(parse_hops(hop, hops_loader, dir_suffix=hops_dir_suffix))
# 
#     yeast = parse_yeast(recipe[u"yeast"], yeast_loader, dir_suffix=yeast_dir_suffix)
# 
#     recipe_kwargs = {
#         u"grain_additions": grain_additions,
#         u"hop_additions": hop_additions,
#         u"yeast": yeast,
#         u"start_volume": recipe[u"start_volume"],
#         u"final_volume": recipe[u"final_volume"],
#     }
#     if u"data" in recipe:
#         if u"brew_house_yield" in recipe[u"data"]:
#             recipe_kwargs[u"brew_house_yield"] = recipe[u"data"][u"brew_house_yield"]
#         if u"units" in recipe[u"data"]:
#             recipe_kwargs[u"units"] = recipe[u"data"][u"units"]
# 
#     beer = Recipe(recipe[u"name"], **recipe_kwargs)
#     return beer


# Path: examples/brewing_classic_styles/biere_de_linde_dict.py
import os
from brew.parsers import JSONDataLoader
from brew.parsers import parse_recipe

                u"name": u"caramel crystal malt 120l",
                u"weight": 0.375,
                u"grain_type": u"specialty",
            },
        ],
        u"hops": [
            {
                u"name": u"challenger",
                u"data": {u"percent_alpha_acids": 0.08},
                u"weight": 1.43,
                u"boil_time": 60.0,
            },
            {
                u"name": u"fuggle",
                u"data": {u"percent_alpha_acids": 0.05},
                u"weight": 1.5,
                u"boil_time": 10.0,
            },
            {
                u"name": u"east kent golding",
                u"data": {u"percent_alpha_acids": 0.05},
                u"weight": 1.5,
                u"boil_time": 0.0,
            },
        ],
        u"yeast": {u"name": u"Wyeast 1028", u"data": {u"percent_attenuation": 0.74}},
        u"data": {u"brew_house_yield": 0.70, u"units": u"imperial"},
    }

    data_dir = os.path.abspath(os.path.join(os.getcwd(), "data/"))

    loader = JSONDataLoader(data_dir)