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" ],
"input": { "circuit_board": 1, "quickwire": 18 },
"output": { "ai_limiter": 1 },
"machine": "assembler",
"crafting_time": 12,
"clicks": 3,
"stack_size": 100,
"requires": "caterium_electronics"
}
]
{
"type": [
"component"
],
"machine": "assembler",
"recipes": [
{
"input": {
"circuit_board": 1,
"quickwire": 18
},
"output": {
"ai_limiter": 1
},
"crafting_time": 12,
"clicks": 3,
"stack_size": 100,
"requires": "caterium_electronics"
}
]
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,10 +1,25 @@
[
{
"type": [ "machine" ],
"input": { "heavy_modular_frame": 2, "motor": 2, "cable": 25, "computer": 3 },
"output": { "manufacturer": 1 },
"machine": "_craft_bench",
"power_usage": 55,
"size": [ 20, 22, 12 ]
}
]
{
"type": [
"machine"
],
"machine": "_craft_bench",
"power_usage": 55,
"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" ],
"input": { "portable_miner": 1, "iron_rod": 5, "concrete": 5 },
"output": { "miner_mk1": 1 },
"is": "miner",
"machine": "_craft_bench",
"power_usage": 5,
"size": [ 8, 14, 18 ],
"requires": "hub_upgrade_4"
}
]
{
"type": [
"machine"
],
"is": "miner",
"machine": "_craft_bench",
"power_usage": 5,
"size": [
8,
14,
18
],
"recipes": [
{
"input": {
"portable_miner": 1,
"iron_rod": 5,
"concrete": 5
},
"output": {
"miner_mk1": 1
},
"requires": "hub_upgrade_4"
}
]
}

View File

@ -1,10 +1,24 @@
[
{
"type": [ "machine" ],
"input": { "heavy_modular_frame": 2, "motor": 3, "cable": 10 },
"output": { "oil_pump": 1 },
"machine": "_craft_bench",
"power_usage": 40,
"size": [ 8, 14, 20 ]
}
]
{
"type": [
"machine"
],
"machine": "_craft_bench",
"power_usage": 40,
"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" ],
"input": { "iron_plate": 4, "wire": 8, "cable": 4 },
"output": { "portable_miner": 1 },
"machine": "equipment_workshop",
"requires": "hub_upgrade_1"
}
]
{
"type": [
"machine",
"item"
],
"machine": "equipment_workshop",
"recipes": [
{
"input": {
"iron_plate": 4,
"wire": 8,
"cable": 4
},
"output": {
"portable_miner": 1
},
"requires": "hub_upgrade_1"
}
]
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,31 +1,12 @@
#!/usr/bin/env python3
import json
import typing
import os
import satisfactory
if __name__ == '__main__':
root = os.path.dirname(__file__)
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
import json
import satisfactory
import os
from typing import Iterable
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:
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]):
def graph(cookbook: satisfactory.Cookbook, targets: Iterable[str]):
print("digraph G {")
seen = set()
@ -51,7 +16,7 @@ def graph(recipes: dict, targets: Iterable[str]):
while remain:
output = remain.pop()
for need in recipes[output][0]['input']:
for need in cookbook.recipes(output)[0]['input']:
print(f"{need} -> {output}")
if need not in seen:
remain.add(need)
@ -81,7 +46,7 @@ if __name__ == '__main__':
args = parser.parse_args()
recipes = Cookbook(args.data)
recipes = satisfactory.Cookbook(args.data)
if 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