Skip to content

Commit e914959

Browse files
JKBTeque5
authored andcommitted
bugfix get_dataset_filename_from_metadata
1 parent e83a865 commit e914959

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

sigmf/sigmffile.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -932,12 +932,15 @@ 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-meta if it exists
935+
1. The file named <METAFILE_BASENAME>.sigmf-data if it exists
936936
2. The file in the `core:dataset` field (Non-Compliant Dataset) if it exists
937937
3. None (may be a metadata only distribution)
938938
"""
939939
compliant_data_fn = get_sigmf_filenames(meta_fn)["data_fn"]
940940
noncompliant_data_fn = metadata["global"].get("core:dataset", None)
941+
dir_path = path.split(meta_fn)[0]
942+
if not dir_path:
943+
dir_path = "." # sets the correct path in the case meta_fn is only a filename
941944

942945
if path.isfile(compliant_data_fn):
943946
if noncompliant_data_fn:
@@ -948,13 +951,14 @@ def get_dataset_filename_from_metadata(meta_fn, metadata=None):
948951
return compliant_data_fn
949952

950953
elif noncompliant_data_fn:
951-
if path.isfile(noncompliant_data_fn):
954+
noncompliant_data_file_path = f"{dir_path}/{noncompliant_data_fn}"
955+
if path.isfile(noncompliant_data_file_path):
952956
if metadata["global"].get("core:metadata_only", False):
953957
warnings.warn(
954-
'Schema defines "core:dataset" but "core:meatadata_only" '
958+
'Schema defines "core:dataset" but "core:metadata_only" '
955959
f"also exists; using `{noncompliant_data_fn}`"
956960
)
957-
return noncompliant_data_fn
961+
return noncompliant_data_file_path
958962
else:
959963
warnings.warn(
960964
f"Non-Compliant Dataset `{noncompliant_data_fn}` is specified " 'in "core:dataset" but does not exist!'

0 commit comments

Comments
 (0)