sigmf.sigmffile.SigMFCollection

class sigmf.sigmffile.SigMFCollection(metafiles: list = None, metadata: dict = None, base_path=None, skip_checksums: bool = False)

Bases: SigMFMetafile

Methods

dump

Write metadata to a file.

dumps

Get a string representation of the metadata.

get_SigMFFile

Returns the SigMFFile instance of the specified stream if it exists, or None.

get_collection_field

Return a field from the collection info, or default if the field is not set.

get_collection_info

Returns a dictionary with all the collection info.

get_stream_names

Returns a list of name object(s) from the collection level core:streams metadata.

ordered_metadata

Get a nicer representation of _metadata.

set_collection_field

Inserts a value into the collection field.

set_collection_info

Overwrite the collection info with a new dictionary.

set_streams

Configures the collection core:streams field from the specified list of metafiles.

tofile

Write metadata file

verify_stream_hashes

Compares the stream hashes in the collection metadata to the metadata files.

Attributes

AUTHOR_KEY

COLLECTION_DOI_KEY

COLLECTION_KEY

DESCRIPTION_KEY

EXTENSIONS_KEY

LICENSE_KEY

STREAMS_KEY

VALID_COLLECTION_KEYS

VALID_KEYS

VERSION_KEY

dump(filep, pretty=True)

Write metadata to a file.

Parameters:
  • filep (object) – File pointer or something that json.dump() can handle.

  • pretty (bool, default True) – When True will write more human-readable output, otherwise will be flat JSON.

dumps(pretty=True)

Get a string representation of the metadata.

Parameters:

pretty (bool, default True) – When True will write more human-readable output, otherwise will be flat JSON.

Returns:

String representation of the metadata using json formatter.

Return type:

string

get_SigMFFile(stream_name=None, stream_index=None)

Returns the SigMFFile instance of the specified stream if it exists, or None.

get_collection_field(key: str, default=None)

Return a field from the collection info, or default if the field is not set.

get_collection_info() dict

Returns a dictionary with all the collection info.

get_stream_names() list

Returns a list of name object(s) from the collection level core:streams metadata.

ordered_metadata()

Get a nicer representation of _metadata. Will sort keys, but put the top-level fields ‘global’, ‘captures’, ‘annotations’ in front.

Returns:

ordered_meta – Cleaner representation of _metadata with top-level keys correctly ordered and the rest of the keys sorted.

Return type:

OrderedDict

set_collection_field(key: str, value) None

Inserts a value into the collection field.

set_collection_info(new_collection: dict) None

Overwrite the collection info with a new dictionary.

set_streams(metafiles) None

Configures the collection core:streams field from the specified list of metafiles.

tofile(file_path, pretty: bool = True, overwrite: bool = False) None

Write metadata file

Parameters:
  • file_path (string) – Location to save.

  • pretty (bool, default True) – When True will write more human-readable output, otherwise will be flat JSON.

  • overwrite (bool, default False) – If False, raise exception if collection file already exists.

verify_stream_hashes() None

Compares the stream hashes in the collection metadata to the metadata files.

Raises:

SigMFFileError – If any dataset checksums do not match saved metadata.