Skip to content

Commit

Permalink
Merge pull request #304 from Orange-OpenSource/user_error_catching_im…
Browse files Browse the repository at this point in the history
…provment

Give more useful comment for user to correct topology
  • Loading branch information
jktjkt authored Dec 12, 2019
2 parents d483802 + 5e22590 commit 8598e65
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions gnpy/core/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from pathlib import Path
from difflib import get_close_matches
from gnpy.core.utils import silent_remove
from gnpy.core.exceptions import NetworkTopologyError
import time

all_rows = lambda sh, start=0: (sh.row(x) for x in range(start, sh.nrows))
Expand Down Expand Up @@ -509,9 +510,12 @@ def parse_excel(input_filename):
all_cities = Counter(n.city for n in nodes)
if len(all_cities) != len(nodes):
raise ValueError(f'Duplicate city: {all_cities}')
if any(ln.from_city not in all_cities or
ln.to_city not in all_cities for ln in links):
raise ValueError(f'Bad link.')
bad_links = []
for lnk in links:
if lnk.from_city not in all_cities or lnk.to_city not in all_cities:
bad_links.append([lnk.from_city, lnk.to_city])
if bad_links:
raise NetworkTopologyError(f'Bad link(s): {bad_links}.')

return nodes, links, eqpts

Expand Down

0 comments on commit 8598e65

Please sign in to comment.