validate() produces exception when extensions are indicated
gmabey opened this issue · 1 comments
gmabey commented
For this python script:
#!/usr/bin/env python3
import numpy
import sigmf
global_info = {
"core:author": "Glen M",
"core:datatype": "ri16_le",
"core:license": "https://creativecommons.org/licenses/by-sa/4.0/",
"core:sample_rate": 48000,
"core:version": "1.0.0",
"core:extensions" : [
{ "name": "extension-01",
"version": "0.0.5",
"optional": True },
{ "name": "extension-02",
"version": "1.2.3",
"optional": False }
]
}
capture_info = { "core:datetime": "2021-06-18T23:17:51.163959Z" }
base_filename = 'extensions_test'
meta_filename = base_filename + '.sigmf-meta'
data_filename = base_filename + '.sigmf-data'
numpy.arange(5, dtype=numpy.int16) .tofile(data_filename)
meta = sigmf.SigMFFile(data_file=data_filename, global_info=global_info)
meta.add_capture(0, metadata=capture_info)
meta.tofile(meta_filename, toarchive=True)
I get an exception thrown that I don't understand:
$ ./exercise_extensions.py
Traceback (most recent call last):
File "./exercise_extensions.py", line 29, in <module>
meta.tofile(meta_filename, toarchive=True)
File "/Users/glenm/src/SigMF/sigmf/sigmffile.py", line 545, in tofile
self.archive(fns['archive_fn'])
File "/Users/glenm/src/SigMF/sigmf/sigmffile.py", line 526, in archive
archive = SigMFArchive(self, name, fileobj)
File "/Users/glenm/src/SigMF/sigmf/archive.py", line 74, in __init__
self._check_input()
File "/Users/glenm/src/SigMF/sigmf/archive.py", line 111, in _check_input
self._validate_sigmffile_metadata()
File "/Users/glenm/src/SigMF/sigmf/archive.py", line 133, in _validate_sigmffile_metadata
valid_md = self.sigmffile.validate()
File "/Users/glenm/src/SigMF/sigmf/sigmffile.py", line 454, in validate
return validate.validate(
File "/Users/glenm/src/SigMF/sigmf/validate.py", line 154, in validate
for result in (validate_section(data.get(key), ref.get(key), key) for key in ref):
File "/Users/glenm/src/SigMF/sigmf/validate.py", line 154, in <genexpr>
for result in (validate_section(data.get(key), ref.get(key), key) for key in ref):
File "/Users/glenm/src/SigMF/sigmf/validate.py", line 145, in validate_section
return {
File "/Users/glenm/src/SigMF/sigmf/validate.py", line 108, in validate_section_dict
for result in key_validation_results:
File "/Users/glenm/src/SigMF/sigmf/validate.py", line 102, in <genexpr>
validate_key(
File "/Users/glenm/src/SigMF/sigmf/validate.py", line 78, in validate_key
if 'type' in ref_dict and not match_type(data_value, ref_dict["type"]):
File "/Users/glenm/src/SigMF/sigmf/validate.py", line 46, in match_type
return value is None or {
KeyError: 'dict_list'
which you may recognize, since I copy-pasted the "core:extensions" list from the explanation given in sigmf-spec.md
.
I plan to try to look into this error, but in the past validate()
has been tricky ...