Helpers¶
Shared utility functions for pykada.
Provides input validation helpers (require_non_empty_str(),
check_user_external_id(), verify_csv_columns()), random-string
generators, date/time format validators, and the
copy_docstring_from() decorator used to propagate docstrings from
client methods onto their functional wrapper equivalents.
- pykada.helpers.remove_null_fields(obj)[source]¶
Removes fields with a value of None from a dictionary. :type obj:
dict:param obj: :return: A dictionary with no values of None- Parameters:
obj (dict)
- pykada.helpers.require_non_empty_str(value, field_name, idx=None)[source]¶
Ensures that a value is a non-empty string.
- pykada.helpers.check_user_external_id(user_id=None, external_id=None)[source]¶
Check if only one of user_id or external_id are provided. Throw an error if neither or both are provided. The AC API requires exactly one of these identifiers.
- pykada.helpers.verify_csv_columns(file_path, expected_headers_list)[source]¶
Verifies that a CSV file exists and contains exactly the columns specified in expected_headers_list. Column order does not matter.
- Parameters:
- Raises:
FileNotFoundError – If the file does not exist.
ValueError – If expected_headers_list is empty, the file has no header row, or the columns do not match.
- Return type:
- pykada.helpers.generate_random_alphanumeric_string(length=16)[source]¶
Generate a random alphanumeric string of the specified length.
- pykada.helpers.generate_random_numeric_string(length=16)[source]¶
Generate a random numeric string of the specified length.
- pykada.helpers.is_valid_date(date_str)[source]¶
Validates that a date string is in YYYY-MM-DD format.