Skip to content

Commit

Permalink
Improve validation error
Browse files Browse the repository at this point in the history
  • Loading branch information
forsyth2 committed Oct 5, 2022
1 parent 5370a52 commit 8254cfa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 3 additions & 3 deletions tests/integration/template_complete_run.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ www = "#expand user_www#zppy_test_complete_run_www"
[climo]
active = True
walltime = "00:30:00"
years = "1850:1854:2", "1850:1854:4",
years = "1850:1854:2", "1850:1854:4"

[[ atm_monthly_180x360_aave ]]
frequency = "monthly"
Expand All @@ -25,9 +25,9 @@ years = "1850:1854:2", "1850:1854:4",
vars = "PRECT"

[ts]
active = True
active = 4
walltime = "00:30:00"
years = "1850:1854:2",
years = "1850:1854:2"

[[ atm_monthly_180x360_aave ]]
frequency = "monthly"
Expand Down
7 changes: 6 additions & 1 deletion zppy/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import argparse
import errno
import os
import pprint
from typing import List

from configobj import ConfigObj
Expand Down Expand Up @@ -167,8 +168,12 @@ def _validate_config(config):
validator = Validator()

result = config.validate(validator)
print(type(result))
if result is not True:
print("Validation results={}".format(result))
printer = pprint.PrettyPrinter(depth=3)
print("Validation results:")
printer.pprint(result)
# print("Validation results={}".format(result))
raise ValueError(
"Configuration file validation failed. Parameters listed as false in the validation results have invalid values."
)
Expand Down

0 comments on commit 8254cfa

Please sign in to comment.