Handled exception with the yaml load
This commit is contained in:
@ -107,6 +107,8 @@ def extract_data_to_yaml(inputFileName):
|
|||||||
docs += "...\n"
|
docs += "...\n"
|
||||||
|
|
||||||
if reading == True and "Step" not in line:
|
if reading == True and "Step" not in line:
|
||||||
|
if "WARNING" in line:
|
||||||
|
continue
|
||||||
data = line.split()
|
data = line.split()
|
||||||
docs += " - ["
|
docs += " - ["
|
||||||
for field in enumerate(data):
|
for field in enumerate(data):
|
||||||
@ -115,7 +117,16 @@ def extract_data_to_yaml(inputFileName):
|
|||||||
|
|
||||||
# load the docs into a YAML data struture
|
# load the docs into a YAML data struture
|
||||||
#print(docs)
|
#print(docs)
|
||||||
thermo = list(yaml.load_all(docs, Loader=Loader))
|
try:
|
||||||
|
yaml_struct = yaml.load_all(docs, Loader=Loader)
|
||||||
|
thermo = list(yaml_struct)
|
||||||
|
except yaml.YAMLError as exc:
|
||||||
|
if hasattr(exc, 'problem_mark'):
|
||||||
|
mark = exc.problem_mark
|
||||||
|
print(f"Error parsing {inputFileName} at line {mark.line}, column {mark.column+1}.")
|
||||||
|
else:
|
||||||
|
print (f"Something went wrong while parsing {inputFileName}.")
|
||||||
|
print(docs)
|
||||||
return thermo
|
return thermo
|
||||||
|
|
||||||
'''
|
'''
|
||||||
@ -393,15 +404,18 @@ if __name__ == "__main__":
|
|||||||
configFileName = "config.yaml"
|
configFileName = "config.yaml"
|
||||||
example_subfolders = []
|
example_subfolders = []
|
||||||
genref = False
|
genref = False
|
||||||
|
verbose = False
|
||||||
|
|
||||||
# parse the arguments
|
# parse the arguments
|
||||||
parser = ArgumentParser()
|
parser = ArgumentParser()
|
||||||
parser.add_argument("--lmp-bin", dest="lmp_binary", default="", help="LAMMPS binary")
|
parser.add_argument("--lmp-bin", dest="lmp_binary", default="", help="LAMMPS binary")
|
||||||
parser.add_argument("--config-file", dest="config_file", default="config.yaml",
|
parser.add_argument("--config-file", dest="config_file", default="config.yaml",
|
||||||
help="Configuration YAML file")
|
help="Configuration YAML file")
|
||||||
parser.add_argument("--example-folders", dest="example_folders", default="", help="Example subfolders")
|
parser.add_argument("--example-folders", dest="example_folders", default="", help="Example subfolders")
|
||||||
parser.add_argument("--gen-ref",dest="genref", action='store_true', default=False,
|
parser.add_argument("--gen-ref",dest="genref", action='store_true', default=False,
|
||||||
help="Generating reference data")
|
help="Generating reference data")
|
||||||
|
parser.add_argument("--verbose",dest="verbose", action='store_true', default=True,
|
||||||
|
help="Verbose output")
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
@ -411,7 +425,8 @@ if __name__ == "__main__":
|
|||||||
example_subfolders = args.example_folders.split(';')
|
example_subfolders = args.example_folders.split(';')
|
||||||
print("Example folders:")
|
print("Example folders:")
|
||||||
print(example_subfolders)
|
print(example_subfolders)
|
||||||
genref = args.genref
|
genref = args.genref
|
||||||
|
verbose = args.verbose
|
||||||
|
|
||||||
# read in the configuration of the tests
|
# read in the configuration of the tests
|
||||||
with open(configFileName, 'r') as f:
|
with open(configFileName, 'r') as f:
|
||||||
@ -453,6 +468,10 @@ if __name__ == "__main__":
|
|||||||
# peptide thermo_style as multi
|
# peptide thermo_style as multi
|
||||||
#example_subfolders.append('../../examples/peptide')
|
#example_subfolders.append('../../examples/peptide')
|
||||||
|
|
||||||
|
if 'GRANULAR' in packages:
|
||||||
|
example_subfolders.append('../../examples/granular')
|
||||||
|
example_subfolders.append('../../examples/pour')
|
||||||
|
|
||||||
if 'AMOEBA' in packages:
|
if 'AMOEBA' in packages:
|
||||||
example_subfolders.append('../../examples/amoeba')
|
example_subfolders.append('../../examples/amoeba')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user