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

Function _format_ids

src/ifcquery/ifcquery/__main__.py:67–81  ·  view source on GitHub ↗

Extract 'id' fields from a list of dicts and return as comma-separated string. For dicts with a top-level 'elements' key (e.g. clash, relations output), extracts from that flat summary list rather than the nested structure.

(data)

Source from the content-addressed store, hash-verified

65
66
67def _format_ids(data) -> str:
68 """Extract 'id' fields from a list of dicts and return as comma-separated string.
69
70 For dicts with a top-level 'elements' key (e.g. clash, relations output),
71 extracts from that flat summary list rather than the nested structure.
72 """
73 if isinstance(data, list):
74 ids = [str(item["id"]) for item in data if isinstance(item, dict) and "id" in item]
75 return ",".join(ids)
76 if isinstance(data, dict):
77 if "elements" in data and isinstance(data["elements"], list):
78 return _format_ids(data["elements"])
79 if "id" in data:
80 return str(data["id"])
81 return ""
82
83
84def _format_text(data, indent: int = 0) -> str:

Callers 1

format_outputFunction · 0.85

Calls 1

joinMethod · 0.45

Tested by

no test coverage detected