
utils.py
About this file
Few agency utilities functions are defined as follows:
Function get_active_users_as_choices() retrieves a list of tuples representing
users that are active for a given agency. Each tuple contains the following
elements:
(Users.guid, Users.name)
Function get_reasons() retrieves the determination reasons
(used in emails) for the specified agency as a JSON object.
If reason_type is provided, only retrieve determination_reasons of that type.
Function get_letter_templates() retrieves letter templates for the specified
agency as a dictionary. If template type is provided, only get
templates of that type.
Function _group_items() groups a collection of items by a specified key.
Code Check Report
app/agency/api/utils.py:50:17: E131 continuation line unaligned for hanging indent app/agency/api/utils.py:52:74: E711 comparison to None should be 'if cond is None:' app/agency/api/utils.py:54:17: E131 continuation line unaligned for hanging indent app/agency/api/utils.py:59:17: E131 continuation line unaligned for hanging indent app/agency/api/utils.py:59:82: E711 comparison to None should be 'if cond is None:' app/agency/api/utils.py:60:17: E131 continuation line unaligned for hanging indent app/agency/api/utils.py:98:17: E131 continuation line unaligned for hanging indent app/agency/api/utils.py:106:17: E131 continuation line unaligned for hanging indent app/agency/api/utils.py:128:1: W293 blank line contains whitespace app/agency/api/utils.py:132:1: W293 blank line contains whitespace app/agency/api/utils.py:139:14: W291 trailing whitespace
Documentation drawn from source code
get_active_users_as_choices(agency_ein: str) -> List[Tuple[str, str]]:
Retrieve a list of tuples representing users that are active for a given agency. Each tuple contains thefollowing elements:(Users.guid, Users.name)Params:agency_ein (str): Agency EIN (4 Character String)Returns:List(Tuple(str, str)): A list of tuples with the following elements:(Users.guid, Users.name)
get_reasons(agency_ein: str, reason_type: str = None) -> Dict:
Retrieve the determination reasons (used in emails) for the specified agency as a JSON object. If reason_type isprovided, only retrieve determination_reasons of that type.Args:agency_ein (str): Agency EINreason_type (str): One of ("denial", "closing", "re-opening")Returns:Dict:{type_', [(reason_id, reason_title),...]}
get_letter_templates(agency_ein: str, template_type: str = None) -> Dict:
Retrieve letter templates for the specified agency as a dictionary. If template type is provided, only gettemplates of that typeParams:Args:agency_ein (str): Agency EINreason_type (str): One of "acknowledgment", "denial", "closing", "letter", "extension", "re-openingReturns:Dict:{type_': [(template_id, template_name),...]}
_group_items(items: Sequence[Sequence], sort_index: int) -> Tuple[Any, list]:
Group a collection of items by a specified keyArgs:collections (Sequence): A collection of items to be groupedsort_index (int): Index of the item to use for groupingYields:tuple:(items[sort_index_1], (Sequence[i], Sequence[j], ...),items[sort_index_2], (Sequence[i], Sequence[j], ...),...)