Sidecar¶
- class Sidecar(files, name=None)[source]
Contents of a JSON file or merged file.
Methods
|
Construct a Sidecar object representing a JSON file. |
Gather and validate definitions in metadata. |
|
Return this sidecar's column metadata as a string. |
|
Returns a list of column refs found in this sidecar. |
|
Returns the definition dict for this sidecar. |
|
Load column metadata from a given json file. |
|
Load json from a given file or list |
|
Save column metadata to a JSON file. |
|
|
Create a SidecarValidator and validate this sidecar with the schema. |
Attributes
Returns all columns that are HED compatible |
|
Generates the ColumnMetadata for this sidecar |
|
This is the definitions from this sidecar. |
- Sidecar.__init__(files, name=None)[source]¶
Construct a Sidecar object representing a JSON file.
- Parameters:
files (str or FileLike or list) – A string or file-like object representing a JSON file, or a list of such.
name (str or None) – Optional name identifying this sidecar, generally a filename.
- Sidecar.extract_definitions(hed_schema, error_handler=None)[source]¶
Gather and validate definitions in metadata.
- Parameters:
hed_schema (HedSchema) – The schema to used to identify tags.
error_handler (ErrorHandler or None) – The error handler to use for context, uses a default one if None.
- Returns:
Contains all the definitions located in the sidecar.
- Return type:
DefinitionDict
- Sidecar.get_as_json_string()[source]¶
Return this sidecar’s column metadata as a string.
- Returns:
The json string representing this sidecar.
- Return type:
str
- Sidecar.get_column_refs()[source]¶
Returns a list of column refs found in this sidecar.
This does not validate
- Returns:
A list of unique column refs found
- Return type:
column_refs(list)
- Sidecar.get_def_dict(hed_schema, extra_def_dicts=None)[source]¶
Returns the definition dict for this sidecar.
- Parameters:
hed_schema (HedSchema) – used to identify tags to find definitions
extra_def_dicts (list, DefinitionDict, or None) – Extra dicts to add to the list.
- Returns:
A single definition dict representing all the data(and extra def dicts)
- Return type:
DefinitionDict
- Sidecar.load_sidecar_file(file)[source]¶
Load column metadata from a given json file.
- Parameters:
file (str or FileLike) – If a string, this is a filename. Otherwise, it will be parsed as a file-like.
- Raises:
If the file was not found or could not be parsed into JSON.
- Sidecar.load_sidecar_files(files)[source]¶
Load json from a given file or list
- Parameters:
files (str or FileLike or list) – A string or file-like object representing a JSON file, or a list of such.
- Raises:
If the file was not found or could not be parsed into JSON.
- Sidecar.save_as_json(save_filename)[source]¶
Save column metadata to a JSON file.
- Parameters:
save_filename (str) – Path to save file
- Sidecar.validate(hed_schema, extra_def_dicts=None, name=None, error_handler=None)[source]¶
Create a SidecarValidator and validate this sidecar with the schema.
- Parameters:
hed_schema (HedSchema) – Input data to be validated.
extra_def_dicts (list or DefinitionDict) – Extra def dicts in addition to sidecar.
name (str) – The name to report this sidecar as.
error_handler (ErrorHandler) – Error context to use. Creates a new one if None.
- Returns:
A list of issues associated with each level in the HED string.
- Return type:
issues (list of dict)
- Sidecar.all_hed_columns¶
Returns all columns that are HED compatible
- Returns:
A list of all valid hed columns by name
- Return type:
column_refs(list)
- Sidecar.column_data¶
Generates the ColumnMetadata for this sidecar
- Returns:
ColumnMetadata}): the column metadata defined by this sidecar
- Return type:
dict({str
- Sidecar.def_dict¶
This is the definitions from this sidecar.
Generally you should instead call get_def_dict to get the relevant definitions
- Returns:
The definitions for this sidecar
- Return type:
DefinitionDict