MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / cmd_run

Function cmd_run

src/ifcedit/ifcedit/__main__.py:91–118  ·  view source on GitHub ↗
(args, extra_args)

Source from the content-addressed store, hash-verified

89
90
91def cmd_run(args, extra_args):
92 try:
93 model = ifcopenshell.open(args.ifc_file)
94 except Exception as e:
95 print(f"Error: Could not open IFC file: {e}", file=sys.stderr)
96 sys.exit(1)
97
98 parts = args.function_path.split(".")
99 if len(parts) != 2:
100 print("Error: function path must be 'module.function' (e.g. root.create_entity)", file=sys.stderr)
101 sys.exit(1)
102 module, function = parts
103
104 # Parse extra --key value arguments into a dict
105 raw_kwargs = _parse_extra_args(extra_args)
106
107 if args.dry_run:
108 result = {"ok": True, "dry_run": True, "module": module, "function": function, "args": raw_kwargs}
109 else:
110 result = run_api(model, module, function, raw_kwargs)
111
112 if result["ok"]:
113 output_path = args.output or args.ifc_file
114 model.write(output_path)
115
116 print(format_output(result, args.output_format))
117 if not result["ok"]:
118 sys.exit(1)
119
120
121def _parse_extra_args(extra: list[str]) -> dict[str, str]:

Callers 1

mainFunction · 0.85

Calls 8

run_apiFunction · 0.90
printFunction · 0.85
_parse_extra_argsFunction · 0.85
openMethod · 0.80
splitMethod · 0.80
format_outputFunction · 0.70
exitMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected