mirror of
https://github.com/PiBrewing/craftbeerpi4.git
synced 2024-11-24 16:08:11 +01:00
fix for fermenter_recipe_controller and flexible config path
This commit is contained in:
parent
46a589c463
commit
fec02047ad
2 changed files with 10 additions and 6 deletions
|
@ -1,4 +1,6 @@
|
||||||
import os
|
import os
|
||||||
|
from os import listdir
|
||||||
|
from os.path import isfile, join
|
||||||
import pathlib
|
import pathlib
|
||||||
import platform
|
import platform
|
||||||
import shutil
|
import shutil
|
||||||
|
@ -26,8 +28,9 @@ class ConfigFolder:
|
||||||
return os.path.join(self._rawPath, 'fermenterrecipes', "{}.yaml".format(recipe_id))
|
return os.path.join(self._rawPath, 'fermenterrecipes', "{}.yaml".format(recipe_id))
|
||||||
|
|
||||||
def get_all_fermenter_recipes(self):
|
def get_all_fermenter_recipes(self):
|
||||||
fermenter_recipes_folder = os.path.join(self._rawPath, 'fermenterrecipes', '*.yaml')
|
fermenter_recipes_folder = os.path.join(self._rawPath, 'fermenterrecipes')
|
||||||
return glob.glob(fermenter_recipes_folder)
|
fermenter_recipe_ids = [os.path.splitext(f)[0] for f in listdir(fermenter_recipes_folder) if isfile(join(fermenter_recipes_folder, f)) and f.endswith(".yaml")]
|
||||||
|
return fermenter_recipe_ids
|
||||||
|
|
||||||
def check_for_setup(self):
|
def check_for_setup(self):
|
||||||
if self.config_file_exists("config.yaml") is False:
|
if self.config_file_exists("config.yaml") is False:
|
||||||
|
|
|
@ -43,14 +43,15 @@ class FermenterRecipeController:
|
||||||
|
|
||||||
|
|
||||||
async def get_recipes(self):
|
async def get_recipes(self):
|
||||||
fermenter_recipes = self.cbpi.config_folder.get_all_fermenter_recipes()
|
fermenter_recipe_ids = self.cbpi.config_folder.get_all_fermenter_recipes()
|
||||||
|
|
||||||
result = []
|
result = []
|
||||||
for filename in fermenter_recipes:
|
for recipe_id in fermenter_recipe_ids:
|
||||||
with open(filename) as file:
|
|
||||||
|
with open(self.cbpi.config_folder.get_fermenter_recipe_by_id(recipe_id)) as file:
|
||||||
data = yaml.load(file, Loader=yaml.FullLoader)
|
data = yaml.load(file, Loader=yaml.FullLoader)
|
||||||
dataset = data["basic"]
|
dataset = data["basic"]
|
||||||
dataset["file"] = filename
|
dataset["file"] = recipe_id
|
||||||
result.append(dataset)
|
result.append(dataset)
|
||||||
logging.info(result)
|
logging.info(result)
|
||||||
return result
|
return result
|
||||||
|
|
Loading…
Reference in a new issue