# Path: brew/styles.py
# class StyleFactory(object):
#     def __init__(self, filename):
#         """
#         :param str filename: The filename of a JSON file containing Styles
#         """
#         self.filename = filename
#         with open(filename, "r") as f:
#             self.data = json.loads(f.read())
# 
#     def create_style(self, category, subcategory):
#         """
#         Create a style given a category and subcategory.
# 
#         :param int category: The Style Category
#         :param str subcategory: The Style Subcategory
#         :return: A Style Object
#         :rtype: Style
#         """
#         data = self.data.get(str(category), {}).get(subcategory, None)
#         return Style(
#             data["style"],
#             category=data["category"],
#             subcategory=data["subcategory"],
#             og=data["og"],
#             fg=data["fg"],
#             abv=data["abv"],
#             ibu=data["ibu"],
#             color=data["color"],
#         )
# 
#     def format(self):
#         msg = []
#         for category in sorted(self.data.keys(), key=int):
#             substyles = self.data[category]
#             for subcategory in sorted(substyles.keys()):
#                 try:
#                     style = self.create_style(category, subcategory)
#                     msg.append(style.format())
#                 except StyleException:
#                     name = self.data[category][subcategory]["style"]
#                     msg.append(
#                         "{}{} {} - Not parseable".format(category, subcategory, name)
#                     )
#         return "\n".join(msg)


import os
from brew.styles import StyleFactory
#! /usr/bin/env python
# -*- coding: utf-8 -*-

"""
A utility for visualizing beer styles
"""




def main():

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

# Path: brew/styles.py
# class StyleFactory(object):
#     def __init__(self, filename):
#         """
#         :param str filename: The filename of a JSON file containing Styles
#         """
#         self.filename = filename
#         with open(filename, "r") as f:
#             self.data = json.loads(f.read())
# 
#     def create_style(self, category, subcategory):
#         """
#         Create a style given a category and subcategory.
# 
#         :param int category: The Style Category
#         :param str subcategory: The Style Subcategory
#         :return: A Style Object
#         :rtype: Style
#         """
#         data = self.data.get(str(category), {}).get(subcategory, None)
#         return Style(
#             data["style"],
#             category=data["category"],
#             subcategory=data["subcategory"],
#             og=data["og"],
#             fg=data["fg"],
#             abv=data["abv"],
#             ibu=data["ibu"],
#             color=data["color"],
#         )
# 
#     def format(self):
#         msg = []
#         for category in sorted(self.data.keys(), key=int):
#             substyles = self.data[category]
#             for subcategory in sorted(substyles.keys()):
#                 try:
#                     style = self.create_style(category, subcategory)
#                     msg.append(style.format())
#                 except StyleException:
#                     name = self.data[category][subcategory]["style"]
#                     msg.append(
#                         "{}{} {} - Not parseable".format(category, subcategory, name)
#                     )
#         return "\n".join(msg)


# Path: examples/styles.py
import os
from brew.styles import StyleFactory

#! /usr/bin/env python
# -*- coding: utf-8 -*-

"""
A utility for visualizing beer styles
"""




def main():

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

    factory = StyleFactory(os.path.join(data_dir, "bjcp", "styles.json"))