fix: Raise ValueError when check_names detects overlong names

ValueError may not be the correct type?

Closes #679
This commit is contained in:
Ray Walker 2022-06-16 10:39:05 +10:00
parent 6c63c6aed8
commit 35e5ffaf85
No known key found for this signature in database
GPG Key ID: 2347427534009BA1
1 changed files with 13 additions and 5 deletions

View File

@ -84,13 +84,21 @@ def main(dirs, prefix_length=None):
source_just = max(len(k) for k in MOD_LIMITS)
name_just = max(len(n.name) for n in names)
value_just = max(len(n.value) for n in names)
errors = []
for name in names:
name_length = name.length + prefix_length
flag = '' if name_length >= MOD_LIMITS[name.source] else ''
print(f'[{flag}] {name.source.ljust(source_just)} '
f'{name.name.ljust(name_just)} '
f'{name.value.ljust(value_just)} '
f'({name_length})')
if name_length >= MOD_LIMITS[name.source]:
flag = ""
errors += [f"{name.source}:{name.name}:{name_length}"]
else:
flag = ""
print(f"[{flag}] {name.source.ljust(source_just)} "
f"{name.name.ljust(name_just)} "
f"{name.value.ljust(value_just)} "
f"({name_length})")
if errors:
raise ValueError(errors)
if __name__ == '__main__':