Allow calling ifcpatch from code with no arguments

This commit is contained in:
Dion Moult
2024-06-18 13:55:19 +10:00
parent ac0b5abfc5
commit bfd9cc0cf0
+3 -2
View File
@@ -76,10 +76,11 @@ def execute(args: dict) -> Union[ifcopenshell.file, str]:
logger = logging.getLogger("IFCPatch")
recipes = getattr(__import__("ifcpatch.recipes.{}".format(args["recipe"])), "recipes")
recipe = getattr(recipes, args["recipe"])
arguments = args.get("arguments", [])
if recipe.Patcher.__init__.__doc__ is not None:
patcher = recipe.Patcher(args.get("input"), args["file"], logger, *args["arguments"])
patcher = recipe.Patcher(args.get("input"), args["file"], logger, *arguments)
else:
patcher = recipe.Patcher(args.get("input"), args["file"], logger, args["arguments"])
patcher = recipe.Patcher(args.get("input"), args["file"], logger, arguments)
patcher.patch()
output = getattr(patcher, "file_patched", patcher.file)
return output