aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHåkon Solbjørg <hakon@solbj.org>2023-02-23 19:13:42 +0100
committerHåkon Solbjørg <hakon@solbj.org>2023-02-23 19:13:42 +0100
commit5c320ca37e9c8e682838896bea42879500754bbb (patch)
tree5641d5ad4ce0220b4802bbce06cda7bd9e566800
parentaf7e5a3b3be6e9ca82eef4b4e340b1c7e6ef6115 (diff)
chore(koblingsplan): Map a and b connection to objects
-rw-r--r--tools/koblingsplan/script.py38
1 files changed, 22 insertions, 16 deletions
diff --git a/tools/koblingsplan/script.py b/tools/koblingsplan/script.py
index 8fdc518..755d9bf 100644
--- a/tools/koblingsplan/script.py
+++ b/tools/koblingsplan/script.py
@@ -31,26 +31,32 @@ with open('tg23-koblingsplan.csv', newline='') as csvfile:
# The not-so-delicate blob of code for assigning data to object keys
current_iteration = {}
- current_iteration['a_type'] = row[0] if len(row[0].strip()) > 0 else prev_iteration['a_type']
- current_iteration['a_model'] = row[1] if len(row[1].strip()) > 0 else prev_iteration['a_model']
- current_iteration['a_node'] = row[2] if len(row[2].strip()) > 0 else prev_iteration['a_node']
- current_iteration['a_interface'] = row[3].strip() if len(row[3].strip()) > 0 else prev_iteration['a_interface']
- current_iteration['a_ae'] = row[4] if len(row[4].strip()) > 0 else prev_iteration['a_ae']
- current_iteration['b_type'] = row[5] if len(row[5].strip()) > 0 else prev_iteration['b_type']
- current_iteration['b_model'] = row[6] if len(row[6].strip()) > 0 else prev_iteration['b_model']
- current_iteration['b_node'] = row[7] if len(row[7].strip()) > 0 else prev_iteration['b_node']
- current_iteration['b_interface'] = row[8].strip() if len(row[8].strip()) > 0 else prev_iteration['b_interface']
- current_iteration['b_ae'] = row[9] if len(row[9].strip()) > 0 else prev_iteration['b_ae']
+ a = {}
+ b = {}
+
+ a['type'] = row[0] if len(row[0].strip()) > 0 else prev_iteration['a']['type']
+ a['model'] = row[1] if len(row[1].strip()) > 0 else prev_iteration['a']['model']
+ a['node'] = row[2] if len(row[2].strip()) > 0 else prev_iteration['a']['node']
+ a['interface'] = row[3].strip() if len(row[3].strip()) > 0 else prev_iteration['a']['interface']
+ a['ae'] = row[4] if len(row[4].strip()) > 0 else prev_iteration['a']['ae']
+ b['type'] = row[5] if len(row[5].strip()) > 0 else prev_iteration['b']['type']
+ b['model'] = row[6] if len(row[6].strip()) > 0 else prev_iteration['b']['model']
+ b['node'] = row[7] if len(row[7].strip()) > 0 else prev_iteration['b']['node']
+ b['interface'] = row[8].strip() if len(row[8].strip()) > 0 else prev_iteration['b']['interface']
+ b['ae'] = row[9] if len(row[9].strip()) > 0 else prev_iteration['b']['ae']
+
+ current_iteration['a'] = a
+ current_iteration['b'] = b
current_iteration['cable_type'] = row[10] if len(row[10].strip()) > 0 else prev_iteration['cable_type']
# strip trailing data from interface sections and put it in a description field
extra_info = ""
- if (if_data := current_iteration['a_interface'].split(" ")) and len(if_data) > 1:
- current_iteration['a_interface_description'] = " ".join(if_data[1:])
- current_iteration['a_interface'] = if_data[0]
- if (if_data := current_iteration['b_interface'].split(" ")) and len(if_data) > 1:
- current_iteration['b_interface_description'] = " ".join(if_data[1:])
- current_iteration['b_interface'] = if_data[0]
+ if (if_data := current_iteration['a']['interface'].split(" ")) and len(if_data) > 1:
+ current_iteration['a']['interface_description'] = " ".join(if_data[1:])
+ current_iteration['a']['interface'] = if_data[0]
+ if (if_data := current_iteration['b']['interface'].split(" ")) and len(if_data) > 1:
+ current_iteration['b']['interface_description'] = " ".join(if_data[1:])
+ current_iteration['b']['interface'] = if_data[0]
dataset.append(current_iteration)