ssb_tbmd_apis.exports package

ssb_tbmd_apis.exports.migrerdok module

deep_equal(elem1, elem2)

Recursively check equality between two elements, ignoring the order of lists.

Parameters:
  • elem1 (Any) – The first element to compare.

  • elem2 (Any) – The second element to compare.

Returns:

True if the elements are equal, otherwise False.

Return type:

bool

get_colnames_from_migrerdok(migrerdok)

Get column names from a migrerdok file.

Parameters:

migrerdok (Path) – Path to the migrerdok file.

Returns:

List of column names.

Return type:

list[str]

save_migrerdok_for_flatfile(flatfile, version_up=True, overwrite=False)

Save datadok contents to a file, and version up if needed.

Parameters:
  • flatfile (Path) – Path to the flatfile.

  • version_up (bool) – Whether to version up the file if it exists.

  • overwrite (bool) – Whether to overwrite the file if it exists.

Returns:

Path to the saved datadok file.

Return type:

Path

Raises:

OSError – If the file already exists, and overwrite is False.

ssb_tbmd_apis.exports.migrermetadb module

get_metadb_vars(varnames)

Get metadb variables from the API based on the provided variable names.

Parameters:

varnames (list[str]) – List of variable names to search for in the metadb.

Returns:

A dictionary where the keys are the variable names and the values are

the corresponding metadb codelists.

Return type:

dict

save_metadb_vars(varnames, outpath, overwrite=False)

Save metadb variables to a JSON file.

Parameters:
  • varnames (list[str]) – List of variable names to save.

  • outpath (Path) – Path to the output JSON file.

  • overwrite (bool) – Whether to overwrite the file if it exists.

Returns:

A dictionary where the keys are the variable names and the values are

the corresponding metadb codelists.

Return type:

dict

Raises:

OSError – If file already exists, and overwrite is not set to True.

ssb_tbmd_apis.exports.migrervar module

save_vardok_variables_belong_section(section, path, overwrite=False)

Save Vardok variables belonging to a section to a JSON file.

Parameters:
  • section (int) – The section number to filter variables by.

  • path (Path) – Path to the output JSON file.

  • overwrite (bool) – Whether to overwrite the file if it exists.

Returns:

A dictionary containing the variables belonging to the specified section.

Return type:

OrderedDict

Raises:

OSError – If the file already exists and overwrite is set to False.