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

Method parse_calendar_xml

src/ifc4d/ifc4d/msp2ifc.py:125–209  ·  view source on GitHub ↗
(self, project)

Source from the content-addressed store, hash-verified

123 )
124
125 def parse_calendar_xml(self, project):
126 def parse_working_times(day):
127 working_times = []
128 if day.find("pr:WorkingTimes", self.ns):
129 for working_time in day.find("pr:WorkingTimes", self.ns).findall("pr:WorkingTime", self.ns):
130 if working_time.find("pr:FromTime", self.ns) is None:
131 continue
132 working_times.append(
133 {
134 "Start": datetime.time.fromisoformat(working_time.find("pr:FromTime", self.ns).text),
135 "Finish": datetime.time.fromisoformat(working_time.find("pr:ToTime", self.ns).text),
136 }
137 )
138 return working_times
139
140 def parse_exception(exception):
141 work_times = parse_working_times(exception)
142 time_period = exception.find("pr:TimePeriod", self.ns)
143 data = {
144 "Name": (
145 exception.find("pr:Name", self.ns).text if exception.find("pr:Name", self.ns) is not None else None
146 ),
147 "FromDate": (
148 datetime.datetime.fromisoformat(time_period.find("pr:FromDate", self.ns).text)
149 if time_period is not None
150 else None
151 ),
152 "ToDate": (
153 datetime.datetime.fromisoformat(time_period.find("pr:ToDate", self.ns).text)
154 if time_period is not None
155 else None
156 ),
157 "Occurrences": (
158 int(exception.find("pr:Occurrences", self.ns).text)
159 if exception.find("pr:Occurrences", self.ns) is not None
160 else None
161 ),
162 "Month": (
163 exception.find("pr:Month", self.ns).text
164 if exception.find("pr:Month", self.ns) is not None
165 else None
166 ),
167 "MonthDay": (
168 exception.find("pr:MonthDay", self.ns).text
169 if exception.find("pr:MonthDay", self.ns) is not None
170 else None
171 ),
172 "Type": (
173 exception.find("pr:Type", self.ns).text if exception.find("pr:Type", self.ns) is not None else None
174 ),
175 "WorkingTimes": work_times,
176 "ifc": None,
177 }
178 return data
179
180 for calendar in project.find("pr:Calendars", self.ns).findall("pr:Calendar", self.ns):
181 calendar_id = calendar.find("pr:UID", self.ns).text
182 week_days = []

Callers 1

parse_xmlMethod · 0.95

Calls 2

findMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected