Skip to content

Commit

Permalink
bt constraints output: synchronise validator and statement defs
Browse files Browse the repository at this point in the history
  • Loading branch information
thorehusfeldt committed Oct 31, 2023
1 parent a7c6350 commit 7ec4b43
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion bin/constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,21 @@ def check_constraints(problem):
'{:^{width}}|{:^40}'.format('VALIDATORS', 'PROBLEM STATEMENT', width=left_width),
sep='',
)
for val, st in itertools.zip_longest(validator_defs, statement_defs):

while statement_defs or validator_defs:
#print(statement_defs, validator_defs)
if statement_defs:
# Display constraints in the order they appear in statement (statement_defs is thus ordered)
st = next(iter(statement_defs))
# Find a validator_def matching st, if there is one
val = min((d for d in validator_defs if len(d) == 3 and d[1] in st), default=None)
else:
# No statement_defs left? Just take the next validator_def
st = None
val = validator_defs[0]

if val is not None:
validator_defs.remove(val)
if isinstance(val, str):
print('{:^{width}}'.format(val, width=left_width), sep='', end='')
else:
Expand All @@ -280,6 +293,8 @@ def check_constraints(problem):
else:
print('{:^40}'.format(''), sep='', end='')
print()
if st is not None:
statement_defs.pop(st)

print()

Expand Down

0 comments on commit 7ec4b43

Please sign in to comment.