Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve quantity check #318

Merged
merged 1 commit into from
Dec 18, 2023
Merged

Improve quantity check #318

merged 1 commit into from
Dec 18, 2023

Conversation

erikbosch
Copy link
Collaborator

Give proper error if "definition" is not given and not any other attributes either.
(In that case v is NoneType som you cannot check for "definition")

Detected by COVESA/vehicle_signal_specification#526

Currently you get the output below if you have not added definition and no other attributes as well

erik@debian4:~/vss-tools/tests/vspec/test_units$ ../../../vspec2json.py --json-pretty  -u units_all.yaml -q quantities_no_def.yaml signals_with_special_units.vspec out.json
INFO     Output to json format
INFO     Known extended attributes: 
Traceback (most recent call last):
  File "/home/erik/vss-tools/tests/vspec/test_units/../../../vspec2json.py", line 19, in <module>
    vspec2x.main(["--format", "json"]+sys.argv[1:])
  File "/home/erik/vss-tools/vspec2x.py", line 158, in main
    vspec.load_quantities(args.vspec_file, args.quantity_file)
  File "/home/erik/vss-tools/vspec/__init__.py", line 883, in load_quantities
    nbr_quantities = VSSQuantityCollection.load_config_file(quantity_file)
  File "/home/erik/vss-tools/vspec/model/constants.py", line 232, in load_config_file
    if "definition" in v:
TypeError: argument of type 'NoneType' is not iterable

With this change you instead get:

erik@debian4:~/vss-tools/tests/vspec/test_units$ ../../../vspec2json.py --json-pretty  -u units_all.yaml -q quantities_no_def.yaml signals_with_special_units.vspec out.json
INFO     Output to json format
INFO     Known extended attributes: 
ERROR    No definition found for quantity volume

Give proper error if "definition" is not given and not any other
attributes either.
(In that case v is NoneType som you cannot check for "definition")

Signed-off-by: Erik Jaegervall <erik.jaegervall@se.bosch.com>
@erikbosch erikbosch merged commit cba9c71 into COVESA:master Dec 18, 2023
5 checks passed
@erikbosch erikbosch deleted the erik_quant branch December 18, 2023 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant