Skip to content

Commit

Permalink
fix test after SigMFCollection merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Teque5 committed Jan 13, 2025
1 parent a4b6c04 commit 5116a6c
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions sigmf/sigmffile.py
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,8 @@ def set_streams(self, metafiles) -> None:
for metafile in self.metafiles:
if metafile.endswith(".sigmf-meta") and Path.is_file(metafile):
stream = {
"name": get_sigmf_filenames(metafile)["base_fn"],
# name must be string here to be serializable later
"name": str(get_sigmf_filenames(metafile)["base_fn"]),
"hash": sigmf_hash.calculate_sha512(filename=metafile_path),
}
streams.append(stream)
Expand Down Expand Up @@ -1054,23 +1055,24 @@ def fromfile(filename, skip_checksum=False):
Parameters
----------
filename: str
filename: str | bytes | PathLike
Path for SigMF Metadata, Dataset, Archive or Collection (with or without extension).
skip_checksum: bool, default False
When True will not read entire dataset to caculate hash.
When True will not read entire dataset to calculate hash.
Returns
-------
object
SigMFFile object with dataset & metadata or a SigMFCollection depending on the type of file
SigMFFile with dataset & metadata or a SigMFCollection depending on file type.
"""
fns = get_sigmf_filenames(filename)
meta_fn = fns["meta_fn"]
archive_fn = fns["archive_fn"]
collection_fn = fns["collection_fn"]

# extract the extension to check whether we are dealing with an archive, collection, etc.
file_path, ext = Path.joinpath(Path(filename).parent,Path(filename).stem), Path(filename).suffix
file_path = Path(filename)
ext = file_path.suffix

if (ext.lower().endswith(SIGMF_ARCHIVE_EXT) or not Path.is_file(meta_fn)) and Path.is_file(archive_fn):
return fromarchive(archive_fn, skip_checksum=skip_checksum)
Expand All @@ -1082,7 +1084,7 @@ def fromfile(filename, skip_checksum=False):
metadata = json.load(mdfile_reader)
collection_fp.close()

dir_path = path.split(meta_fn)[0]
dir_path = meta_fn.parent
return SigMFCollection(metadata=metadata, base_path=dir_path, skip_checksums=skip_checksum)

else:
Expand Down

0 comments on commit 5116a6c

Please sign in to comment.