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

Method to_file

src/ifctester/ifctester/reporter.py:588–688  ·  view source on GitHub ↗
(self, filepath: str)

Source from the content-addressed store, hash-verified

586 return name
587
588 def to_file(self, filepath: str) -> None:
589 from odf.opendocument import OpenDocumentSpreadsheet
590 from odf.style import Style, TableCellProperties
591 from odf.table import Table, TableCell, TableRow
592 from odf.text import P
593
594 self.doc = OpenDocumentSpreadsheet()
595
596 self.cell_formats = {}
597 for key, value in self.colours.items():
598 style = Style(name=key, family="table-cell")
599 style.addElement(TableCellProperties(backgroundcolor="#" + value))
600 self.doc.automaticstyles.addElement(style)
601 self.cell_formats[key] = style
602
603 table = Table(name=self.excel_safe_spreadsheet_name(self.results["title"]))
604 tr = TableRow()
605 for header in ["Specification", "Status", "Total Pass", "Total Checks", "Percentage Pass"]:
606 tc = TableCell(valuetype="string", stylename="h")
607 tc.addElement(P(text=header))
608 tr.addElement(tc)
609 table.addElement(tr)
610
611 rows = []
612 for specification in self.results["specifications"]:
613 rows.append(
614 [
615 specification["name"],
616 "Pass" if specification["status"] else "Fail",
617 str(specification["total_checks_pass"]),
618 str(specification["total_checks"]),
619 str(specification["percent_checks_pass"]),
620 ]
621 )
622
623 for row in rows:
624 tr = TableRow()
625 c = 0
626 stylename = "p" if row[1] == "Pass" else "f"
627 for col in row:
628 tc = TableCell(valuetype="string", stylename=stylename)
629 if col is None:
630 col = "NULL"
631 tc.addElement(P(text=col))
632 tr.addElement(tc)
633 c += 1
634 table.addElement(tr)
635 self.doc.spreadsheet.addElement(table)
636
637 for specification in self.results["specifications"]:
638 if specification["status"]:
639 continue
640 table = Table(name=self.excel_safe_spreadsheet_name(specification["name"]))
641 tr = TableRow()
642 for header in [
643 "Requirement",
644 "Problem",
645 "Class",

Callers 1

execute_testerMethod · 0.95

Calls 7

StyleClass · 0.90
lowerMethod · 0.80
itemsMethod · 0.45
appendMethod · 0.45
getMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected