Improving assert error messages.

Signed-off-by: Tim 'mithro' Ansell <me@mith.ro>
This commit is contained in:
Tim 'mithro' Ansell 2018-12-10 10:49:19 -08:00
parent 3c64f302dd
commit adc20bcf89
1 changed files with 6 additions and 4 deletions

View File

@ -74,7 +74,8 @@ class Segmaker:
def set_def_bt(self, block_type):
'''Set default block type when more than one block present'''
assert block_type in BLOCK_TYPES
assert block_type in BLOCK_TYPES, (
"Unknown block type %r (known %r)" % (block_Type, BLOCK_TYPES))
self.def_bt = block_type
def load_grid(self):
@ -239,7 +240,7 @@ class Segmaker:
elif re.match(r"SLICE_X[0-9]*[13579]Y", site):
return "SLICE_X1"
else:
assert 0
assert False, "Invalid name in %s" % site
def name_bram18():
# RAMB18_X0Y41
@ -248,7 +249,7 @@ class Segmaker:
elif re.match(r"^RAMB18_X.*Y[0-9]*[13579]$", site):
return "RAMB18_Y1"
else:
assert 0
assert False, "Invalid name in %s" % site
def name_default():
# most sites are unique within their tile
@ -326,7 +327,8 @@ class Segmaker:
print("Tag tiles: %u" % (n_tile_tags, ))
print("Used %u sites" % len(sites_used))
print("Grid DB had %u tile types" % len(tile_types_found))
assert ntags == len(tags_used), "Unused tags"
assert ntags == len(tags_used), "Unused tags, %s used out of %s" % (
len(tag_used), ntags)
def write(self, suffix=None, roi=False, allow_empty=False):
assert self.segments_by_type, 'No data to write'