|
2 | 2 | This module contains logic to convert EbdTable data to EbdGraph data. |
3 | 3 | """ |
4 | 4 |
|
| 5 | +import re |
5 | 6 | from typing import Dict, List, Literal, Optional, overload |
6 | 7 |
|
7 | 8 | from networkx import DiGraph, isolates # type:ignore[import-untyped] |
@@ -143,6 +144,15 @@ def _get_key_and_node_with_lowest_step_number(ebd_table: EbdTable) -> tuple[str, |
143 | 144 | return str(lowest_numeric_key), nodes[str(lowest_numeric_key)] |
144 | 145 |
|
145 | 146 |
|
| 147 | +def _notes_same_except_for_whitespace(note1: str | None, note2: str | None) -> bool: |
| 148 | + """ |
| 149 | + Checks if two notes are the same except for whitespace characters. |
| 150 | + """ |
| 151 | + if note1 is not None and note2 is not None: |
| 152 | + return re.sub(r"\s+", "", note1) == re.sub(r"\s+", "", note2) |
| 153 | + return note1 is None and note2 is None |
| 154 | + |
| 155 | + |
146 | 156 | def get_all_edges(table: EbdTable) -> List[EbdGraphEdge]: |
147 | 157 | """ |
148 | 158 | Returns a list with all edges from the given table. |
@@ -188,7 +198,9 @@ def get_all_edges(table: EbdTable) -> List[EbdGraphEdge]: |
188 | 198 | # check for ambiguous outcome nodes, i.e. A** with different notes |
189 | 199 | is_ambiguous_outcome_node = ( |
190 | 200 | outcome_node.result_code in outcome_nodes_duplicates |
191 | | - and outcome_nodes_duplicates[outcome_node.result_code].note != outcome_node.note |
| 201 | + and not _notes_same_except_for_whitespace( |
| 202 | + outcome_nodes_duplicates[outcome_node.result_code].note, outcome_node.note |
| 203 | + ) |
192 | 204 | ) |
193 | 205 |
|
194 | 206 | if not is_ambiguous_outcome_node: |
|
0 commit comments