ifcfm - move preset searching logic from ifcm to bonsai

So anyone using 'python -m ifcfm' will get more readable error for invalid presets.
This commit is contained in:
Andrej730
2024-11-06 17:17:15 +05:00
parent 9821c343ca
commit 19cbf6d140
2 changed files with 25 additions and 13 deletions
+4 -8
View File
@@ -36,13 +36,9 @@ class FMData:
cls.data["engine"] = cls.engine()
@classmethod
def engine(cls):
def engine(cls) -> list[tuple[str, str, str]]:
results = []
fm_dir = os.path.dirname(ifcfm.__file__)
for f in os.listdir(fm_dir):
if f.endswith(".py") and not f.startswith("_"):
preset = os.path.splitext(f)[0]
module = importlib.import_module(f"ifcfm.{preset}")
config = getattr(module, "config")
results.append((preset, config["name"], config["description"]))
presets = ifcfm.get_presets_configs()
for preset, config in presets.items():
results.append((preset, config["name"], config["description"]))
return results