Skip to content

Commit

Permalink
(RSM) clean up code, improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
mwe-sandag committed Apr 24, 2023
1 parent 8873cb2 commit fb23df5
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/main/emme/toolbox/import/import_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -777,13 +777,15 @@ def _create_base_net(self, data, network, mode_callback, centroid_callback, arc_
network_editor_yaml_file = FILE_NAMES["NETWORK_EDITS"]
network_editor_bool = False
network_editor_yaml_path = _join(self.source, network_editor_yaml_file)
self._log.append({"type": "header", "content": "__Network Edits"})
if os.path.exists(network_editor_yaml_path):
network_editor_bool = True
self._log.append({"type": "text", "content": "%s" % network_editor_yaml_path})
with open(network_editor_yaml_path, "r") as stream:
network_editor_data = yaml.safe_load(stream)
self._log.append({"type": "text", "content": "loaded YAML"})

self._log.append({"type": "text", "content": "Successfully loaded Network Edits YAML"})
self._log.append({"type": "text", "content": "\tYAML Path: %s" % network_editor_yaml_path})
else:
self._log.append({"type": "text", "content": "NO Network Edits YAML to load"})

# Create nodes and links
for arc in data:
Expand All @@ -807,15 +809,12 @@ def _create_base_net(self, data, network, mode_callback, centroid_callback, arc_
new_node_id += 1

#arc edits to raw_network
# if network_editor_bool:
if arc_id_name == "HWYCOV-ID":
for link_edits in network_editor_data.get('raw_network',[]):
if arc["HWYCOV-ID"] in link_edits.get("@tcov_id",[]):
#could explore using set_attribute_values() method in EMME API
try:
if network_editor_bool:
if arc_id_name == "HWYCOV-ID":
for link_edits in network_editor_data.get('raw_network',[]):
if arc["HWYCOV-ID"] in link_edits.get("@tcov_id",[]):
self._log.append({"type": "text", "content": "network edit descr: %s" % link_edits["descr"]})
arc[link_edits["attribute_to_edit"]] = link_edits["new_value"]
except KeyError:
setattr(arc, link_edits["attribute_to_edit"], link_edits["new_value"])

modes = mode_callback(arc)
link = network.create_link(i_node, j_node, modes)
Expand Down

0 comments on commit fb23df5

Please sign in to comment.