def read_nodes_file(self, nodes_file, screen_log): """ Read the nodes file and populate the node grid with Node objects """ fp_node_file = open(nodes_file, "r") lines = fp_node_file.readlines() fp_node_file.close() hash_regex = re.compile(r'^#') return_regex = re.compile(r'\n') for line in lines: node_name = "" x_pos = 0 y_pos = 0 if hash_regex.match(line) or return_regex.match(line): pass else: node_info = line.split(' ', 3) node_name = node_info[0] x_pos = node_info[1] y_pos = node_info[2] y_pos = y_pos.replace('\n', '') node = Node(screen_log) node.set_name(node_name) node.set_grid_location(x_pos, y_pos) self.node_table[node_name] = node
def add_new_node(self, node_name): """ Creates an empty Node object with the given name and adds it to the node list """ node = Node(self.screen_log) node.set_name(node_name) self.node_table[node_name] = node