tsdf.legacy_tsdf_utils

Attributes

TSDB_TSDF_KEY_MAP

TSDB_ARRAY_KEYS

Functions

_rename_keys_in_metadata(→ Dict[str, Any])

This function renames the keys in a metadata file.

_convert_to_array(→ Dict[str, Any])

This function converts the value of a specified key in a dictionary to an array if it's not already an array.

convert_tsdb_to_tsdf(→ Dict[str, Any])

Converts a data from TSDB (legacy) to TSDF (0.1) format.

generate_tsdf_metadata_from_tsdb(→ None)

This function creates a metadata file (JSON) file in TSDF (0.1) format from a TSDB (legacy) file.

convert_file_tsdb_to_tsdf(→ None)

This function converts a metadata file (JSON) from TSDB (legacy) to TSDF (0.1) format. It overwrites the original file.

convert_files_tsdb_to_tsdf(→ None)

This function converts all metadata files in a directory (and its subdirectories) from TSDB (legacy) to TSDF (0.1) format.

Module Contents

tsdf.legacy_tsdf_utils.TSDB_TSDF_KEY_MAP
tsdf.legacy_tsdf_utils.TSDB_ARRAY_KEYS
tsdf.legacy_tsdf_utils._rename_keys_in_metadata(old_dict: Dict[str, Any]) Dict[str, Any][source]

This function renames the keys in a metadata file. If a key in the metadata matches a key in the provided dictionary, it is renamed to the corresponding value in the dictionary. It handles nested dictionaries and lists of dictionaries.

Parameters:

old_dict – The metadata file (dictionary) with keys to rename

Returns:

The updated metadata file (dictionary)

tsdf.legacy_tsdf_utils._convert_to_array(data: Dict[str, Any], key: str) Dict[str, Any][source]

This function converts the value of a specified key in a dictionary to an array if it’s not already an array. It handles nested dictionaries and lists of dictionaries.

Parameters:
  • data – The dictionary with a value to convert

  • key – The key in the dictionary whose value to convert

Returns:

The updated dictionary

tsdf.legacy_tsdf_utils.convert_tsdb_to_tsdf(data: Dict[str, Any]) Dict[str, Any][source]

Converts a data from TSDB (legacy) to TSDF (0.1) format.

Parameters:

data – The data in legacy (tsdb) format.

Returns:

The data in tsdf format.

tsdf.legacy_tsdf_utils.generate_tsdf_metadata_from_tsdb(filepath_existing: str, filepath_new: str) None[source]

This function creates a metadata file (JSON) file in TSDF (0.1) format from a TSDB (legacy) file.

Parameters:
  • filepath_existing – The path to the JSON file to process

  • filepath_new – The path to the new JSON file

tsdf.legacy_tsdf_utils.convert_file_tsdb_to_tsdf(filepath: str) None[source]

This function converts a metadata file (JSON) from TSDB (legacy) to TSDF (0.1) format. It overwrites the original file.

Parameters:

filepath – The path to the JSON file to process

tsdf.legacy_tsdf_utils.convert_files_tsdb_to_tsdf(directory: str) None[source]

This function converts all metadata files in a directory (and its subdirectories) from TSDB (legacy) to TSDF (0.1) format. It walks through all files in a directory (and its subdirectories), and processes all files with a .json extension.

Parameters:

directory – The directory to process files in