|
@@ -1,28 +1,28 @@
|
|
#!/usr/bin/env python3
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
+# read from standard input
|
|
import sys
|
|
import sys
|
|
-
|
|
|
|
stdin_list = []
|
|
stdin_list = []
|
|
for line in sys.stdin:
|
|
for line in sys.stdin:
|
|
stdin_list.append(line.rstrip())
|
|
stdin_list.append(line.rstrip())
|
|
|
|
|
|
-
|
|
|
|
|
|
+# function to replace a substring of a 'part' from each line of the 'gizmo notation'
|
|
def replace_substring_of_list_part(input_list, split_index, pattern, replace_str):
|
|
def replace_substring_of_list_part(input_list, split_index, pattern, replace_str):
|
|
|
|
+
|
|
|
|
+ # create a temporary list with the selected 'part'
|
|
working_list = []
|
|
working_list = []
|
|
for sub in input_list:
|
|
for sub in input_list:
|
|
working_list.append((sub.split(",")[split_index]))
|
|
working_list.append((sub.split(",")[split_index]))
|
|
|
|
|
|
|
|
+ # replace the patterns in the temporary list with the replacement strings
|
|
working_list = [sub.replace(pattern, replace_str) for sub in working_list]
|
|
working_list = [sub.replace(pattern, replace_str) for sub in working_list]
|
|
|
|
|
|
- final_list = []
|
|
|
|
- for list_item in input_list:
|
|
|
|
- final_list.append(list_item)
|
|
|
|
-
|
|
|
|
|
|
+ # replace the new 'part' segment in each line
|
|
output_list = []
|
|
output_list = []
|
|
|
|
+ seperator_string = ","
|
|
for i in range(len(input_list)):
|
|
for i in range(len(input_list)):
|
|
loop_list = input_list[i].split(",")
|
|
loop_list = input_list[i].split(",")
|
|
loop_list[split_index] = working_list[i]
|
|
loop_list[split_index] = working_list[i]
|
|
- seperator_string = ","
|
|
|
|
output_list.append(seperator_string.join(loop_list))
|
|
output_list.append(seperator_string.join(loop_list))
|
|
return output_list
|
|
return output_list
|
|
|
|
|