| 27 | |
| 28 | |
| 29 | class PP2Ifc: |
| 30 | wbs: dict[int, WBSEntry] |
| 31 | activities: dict[int, Activity] |
| 32 | |
| 33 | def __init__(self): |
| 34 | |
| 35 | self.pp = None |
| 36 | self.file = None |
| 37 | self.work_plan = None |
| 38 | self.project = {} |
| 39 | self.calendars = {} |
| 40 | self.wbs = {} |
| 41 | self.root_activites = [] |
| 42 | self.activities = {} |
| 43 | self.relationships = {} |
| 44 | self.resources = {} |
| 45 | self.output = None |
| 46 | |
| 47 | self.relationship_map = {0: "FINISH_START", 1: "FINISH_FINISH", 2: "START_START", 3: "START_FINISH"} |
| 48 | |
| 49 | def get_json(self, table_name: str) -> list[dict[str, Any]]: |
| 50 | self.cur.execute("select * from " + table_name) |
| 51 | r = [dict((self.cur.description[i][0], value) for i, value in enumerate(row)) for row in self.cur.fetchall()] |
| 52 | return r |
| 53 | |
| 54 | def get_json_with_filter(self, table_name: str, attr_name: str, attr_value: Any) -> list[dict[str, Any]]: |
| 55 | self.cur.execute("select * from " + table_name + " where " + attr_name + " = " + str(attr_value)) |
| 56 | r = [dict((self.cur.description[i][0], value) for i, value in enumerate(row)) for row in self.cur.fetchall()] |
| 57 | return r |
| 58 | |
| 59 | def execute(self) -> None: |
| 60 | self.con = sqlite3.connect(self.pp) |
| 61 | self.cur = self.con.cursor() |
| 62 | self.parse_pp() |
| 63 | settings = { |
| 64 | "work_plan": self.work_plan, |
| 65 | "project": self.project, |
| 66 | "calendars": self.calendars, |
| 67 | "wbs": self.wbs, |
| 68 | "root_activities": self.root_activites, |
| 69 | "activities": self.activities, |
| 70 | "relationships": self.relationships, |
| 71 | "resources": self.resources, |
| 72 | } |
| 73 | start = time.time() |
| 74 | ifcCreator = ScheduleIfcGenerator(self.file, self.output, settings) |
| 75 | end = time.time() |
| 76 | |
| 77 | ifcCreator.create_ifc() |
| 78 | end2 = time.time() |
| 79 | print("Parsing time is", end - start) |
| 80 | print("IFC Creation took", end2 - end) |
| 81 | print("Overall Time", end2 - start) |
| 82 | |
| 83 | def parse_pp(self) -> None: |
| 84 | project = self.get_json("PROJECT_SUMMARY")[0] |
| 85 | self.project["Name"] = project["SHORT_NAME"] |
| 86 | self.parse_calendar_pp() |
no outgoing calls
no test coverage detected