diff --git a/describe.py b/describe.py index b9cc3a3..1989616 100755 --- a/describe.py +++ b/describe.py @@ -9,5 +9,6 @@ if __name__ == '__main__': recipe_root = os.path.join(root, 'data', 'recipes') cookbook = satisfactory.Cookbook(recipe_root) - print(i for i in cookbook.resources()) + for i in cookbook.resources(): + print(i) diff --git a/satisfactory/__init__.py b/satisfactory/__init__.py index f5a4abc..348ccf1 100644 --- a/satisfactory/__init__.py +++ b/satisfactory/__init__.py @@ -26,19 +26,11 @@ class Cookbook(object): def is_component(self, name): return 'component' in self.__recipes[name]['type'] - def is_resource(self, name): - return '' - def components(self): - found = set() + return (i for i in self.all() if self.is_component(i)) - 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 + def is_resource(self, name): + return 'resource' in self.__recipes[name]['type'] + def resources(self): + return (i for i in self.all() if self.is_resource(i))