getStationInitials corrected - now returns a list of initials as a technology...

getStationInitials corrected - now returns a list of initials as a technology can be performed at stations with different initials
parent 57fef693
......@@ -32,9 +32,11 @@ class ReadJSSkillsToStations(UpdateStationList.UpdateStationList):
for technology in technologyList:
tech = technology.split("-")[0]
for station in data["graph"]["node"]:
if station.startswith(self.getStationInitials(tech))\
and data["graph"]["node"][station]["_class"] in self.STATION_CLASS_SET:
stationList.append(station)
for initial in self.getStationInitials(tech):
if station.startswith(initial)\
and data["graph"]["node"][station]["_class"] in self.STATION_CLASS_SET:
stationList.append(station)
break
'''
the skillDict has the form of
{"load": {"stationIdList": []
......
......@@ -31,11 +31,12 @@ class UpdateStationList(plugin.InputPreparationPlugin):
def getStationInitials(self,technology):
'''get the stations that correspond to that technology'''
initialsList = []
for initials, corresponding_tech_list in self.getStationTechnologies().iteritems():
for tech in corresponding_tech_list:
if tech == technology:
return initials
return None
if tech == technology and not initials in initialsList:
initialsList.append(initials)
return initialsList
def getStationNames(self):
node = self.data["graph"]["node"]
......@@ -61,19 +62,20 @@ class UpdateStationList(plugin.InputPreparationPlugin):
for index, step in enumerate(route):
technology = step.get("technology", None)
technology = technology.split("-")[0]
assert self.getStationInitials(technology), 'there is no corresponding station initial for that technology'
assert len(self.getStationInitials(technology)), 'there is no corresponding station initial for that technology'
step["technology"] = technology
technologyStations = []
for station in stations:
if station.startswith(self.getStationInitials(technology))\
and data["graph"]["node"][station]["_class"] in self.STATION_CLASS_SET:
found = False # check that the id of the station provided by the db BOM exist in the nodes of the graph
for node in nodes.keys():
if node == station:
found = True
break
assert found == True, "the station ids in the DB must be the same with the stations ids provided by the model"
technologyStations.append(station)
for initials in self.getStationInitials(technology):
if station.startswith(initials)\
and data["graph"]["node"][station]["_class"] in self.STATION_CLASS_SET:
found = False # check that the id of the station provided by the db BOM exist in the nodes of the graph
for node in nodes.keys():
if node == station:
found = True
break
assert found == True, "the station ids in the DB must be the same with the stations ids provided by the model"
technologyStations.append(station)
assert len(technologyStations)>0, "the stations corresponding to the defined technology must be more than 0"
step["stationIdsList"] = technologyStations
return data
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment