grocy-cli/grocy/meta.py

28 lines
887 B
Python
Raw Normal View History

from grocy.entity import Entity
from grocy.schema import get_schema
from grocy.recipe import Recipe
from fontawesome import icons as fa_icons
class Meta(object):
def __init__(self):
self.meta = {'meta': {'entities': {}, 'fa_icons': fa_icons}}
def add(self, type, name):
if type == 'entities':
entity = Entity(name=name)
resources = entity.get()
schema = get_schema(name)
elif type == 'recipes':
recipe = Recipe()
if name == 'fulfillments':
resources = recipe.get_fulfillments()
schema = get_schema(name='recipe_fulfilments')
self.meta['meta'][type][name] = {}
self.meta['meta'][type][name]['properties'] = schema['properties']
self.meta['meta'][type][name]['valid_values'] = resources
def generate(self):
return self.meta