(self, project)
| 97 | self.parse_resources_xml(root) |
| 98 | |
| 99 | def parse_calendar_xml(self, project): |
| 100 | for calendar in project.findall("pr:Calendar", self.ns): |
| 101 | calendar_id = calendar.find("pr:ObjectId", self.ns).text |
| 102 | standard_work_week = [] |
| 103 | for standard_work_hour in calendar.find("pr:StandardWorkWeek", self.ns).findall( |
| 104 | "pr:StandardWorkHours", self.ns |
| 105 | ): |
| 106 | work_times = [] |
| 107 | for work_time in standard_work_hour.findall("pr:WorkTime", self.ns): |
| 108 | if work_time.find("pr:Start", self.ns) is None: |
| 109 | continue |
| 110 | work_times.append( |
| 111 | { |
| 112 | "Start": datetime.time.fromisoformat(work_time.find("pr:Start", self.ns).text), |
| 113 | "Finish": datetime.time.fromisoformat(work_time.find("pr:Finish", self.ns).text), |
| 114 | } |
| 115 | ) |
| 116 | standard_work_week.append( |
| 117 | { |
| 118 | "DayOfWeek": standard_work_hour.find("pr:DayOfWeek", self.ns).text, |
| 119 | "WorkTimes": work_times, |
| 120 | "ifc": None, |
| 121 | } |
| 122 | ) |
| 123 | exceptions = {} |
| 124 | holiday_or_exceptions = calendar.find("pr:HolidayOrExceptions", self.ns) |
| 125 | holiday_or_exception = [] |
| 126 | if holiday_or_exceptions is not None: |
| 127 | holiday_or_exception = holiday_or_exceptions.findall("pr:HolidayOrException", self.ns) |
| 128 | for exception in holiday_or_exception: |
| 129 | d = datetime.datetime.fromisoformat(exception.find("pr:Date", self.ns).text).date() |
| 130 | month = exceptions.setdefault(d.year, {}).setdefault(d.month, {}) |
| 131 | month.setdefault("FullDay", []) |
| 132 | month.setdefault("WorkTime", []) |
| 133 | work_times = [] |
| 134 | for work_time in exception.findall("pr:WorkTime", self.ns): |
| 135 | if work_time.find("pr:Start", self.ns) is None: |
| 136 | continue |
| 137 | work_times.append( |
| 138 | { |
| 139 | "Start": datetime.time.fromisoformat(work_time.find("pr:Start", self.ns).text), |
| 140 | "Finish": datetime.time.fromisoformat(work_time.find("pr:Finish", self.ns).text), |
| 141 | } |
| 142 | ) |
| 143 | if work_times: |
| 144 | exceptions[d.year][d.month]["WorkTime"].append({"Day": d.day, "WorkTimes": work_times, "ifc": None}) |
| 145 | else: |
| 146 | exceptions[d.year][d.month]["FullDay"].append(d.day) |
| 147 | self.calendars[calendar_id] = { |
| 148 | "Name": calendar.find("pr:Name", self.ns).text, |
| 149 | "Type": calendar.find("pr:Type", self.ns).text, |
| 150 | "HoursPerDay": calendar.find("pr:HoursPerDay", self.ns).text, |
| 151 | "StandardWorkWeek": standard_work_week, |
| 152 | "HolidayOrExceptions": exceptions, |
| 153 | } |
| 154 | |
| 155 | def parse_wbs_xml(self, project): |
| 156 | for wbs in project.findall("pr:WBS", self.ns): |
no test coverage detected