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

Function _parse_extra_args

src/ifcedit/ifcedit/__main__.py:121–139  ·  view source on GitHub ↗

Parse a list of ['--key', 'value', ...] into a dict.

(extra: list[str])

Source from the content-addressed store, hash-verified

119
120
121def _parse_extra_args(extra: list[str]) -> dict[str, str]:
122 """Parse a list of ['--key', 'value', ...] into a dict."""
123 kwargs = {}
124 i = 0
125 while i < len(extra):
126 arg = extra[i]
127 if arg.startswith("--"):
128 key = arg[2:]
129 if i + 1 < len(extra) and not extra[i + 1].startswith("--"):
130 kwargs[key] = extra[i + 1]
131 i += 2
132 else:
133 # Flag without value — treat as "true"
134 kwargs[key] = "true"
135 i += 1
136 else:
137 print(f"Error: Unexpected argument: {arg}", file=sys.stderr)
138 sys.exit(1)
139 return kwargs
140
141
142def cmd_foreach(args, extra_args):

Callers 2

cmd_runFunction · 0.85
cmd_foreachFunction · 0.85

Calls 2

printFunction · 0.85
exitMethod · 0.45

Tested by

no test coverage detected