@@ -932,36 +932,36 @@ def get_dataset_filename_from_metadata(meta_fn, metadata=None):
932932 Parse provided metadata and return the expected data filename. In the case of
933933 a metadata only distribution, or if the file does not exist, this will return
934934 'None'. The priority for conflicting:
935- 1. The file named <METAFILE_BASENAME>.sigmf-data if it exists
936- 2. The file in the `core:dataset` field (Non-Compliant Dataset) if it exists
937- 3. None (may be a metadata only distribution)
935+ 1. The file named <METAFILE_BASENAME>.sigmf-data if it exists
936+ 2. The file in the `core:dataset` field (Non-Compliant Dataset) if it exists
937+ 3. None (may be a metadata only distribution)
938938 """
939- compliant_data_fn = get_sigmf_filenames (meta_fn )["data_fn" ]
940- noncompliant_data_fn = metadata ["global" ].get ("core:dataset" , None )
939+ compliant_filename = get_sigmf_filenames (meta_fn )["data_fn" ]
940+ noncompliant_filename = metadata ["global" ].get ("core:dataset" , None )
941941
942- if path .isfile (compliant_data_fn ):
943- if noncompliant_data_fn :
942+ if path .isfile (compliant_filename ):
943+ if noncompliant_filename :
944944 warnings .warn (
945- f"Compliant Dataset `{ compliant_data_fn } ` exists but "
946- f'"core:dataset" is also defined; using `{ compliant_data_fn } `'
945+ f"Compliant Dataset `{ compliant_filename } ` exists but "
946+ f" { SigMFFile . DATASET_KEY } is also defined; using `{ compliant_filename } `"
947947 )
948- return compliant_data_fn
948+ return compliant_filename
949949
950- elif noncompliant_data_fn :
950+ elif noncompliant_filename :
951951 dir_path = path .split (meta_fn )[0 ]
952- noncompliant_data_file_path = path .join (dir_path , noncompliant_data_fn )
952+ noncompliant_data_file_path = path .join (dir_path , noncompliant_filename )
953953 if path .isfile (noncompliant_data_file_path ):
954- if metadata ["global" ].get ("core:metadata_only" , False ):
955- warnings . warn (
956- ' Schema defines "core:dataset" but "core:metadata_only" '
957- f"also exists; using `{ noncompliant_data_fn } `"
954+ if metadata ["global" ].get (SigMFFile . METADATA_ONLY_KEY , False ):
955+ raise SigMFFileError (
956+ f" Schema defines { SigMFFile . DATASET_KEY } "
957+ f"but { SigMFFile . METADATA_ONLY_KEY } also exists; using `{ noncompliant_filename } `"
958958 )
959959 return noncompliant_data_file_path
960960 else :
961- warnings .warn (
962- f"Non-Compliant Dataset `{ noncompliant_data_fn } ` is specified " 'in "core:dataset" but does not exist!'
961+ raise SigMFFileError (
962+ f"Non-Compliant Dataset `{ noncompliant_filename } ` is specified in { SigMFFile .DATASET_KEY } "
963+ "but does not exist!"
963964 )
964-
965965 return None
966966
967967
0 commit comments