parsedb: more verbose duplicate tag message

Signed-off-by: John McMaster <johndmcmaster@gmail.com>
This commit is contained in:
John McMaster 2018-11-13 14:38:26 -08:00
parent 0d0291e9e7
commit eb7c1cc589
1 changed files with 6 additions and 4 deletions

View File

@ -5,7 +5,7 @@ from prjxray import util
def run(fnin, fnout=None, strict=False, verbose=False):
lines = open(fnin, 'r').read().split('\n')
tags = set()
tags = dict()
bitss = set()
for line in lines:
line = line.strip()
@ -14,11 +14,13 @@ def run(fnin, fnout=None, strict=False, verbose=False):
tag, bits, mode = util.parse_db_line(line)
if strict:
assert not mode, "strict: got ill defined line: %s" % (line, )
assert tag not in tags, "strict: got duplicate tag %s (ex: %s)" % (
tag, line)
if tag in tags:
print("Original line: %s" % tags[tag])
print("New line: %s" % line)
assert 0, "strict: got duplicate tag %s" % (tag, )
assert bits not in bitss, "strict: got duplicate bits %s (ex: %s)" % (
bits, line)
tags.add(tag)
tags[tag] = line
bitss.add(bits)
if fnout: