Helpers
- helpers.fetch_docstring_from_csv(unique_id: str)[source]
Fetch the docstring from a CSV file based on a unique identifier.
This function reads a CSV file and searches for a row where the ‘unique_id’ column matches the provided unique_id parameter. If a matching row is found, the function returns the value of the ‘docstring’ column from that row.
If the CSV file is not found, the function returns None.
- Args:
unique_id (str): The unique identifier to search for in the CSV file.
- Returns:
str or None: The docstring value from the matching row, or None if the file is not found or no matching row is found.
- helpers.generate_unique_id(file_path: str, func_name: str) str[source]
Generate a unique identifier for a function based on its file path and name.
This function takes the file path and function name as input, and generates a unique identifier using the MD5 hash of the concatenation of these two values. The resulting hash is returned as a hexadecimal string.
The purpose of this function is to provide a unique identifier for a function that can be used to track or reference the function, for example, in logging or monitoring systems.
- Args:
file_path (str): The full file path of the function. func_name (str): The name of the function.
- Returns:
str: A unique identifier for the function, based on its file path and name.
- helpers.is_function_processed(unique_id: str) bool[source]
Checks if a unique ID has been processed in a CSV file.
This function reads a CSV file and checks if the provided unique_id is present in any of the rows. If the file is not found, it returns False.
- Args:
unique_id (str): The unique identifier to search for in the CSV file.
- Returns:
bool: True if the unique_id is found in the CSV file, False otherwise.
- Raises:
FileNotFoundError: If the CSV file is not found.
- helpers.save_function_details(file_path: str, func_name: str, unique_id: str, docstring: str)[source]
Save function details to a CSV file.
This function takes the file path, function name, unique identifier, and function docstring as input, and writes them to a CSV file. If the file does not exist or is empty, it will add the CSV headers before writing the data.
- Args:
file_path (str): The file path where the function is defined. func_name (str): The name of the function. unique_id (str): A unique identifier for the function. docstring (str): The docstring of the function.
- Raises:
IOError: If there is an error writing to the CSV file.