satisfactory: Correct the generator typing for Cookbook
This commit is contained in:
parent
51001d66a5
commit
10a3438472
@ -1,7 +1,8 @@
|
|||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from typing import Dict, Generator
|
from typing import Dict, Generator, Iterable
|
||||||
|
|
||||||
|
|
||||||
class Cookbook(object):
|
class Cookbook(object):
|
||||||
__recipes: Dict[str, Dict]
|
__recipes: Dict[str, Dict]
|
||||||
@ -19,7 +20,7 @@ class Cookbook(object):
|
|||||||
def __getitem__(self, item: str) -> Dict[str, Dict]:
|
def __getitem__(self, item: str) -> Dict[str, Dict]:
|
||||||
return self.__recipes[item]
|
return self.__recipes[item]
|
||||||
|
|
||||||
def all(self):
|
def all(self) -> Iterable[str]:
|
||||||
return self.__recipes.keys()
|
return self.__recipes.keys()
|
||||||
|
|
||||||
def recipes(self, name: str) -> Dict:
|
def recipes(self, name: str) -> Dict:
|
||||||
@ -28,11 +29,11 @@ class Cookbook(object):
|
|||||||
def is_component(self, name: str) -> bool:
|
def is_component(self, name: str) -> bool:
|
||||||
return 'component' in self.__recipes[name]['type']
|
return 'component' in self.__recipes[name]['type']
|
||||||
|
|
||||||
def components(self) -> Generator[Dict, None, None]:
|
def components(self) -> Generator[str, None, None]:
|
||||||
return (i for i in self.all() if self.is_component(i))
|
return (i for i in self.all() if self.is_component(i))
|
||||||
|
|
||||||
def is_resource(self, name: str) -> bool:
|
def is_resource(self, name: str) -> bool:
|
||||||
return 'resource' in self.__recipes[name]['type']
|
return 'resource' in self.__recipes[name]['type']
|
||||||
|
|
||||||
def resources(self) -> Generator[Dict, None, None]:
|
def resources(self) -> Generator[str, None, None]:
|
||||||
return (i for i in self.all() if self.is_resource(i))
|
return (i for i in self.all() if self.is_resource(i))
|
||||||
|
Loading…
Reference in New Issue
Block a user