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

Method parse

src/ifc5d/ifc5d/ifc5Dspreadsheet.py:336–380  ·  view source on GitHub ↗

Fill ``sheet_data`` from ``cost_schedules``.

(self)

Source from the content-addressed store, hash-verified

334 self.colours = self.default_colors.copy()
335
336 def parse(self) -> None:
337 """Fill ``sheet_data`` from ``cost_schedules``."""
338 self.sheet_data = {}
339 counter: Counter[str] = Counter()
340 for cost_schedule in self.cost_schedules:
341 sheet_id = cost_schedule.id()
342 cost_items = IfcDataGetter.get_schedule_cost_items_data(self.file, cost_schedule)
343 headers: list[str] = [
344 "Id",
345 "ItemIsASum",
346 "Hierarchy",
347 "Index",
348 "Identification",
349 "Name",
350 "Description",
351 "Unit",
352 ]
353 if cost_schedule.PredefinedType != "SCHEDULEOFRATES":
354 headers.insert(-1, "Quantities")
355 headers.insert(-1, "Quantity")
356 headers.extend(["RateSubtotal", "TotalPrice"])
357
358 # Handle cost categories.
359 categories: set[str] = set()
360 for cost_item in cost_items:
361 for category, value in cost_item["cost_categories"].items():
362 categories.add(category)
363 cost_item[category] = value
364 assert not (intersection := categories.intersection(headers)), intersection
365 headers.extend(categories)
366
367 schedule_name = cost_schedule.Name or "Unnamed"
368 counter[schedule_name] += 1
369 if (count := counter[schedule_name]) > 1:
370 schedule_name = f"{schedule_name}_{count - 1}"
371
372 self.sheet_data[sheet_id] = {
373 "Name": schedule_name,
374 "headers": headers,
375 "cost_items": cost_items,
376 "UpdateDate": IfcDataGetter.canonicalise_time(
377 ifcopenshell.util.date.ifc2datetime(cost_schedule.UpdateDate)
378 ),
379 "PredefinedType": cost_schedule.PredefinedType,
380 }
381
382 def multiply_cells(self, cell1, cell2):
383 return "={}*{}".format(cell1, cell2)

Callers 1

writeMethod · 0.95

Calls 9

intersectionMethod · 0.80
canonicalise_timeMethod · 0.80
setFunction · 0.50
idMethod · 0.45
insertMethod · 0.45
extendMethod · 0.45
itemsMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected