Skip to content

Commit fe838bd

Browse files
committed
Fix translation of days in Powerproject importer
1 parent 9dfd7e0 commit fe838bd

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

src/ifc4d/ifc4d/wpattern.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ def __init__(self, string, work_type_ids):
3434
}
3535
self.keys = self.get_keys(string)
3636
self.values = self.get_values(string)
37-
self.dict_wp = {}
3837
self.dict_wp = []
3938
for d, m in zip(self.values[1:], self.keys):
4039
splt_data = d.strip().split(",")
@@ -55,15 +54,17 @@ def __init__(self, string, work_type_ids):
5554
self.dict_wp.append({"DayOfWeek": m.replace('"', ""), "WorkTimes": workhours, "ifc": None})
5655

5756
# Translate day names to english
58-
for index, day in enumerate(self.Days["en"]):
59-
d = self.dict_wp[-1]["DayOfWeek"]
60-
for lang in self.Days.keys():
61-
if lang == "en":
62-
continue
63-
self.dict_wp[-1]["DayOfWeek"] = d.replace(self.Days[lang][index], self.Days["en"][index])
57+
def translate_days(days, wp):
58+
for index, day in enumerate(days["en"]):
59+
for lang in days.keys():
60+
if lang == "en":
61+
continue
62+
if wp["DayOfWeek"] == days[lang][index]:
63+
wp["DayOfWeek"] = days["en"][index]
64+
return
65+
translate_days(self.Days, self.dict_wp[-1])
6466

6567
for day in self.Days["en"]:
6668
if not len(list(filter(lambda d: d["DayOfWeek"] == day, self.dict_wp))) > 0:
6769
print("MISSING", day)
6870
self.dict_wp.append({"DayOfWeek": day, "WorkTimes": [], "ifc": None})
69-
print("final", self.dict_wp)

0 commit comments

Comments
 (0)