recipes: pull type and machine variables out of the recipe list

This commit is contained in:
Danny Robson 2019-04-28 11:03:27 +10:00
parent 79df7638a8
commit 14fe028fe1
44 changed files with 844 additions and 500 deletions

View File

@ -1,12 +1,21 @@
[
{ {
"type": [ "component" ], "type": [
"input": { "circuit_board": 1, "quickwire": 18 }, "component"
"output": { "ai_limiter": 1 }, ],
"machine": "assembler", "machine": "assembler",
"recipes": [
{
"input": {
"circuit_board": 1,
"quickwire": 18
},
"output": {
"ai_limiter": 1
},
"crafting_time": 12, "crafting_time": 12,
"clicks": 3, "clicks": 3,
"stack_size": 100, "stack_size": 100,
"requires": "caterium_electronics" "requires": "caterium_electronics"
} }
] ]
}

View File

@ -1,10 +1,19 @@
[
{ {
"type": [ "component", "item" ], "type": [
"input": { "wire": 2 }, "component",
"output": { "cable": 1 }, "item"
],
"machine": "constructor", "machine": "constructor",
"recipes": [
{
"input": {
"wire": 2
},
"output": {
"cable": 1
},
"crafting_time": 4, "crafting_time": 4,
"clicks": 1 "clicks": 1
} }
] ]
}

View File

@ -1,11 +1,19 @@
[
{ {
"type": [ "component" ], "type": [
"input": { "caterium_ore": 4 }, "component"
"output": { "caterium_ingot": 1 }, ],
"machine": "smelter", "machine": "smelter",
"recipes": [
{
"input": {
"caterium_ore": 4
},
"output": {
"caterium_ingot": 1
},
"crafting_time": 4, "crafting_time": 4,
"clicks": 4, "clicks": 4,
"requires": "caterium_technology" "requires": "caterium_technology"
} }
] ]
}

View File

@ -1,12 +1,21 @@
[
{ {
"type": [ "component" ], "type": [
"input": { "wire": 12, "plastic": 6 }, "component"
"output": { "circuit_board": 1 }, ],
"machine": "assembler", "machine": "assembler",
"stack_size": 100,
"recipes": [
{
"input": {
"wire": 12,
"plastic": 6
},
"output": {
"circuit_board": 1
},
"crafting_time": 12, "crafting_time": 12,
"clicks": 3, "clicks": 3,
"stack_size": 100,
"stage": "expansion" "stage": "expansion"
} }
] ]
}

View File

@ -1,12 +1,23 @@
[
{ {
"type": [ "component" ], "type": [
"input": { "circuit_board": 5, "cable": 12, "plastic": 18, "screw": 60 }, "component"
"output": { "computer": 1 }, ],
"machine": "manufacturer", "machine": "manufacturer",
"stack_size": 50,
"recipes": [
{
"input": {
"circuit_board": 5,
"cable": 12,
"plastic": 18,
"screw": 60
},
"output": {
"computer": 1
},
"crafting_time": 32, "crafting_time": 32,
"clicks": 8, "clicks": 8,
"stack_size": 50,
"stage": "expansion" "stage": "expansion"
} }
] ]
}

View File

@ -1,11 +1,19 @@
[
{ {
"type": [ "component" ], "type": [
"input": { "limestone": 3 }, "component"
"output": { "concrete": 1 }, ],
"machine": "constructor", "machine": "constructor",
"recipes": [
{
"input": {
"limestone": 3
},
"output": {
"concrete": 1
},
"crafting_time": 4, "crafting_time": 4,
"clicks": 1, "clicks": 1,
"requires": "hub_upgrade_2" "requires": "hub_upgrade_2"
} }
] ]
}

View File

@ -1,12 +1,20 @@
[
{ {
"type": [ "component" ], "type": [
"input": { "copper_ore": 1 }, "component"
"output": { "copper_ingot": 1 }, ],
"machine": "smelter", "machine": "smelter",
"stack_size": 100,
"recipes": [
{
"input": {
"copper_ore": 1
},
"output": {
"copper_ingot": 1
},
"crafting_time": 2, "crafting_time": 2,
"clicks": 2, "clicks": 2,
"stack_size": 100,
"stage": "establishing" "stage": "establishing"
} }
] ]
}

View File

@ -1,12 +1,21 @@
[
{ {
"type": [ "component" ], "type": [
"input": { "steel_beam": 4, "concrete": 5 }, "component"
"output": { "encased_industrial_beam": 1 }, ],
"machine": "assembler", "machine": "assembler",
"stack_size": 100,
"recipes": [
{
"input": {
"steel_beam": 4,
"concrete": 5
},
"output": {
"encased_industrial_beam": 1
},
"crafting_time": 15, "crafting_time": 15,
"clicks": 4, "clicks": 4,
"stack_size": 100,
"stage": "development" "stage": "development"
} }
] ]
}

View File

@ -1,12 +1,23 @@
[
{ {
"type": [ "component" ], "type": [
"input": { "modular_frame": 5, "steel_pipe": 15, "encased_industrial_beam": 5, "screw": 90 }, "component"
"output": { "heavy_modular_frame": 1 }, ],
"machine": "assembler", "machine": "assembler",
"stack_size": 50,
"recipes": [
{
"input": {
"modular_frame": 5,
"steel_pipe": 15,
"encased_industrial_beam": 5,
"screw": 90
},
"output": {
"heavy_modular_frame": 1
},
"crafting_time": 30, "crafting_time": 30,
"clicks": 8, "clicks": 8,
"stack_size": 50,
"stage": "development" "stage": "development"
} }
] ]
}

View File

@ -1,12 +1,22 @@
[
{ {
"type": [ "component" ], "type": [
"input": { "quickwire": 40, "cable": 10, "plastic": 6 }, "component"
"output": { "high_speed_connector": 1 }, ],
"machine": "manufacturer", "machine": "manufacturer",
"stack_size": 100,
"recipes": [
{
"input": {
"quickwire": 40,
"cable": 10,
"plastic": 6
},
"output": {
"high_speed_connector": 1
},
"crafting_time": 24, "crafting_time": 24,
"clicks": 6, "clicks": 6,
"stack_size": 100,
"requires": "caterium_electronics" "requires": "caterium_electronics"
} }
] ]
}

View File

@ -1,10 +1,18 @@
[
{ {
"type": [ "component" ], "type": [
"input": { "iron_ore": 1 }, "component"
"output": { "iron_ingot": 1 }, ],
"machine": "smelter", "machine": "smelter",
"recipes": [
{
"input": {
"iron_ore": 1
},
"output": {
"iron_ingot": 1
},
"crafting_time": 2, "crafting_time": 2,
"clicks": 2 "clicks": 2
} }
] ]
}

View File

@ -1,9 +1,17 @@
[
{ {
"type": [ "component" ], "type": [
"input": { "iron_ingot": 2 }, "component"
"output": { "iron_plate": 1 }, ],
"recipes": [
{
"input": {
"iron_ingot": 2
},
"output": {
"iron_plate": 1
},
"crafting_time": 4, "crafting_time": 4,
"clicks": 1 "clicks": 1
} }
] ]
}

View File

@ -1,10 +1,18 @@
[
{ {
"type": [ "component" ], "type": [
"input": { "iron_ingot": 1 }, "component"
"output": { "iron_rod": 1 }, ],
"machine": "constructor", "machine": "constructor",
"recipes": [
{
"input": {
"iron_ingot": 1
},
"output": {
"iron_rod": 1
},
"crafting_time": 4, "crafting_time": 4,
"clicks": 1 "clicks": 1
} }
] ]
}

View File

@ -1,12 +1,21 @@
[
{ {
"type": [ "component" ], "type": [
"input": { "reinforced_iron_plate": 3, "iron_rod": 3 }, "component"
"output": { "modular_frame": 1 }, ],
"machine": "assembler", "machine": "assembler",
"stack_size": 50,
"recipes": [
{
"input": {
"reinforced_iron_plate": 3,
"iron_rod": 3
},
"output": {
"modular_frame": 1
},
"crafting_time": 15, "crafting_time": 15,
"clicks": 4, "clicks": 4,
"stack_size": 50,
"stage": "establishing" "stage": "establishing"
} }
] ]
}

View File

@ -1,10 +1,19 @@
[
{ {
"type": [ "component" ], "type": [
"input": { "rotor": 2, "stator": 2 }, "component"
"output": { "motor": 1 }, ],
"machine": "assembler", "machine": "assembler",
"recipes": [
{
"input": {
"rotor": 2,
"stator": 2
},
"output": {
"motor": 1
},
"crafting_time": 12, "crafting_time": 12,
"clicks": 3 "clicks": 3
} }
] ]
}

View File

@ -1,12 +1,20 @@
[
{ {
"type": [ "component" ], "type": [
"input": { "crude_oil": 4 }, "component"
"output": { "plastic": 3 }, ],
"machine": "oil_refinery", "machine": "oil_refinery",
"stack_size": 100,
"recipes": [
{
"input": {
"crude_oil": 4
},
"output": {
"plastic": 3
},
"crafting_time": 8, "crafting_time": 8,
"clicks": 2, "clicks": 2,
"stack_size": 100,
"stage": "expansion" "stage": "expansion"
} }
] ]
}

View File

@ -1,12 +1,20 @@
[
{ {
"type": [ "component" ], "type": [
"input": { "caterium_ingot": 1 }, "component"
"output": { "quickwire": 4 }, ],
"machine": "constructor", "machine": "constructor",
"stack_size": 500,
"recipes": [
{
"input": {
"caterium_ingot": 1
},
"output": {
"quickwire": 4
},
"crafting_time": 4, "crafting_time": 4,
"clicks": 1, "clicks": 1,
"stack_size": 500,
"requires": "caterium_technology" "requires": "caterium_technology"
} }
] ]
}

View File

@ -1,11 +1,20 @@
[
{ {
"type": [ "component" ], "type": [
"input": { "iron_plate": 4, "screw": 24 }, "component"
"output": { "reinforced_iron_plate": 1 }, ],
"machine": "assembler", "machine": "assembler",
"recipes": [
{
"input": {
"iron_plate": 4,
"screw": 24
},
"output": {
"reinforced_iron_plate": 1
},
"crafting_time": 12, "crafting_time": 12,
"clicks": 3, "clicks": 3,
"requires": "hub_upgrade_2" "requires": "hub_upgrade_2"
} }
] ]
}

View File

@ -1,12 +1,21 @@
[
{ {
"type": [ "component" ], "type": [
"input": { "iron_rod": 3, "screw": 22 }, "component"
"output": { "rotor": 1 }, ],
"machine": "smelter", "machine": "smelter",
"stack_size": 100,
"recipes": [
{
"input": {
"iron_rod": 3,
"screw": 22
},
"output": {
"rotor": 1
},
"crafting_time": 10, "crafting_time": 10,
"clicks": 3, "clicks": 3,
"stack_size": 100,
"stage": "establishing" "stage": "establishing"
} }
] ]
}

View File

@ -1,12 +1,20 @@
[
{ {
"type": [ "component" ], "type": [
"input": { "crude_oil": 4 }, "component"
"output": { "rubber": 4 }, ],
"machine": "oil_refinery", "machine": "oil_refinery",
"stack_size": 100,
"recipes": [
{
"input": {
"crude_oil": 4
},
"output": {
"rubber": 4
},
"crafting_time": 8, "crafting_time": 8,
"clicks": 2, "clicks": 2,
"stack_size": 100,
"stage": "expansion" "stage": "expansion"
} }
] ]
}

View File

@ -1,11 +1,19 @@
[
{ {
"type": [ "component" ], "type": [
"input": { "iron_rod": 1 }, "component"
"output": { "screw": 6 }, ],
"machine": "constructor", "machine": "constructor",
"recipes": [
{
"input": {
"iron_rod": 1
},
"output": {
"screw": 6
},
"crafting_time": 4, "crafting_time": 4,
"clicks": 2, "clicks": 2,
"requires": "hub_upgrade_2" "requires": "hub_upgrade_2"
} }
] ]
}

View File

@ -1,10 +1,19 @@
[
{ {
"type": [ "component" ], "type": [
"input": { "steel_pipe": 3, "wire": 10 }, "component"
"output": { "stator": 1 }, ],
"recipes": [
{
"input": {
"steel_pipe": 3,
"wire": 10
},
"output": {
"stator": 1
},
"machine": "assembler", "machine": "assembler",
"crafting_time": 10, "crafting_time": 10,
"clicks": 3 "clicks": 3
} }
] ]
}

View File

@ -1,11 +1,19 @@
[
{ {
"type": [ "component" ], "type": [
"input": { "steel_ingot": 3 }, "component"
"output": { "steel_beam": 1 }, ],
"machine": "constructor", "machine": "constructor",
"stack_size": 100,
"recipes": [
{
"input": {
"steel_ingot": 3
},
"output": {
"steel_beam": 1
},
"crafting_time": 6, "crafting_time": 6,
"clicks": 2, "clicks": 2
"stack_size": 100
} }
] ]
}

View File

@ -1,12 +1,21 @@
[
{ {
"type": [ "component" ], "type": [
"input": { "iron_ore": 3, "coal": 3 }, "component"
"output": { "steel_ingot": 2 }, ],
"machine": "foundry", "machine": "foundry",
"stack_size": 100,
"recipes": [
{
"input": {
"iron_ore": 3,
"coal": 3
},
"output": {
"steel_ingot": 2
},
"crafting_time": 4, "crafting_time": 4,
"clicks": 4, "clicks": 4,
"stack_size": 100,
"stage": "development" "stage": "development"
} }
] ]
}

View File

@ -1,12 +1,20 @@
[
{ {
"type": [ "component" ], "type": [
"input": { "steel_ingot": 1 }, "component"
"output": { "steel_pipe": 1 }, ],
"machine": "constructor", "machine": "constructor",
"stack_size": 100,
"recipes": [
{
"input": {
"steel_ingot": 1
},
"output": {
"steel_pipe": 1
},
"crafting_time": 4, "crafting_time": 4,
"clicks": 1, "clicks": 1,
"stack_size": 100,
"stage": "development" "stage": "development"
} }
] ]
}

View File

@ -1,12 +1,23 @@
[
{ {
"type": [ "component" ], "type": [
"input": { "computer": 2, "ai_limiter": 2, "high_speed_connector": 3, "plastic": 21 }, "component"
"output": { "supercomputer": 1 }, ],
"machine": "manufacturer", "machine": "manufacturer",
"stack_size": 50,
"recipes": [
{
"input": {
"computer": 2,
"ai_limiter": 2,
"high_speed_connector": 3,
"plastic": 21
},
"output": {
"supercomputer": 1
},
"crafting_time": 32, "crafting_time": 32,
"clicks": 8, "clicks": 8,
"stack_size": 50,
"requires": "advanced_caterium_electronics" "requires": "advanced_caterium_electronics"
} }
] ]
}

View File

@ -1,12 +1,20 @@
[
{ {
"type": [ "component" ], "type": [
"input": { "copper_ingot": 1 }, "component"
"output": { "wire": 3 }, ],
"machine": "constructor", "machine": "constructor",
"stack_size": 500,
"recipes": [
{
"input": {
"copper_ingot": 1
},
"output": {
"wire": 3
},
"crafting_time": 4, "crafting_time": 4,
"clicks": 1, "clicks": 1,
"stack_size": 500,
"stage": "establishing" "stage": "establishing"
} }
] ]
}

View File

@ -1,10 +1,24 @@
[
{ {
"type": [ "machine" ], "type": [
"input": { "modular_frame": 3, "rotor": 4, "cable": 10 }, "machine"
"output": { "assembler": 1 }, ],
"machine": "_craft_bench", "machine": "_craft_bench",
"power_usage": 15, "power_usage": 15,
"size": [ 11, 14, 8 ] "size": [
11,
14,
8
],
"recipes": [
{
"input": {
"modular_frame": 3,
"rotor": 4,
"cable": 10
},
"output": {
"assembler": 1
}
} }
] ]
}

View File

@ -1,11 +1,24 @@
[
{ {
"type": [ "machine" ], "type": [
"input": { "reinforced_iron_plate": 3, "cable": 2 }, "machine"
"output": { "constructor": 1 }, ],
"machine": "_craft_bench", "machine": "_craft_bench",
"requires": "hub_upgrade_2", "requires": "hub_upgrade_2",
"power_usage": 4, "power_usage": 4,
"size": [ 9, 11, 8 ] "size": [
9,
11,
8
],
"recipes": [
{
"input": {
"reinforced_iron_plate": 3,
"cable": 2
},
"output": {
"constructor": 1
}
} }
] ]
}

View File

@ -1,10 +1,25 @@
[
{ {
"type": [ "machine" ], "type": [
"input": { "heavy_modular_frame": 2, "motor": 2, "cable": 25, "computer": 3 }, "machine"
"output": { "manufacturer": 1 }, ],
"machine": "_craft_bench", "machine": "_craft_bench",
"power_usage": 55, "power_usage": 55,
"size": [ 20, 22, 12 ] "size": [
20,
22,
12
],
"recipes": [
{
"input": {
"heavy_modular_frame": 2,
"motor": 2,
"cable": 25,
"computer": 3
},
"output": {
"manufacturer": 1
}
} }
] ]
}

View File

@ -1,12 +1,26 @@
[
{ {
"type": [ "machine" ], "type": [
"input": { "portable_miner": 1, "iron_rod": 5, "concrete": 5 }, "machine"
"output": { "miner_mk1": 1 }, ],
"is": "miner", "is": "miner",
"machine": "_craft_bench", "machine": "_craft_bench",
"power_usage": 5, "power_usage": 5,
"size": [ 8, 14, 18 ], "size": [
8,
14,
18
],
"recipes": [
{
"input": {
"portable_miner": 1,
"iron_rod": 5,
"concrete": 5
},
"output": {
"miner_mk1": 1
},
"requires": "hub_upgrade_4" "requires": "hub_upgrade_4"
} }
] ]
}

View File

@ -1,10 +1,24 @@
[
{ {
"type": [ "machine" ], "type": [
"input": { "heavy_modular_frame": 2, "motor": 3, "cable": 10 }, "machine"
"output": { "oil_pump": 1 }, ],
"machine": "_craft_bench", "machine": "_craft_bench",
"power_usage": 40, "power_usage": 40,
"size": [ 8, 14, 20 ] "size": [
8,
14,
20
],
"recipes": [
{
"input": {
"heavy_modular_frame": 2,
"motor": 3,
"cable": 10
},
"output": {
"oil_pump": 1
}
} }
] ]
}

View File

@ -1,9 +1,20 @@
[
{ {
"type": [ "machine", "item" ], "type": [
"input": { "iron_plate": 4, "wire": 8, "cable": 4 }, "machine",
"output": { "portable_miner": 1 }, "item"
],
"machine": "equipment_workshop", "machine": "equipment_workshop",
"recipes": [
{
"input": {
"iron_plate": 4,
"wire": 8,
"cable": 4
},
"output": {
"portable_miner": 1
},
"requires": "hub_upgrade_1" "requires": "hub_upgrade_1"
} }
] ]
}

View File

@ -1,10 +1,19 @@
[
{ {
"type": [ "machine" ], "type": [
"input": { "iron_rod": 5, "wire": 8 }, "machine"
"output": { "smelter": 1 }, ],
"machine": "_craft_bench", "machine": "_craft_bench",
"power_usage": 4, "power_usage": 4,
"recipes": [
{
"input": {
"iron_rod": 5,
"wire": 8
},
"output": {
"smelter": 1
},
"size": [ 6, 10, 10 ] "size": [ 6, 10, 10 ]
} }
] ]
}

View File

@ -1,11 +1,14 @@
[
{ {
"type": [ "machine" ], "type": [ "machine" ],
"input": { "concrete": 500, "iron_plate": 250, "iron_rod": 400, "wire": 1500 },
"output": { "space_elevator": 1 },
"machine": "_placement", "machine": "_placement",
"power_usage": null, "power_usage": null,
"size": [ 54, 54, 118 ], "size": [ 54, 54, 118 ],
"recipes":
[
{
"input": { "concrete": 500, "iron_plate": 250, "iron_rod": 400, "wire": 1500 },
"output": { "space_elevator": 1 },
"requires": "hub_upgrade_5" "requires": "hub_upgrade_5"
} }
] ]
}

View File

@ -1,8 +1,11 @@
[
{ {
"type": [ "resource" ], "type": [ "resource" ],
"machine": "miner",
"recipes": [
{
"input": { }, "input": { },
"output": { "caterium_ore": 1 }, "output": { "caterium_ore": 1 }
"machine": "miner"
} }
] ]
}

View File

@ -1,8 +1,11 @@
[
{ {
"type": [ "resource" ], "type": [ "resource" ],
"machine": "miner",
"recipes":
[
{
"input": { }, "input": { },
"output": { "coal": 1 }, "output": { "coal": 1 }
"machine": "miner"
} }
] ]
}

View File

@ -1,8 +1,14 @@
[
{ {
"type": [ "resource" ], "type": [
"resource"
],
"machine": "miner",
"recipes": [
{
"input": {}, "input": {},
"output": { "copper_ore": 1 }, "output": {
"machine": "miner" "copper_ore": 1
}
} }
] ]
}

View File

@ -1,8 +1,11 @@
[
{ {
"type": [ "resource" ], "type": [ "resource" ],
"machine": "oil_pump",
"recipes":
[
{
"input": { }, "input": { },
"output": { "crude_oil": 1 }, "output": { "crude_oil": 1 }
"machine": "oil_pump"
} }
] ]
}

View File

@ -1,8 +1,11 @@
[
{ {
"type": [ "resource" ], "type": [ "resource" ],
"machine": "miner",
"recipes":
[
{
"input": { }, "input": { },
"output": { "iron_ore": 1 }, "output": { "iron_ore": 1 }
"machine": "miner"
} }
] ]
}

View File

@ -1,9 +1,15 @@
[
{ {
"type": [ "resource" ], "type": [
"input": { }, "resource"
"output": { "limestone": 1 }, ],
"machine": "miner", "machine": "miner",
"requires": "hub_upgrade_2" "requires": "hub_upgrade_2",
"recipes": [
{
"input": {},
"output": {
"limestone": 1
}
} }
] ]
}

View File

@ -1,31 +1,12 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import json import satisfactory
import typing
import os
if __name__ == '__main__': if __name__ == '__main__':
root = os.path.dirname(__file__) root = os.path.dirname(__file__)
recipe_root = os.path.join(root, 'data', 'recipes') recipe_root = os.path.join(root, 'data', 'recipes')
cookbook = satisfactory.Cookbook(recipe_root)
recipes = dict() print(i for i in cookbook.resources())
for dirname, dirs, files in os.walk(recipe_root):
for f in files:
path = os.path.join(dirname, f)
name, _ = os.path.splitext(f)
with open(path, 'r') as src:
variations = json.load(src)
recipes[name] = variations
resources = set()
for output, variations in recipes.items():
for option in variations:
if len(option['input']) == 0:
resources.add(output)
print("Resources:", resources)

View File

@ -1,48 +1,13 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import json import satisfactory
import os import os
from typing import Iterable from typing import Iterable
class Cookbook(object):
recipes: dict
def __init__(self, root: str): def graph(cookbook: satisfactory.Cookbook, targets: Iterable[str]):
self.recipes = dict()
for dirname, dirs, files in os.walk(root):
for f in files:
path = os.path.join(dirname, f)
name, _ = os.path.splitext(f)
with open(path, 'r') as src:
variations = json.load(src)
self.recipes[name] = variations
def __getitem__(self, item: str):
return self.recipes[item]
def all(self):
return self.recipes.keys()
def is_component(self, name):
return 'component' in self.recipes[name]['type']
def components(self):
found = set()
for target, methods in self.recipes.items():
for variation in methods:
for need, _ in variation['input'].items():
if need in found:
continue
found.add(need)
if not self.is_component(need):
continue
yield need
def graph(recipes: dict, targets: Iterable[str]):
print("digraph G {") print("digraph G {")
seen = set() seen = set()
@ -51,7 +16,7 @@ def graph(recipes: dict, targets: Iterable[str]):
while remain: while remain:
output = remain.pop() output = remain.pop()
for need in recipes[output][0]['input']: for need in cookbook.recipes(output)[0]['input']:
print(f"{need} -> {output}") print(f"{need} -> {output}")
if need not in seen: if need not in seen:
remain.add(need) remain.add(need)
@ -81,7 +46,7 @@ if __name__ == '__main__':
args = parser.parse_args() args = parser.parse_args()
recipes = Cookbook(args.data) recipes = satisfactory.Cookbook(args.data)
if args.target: if args.target:
graph_one(recipes, args.target) graph_one(recipes, args.target)

44
satisfactory/__init__.py Normal file
View File

@ -0,0 +1,44 @@
import os
import json
class Cookbook(object):
__recipes: dict
def __init__(self, root: str):
self.__recipes = dict()
for dirname, dirs, files in os.walk(root):
for f in files:
path = os.path.join(dirname, f)
name, _ = os.path.splitext(f)
with open(path, 'r') as src:
self.__recipes[name] = json.load(src)
def __getitem__(self, item: str):
return self.__recipes[item]
def all(self):
return self.__recipes.keys()
def recipes(self, name: str) -> dict:
return self.__recipes[name]['recipes']
def is_component(self, name):
return 'component' in self.__recipes[name]['type']
def is_resource(self, name):
return ''
def components(self):
found = set()
for _, descriptor in self.__recipes.items():
for variation in descriptor['recipes']:
for need, _ in variation['input'].items():
if need in found:
continue
found.add(need)
if not self.is_component(need):
continue
yield need