Skip to content

Commit

Permalink
Outputter glow up
Browse files Browse the repository at this point in the history
  • Loading branch information
joshk0 committed Nov 22, 2023
1 parent d5519e2 commit db9f9ba
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions focus_validator/outputter/outputter_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,18 @@ def write(self, result_set: ValidationResult):
self.result_set = result_set

checklist = self.__restructure_check_list__(result_set)
print("Checklist:")
print(tabulate(checklist, headers="keys", showindex=False))

if result_set.failure_cases is not None:
aggregated_failures = result_set.failure_cases.groupby(
by=["Check Name", "Column", "Description"], as_index=False
by=["Check Name", "Description"], as_index=False
).aggregate(lambda x: collapse_occurrence_range(x.unique().tolist()))

print("Checks summary:")
print(
tabulate(
tabular_data=aggregated_failures, # type: ignore
headers="keys",
showindex=False,
maxcolwidths=60
)
)
print("Errors encountered:")
for _, fail in aggregated_failures.iterrows():
print(f'{fail["Check Name"]} failed:\n\tDescription: {fail["Description"]}\n\tRows: {fail["Row #"] if fail["Row #"] else "(whole file)"}\n\tExample values: {fail["Values"] if fail["Values"] else "(none)"}\n')
print("Validation failed!")
else:
print("Validation succeeded.")


def collapse_occurrence_range(occurrence_range: list):
Expand Down

0 comments on commit db9f9ba

Please sign in to comment.