universal_devkit.utils package¶
Submodules¶
universal_devkit.utils.utils module¶
-
universal_devkit.utils.utils.convert_list_to_dict(data_list: list, using_key: str)[source]¶ Converts a list of dictionaries to a dictionary using the value of a specific key in each object as the indentifier
-
universal_devkit.utils.utils.create_token()[source]¶ Generates a 32 character unique identifier
- Returns
unique identifier
- Return type
-
universal_devkit.utils.utils.get_closest_match(sorted_list, query_number)[source]¶ Source: https://stackoverflow.com/a/12141511
Parameters: - sorted_list: a sorted list of numbers to search through - query_number: the number to search for
Returns: The closest value in sorted_list to query_number. If two numbers are equally close, return the smallest number.
-
universal_devkit.utils.utils.get_existing_token(data_list, json_path, match_key, token_key)[source]¶ Takes a list of dictionaries and tries to assign the [token_key] value passed on matching existing data in the JSON file using the [match_key].
For example, you can use this to find the sensor tokens to use for the calibrated sensor data.
- Parameters
- Returns
updated list of dictionaries
- Return type
-
universal_devkit.utils.utils.get_file_extension(file_path: str)[source]¶ Gets the extension of a file.
Example:
>>> get_file_stem_name("/home/user/Downloads/repo/test.txt") "txt"
-
universal_devkit.utils.utils.get_file_stem_name(file_path: str)[source]¶ Gets the stem of a file path.
Example:
>>> get_file_stem_name("/home/user/Downloads/repo/test.txt") "test"
-
universal_devkit.utils.utils.get_full_path_to_file(root_data_dir: str, relative_file_path: str)[source]¶ Gets the path to a file given the path to the root data directory and a path relative to the root of the data directory
-
universal_devkit.utils.utils.get_immediate_directories(directory_path)[source]¶ Gets the immediate sub-directories within a directory
-
universal_devkit.utils.utils.get_timestamp(imu_dict)[source]¶ The timestamp of a message does not necessarily equal the timestamp in the message’s header. The header timestamp is more accurate and the timestamp of the message just corresponds to whenever the bag received the message and saved it.
-
universal_devkit.utils.utils.merge_json_lists(path_a, path_b)[source]¶ Merge two JSON files with lists