add new function

This commit is contained in:
nolan 2023-12-06 22:57:26 -08:00
parent f0d40e0a70
commit 70ed9f7f1a
2 changed files with 34 additions and 3 deletions

View File

@ -31,6 +31,7 @@ class AFCMUniverseMapFile:
self.mosaic_head = {} self.mosaic_head = {}
self.metadata = {} self.metadata = {}
self.mosaic_file_list = {} self.mosaic_file_list = {}
self.voterset_key = None
self.files = [] self.files = []
@ -105,7 +106,7 @@ class AFCMUniverseMapFile:
return data return data
def read_mosaic_map_dict( self, map_dict : dict ): def read_mosaic_map_dict( self, voterset_key : str, map_dict : dict ):
""" """
read_mosaic_map_dict read_mosaic_map_dict
""" """
@ -116,6 +117,7 @@ class AFCMUniverseMapFile:
self.mosaic_head = map_dict.get('mosaic', {}) self.mosaic_head = map_dict.get('mosaic', {})
self.metadata = map_dict.get('metadata', {}) self.metadata = map_dict.get('metadata', {})
self.mosaic_file_list = map_dict.get('files', {}) self.mosaic_file_list = map_dict.get('files', {})
self.voterset_key = voterset_key
return None return None
@ -314,7 +316,7 @@ class AFCMUniverseMapFile:
mapping[amplify_key]) mapping[amplify_key])
if new_row['UID'] is None or new_row['UID'] == 'n/a': if new_row['UID'] is None or new_row['UID'] == 'n/a':
new_row['UID'] = uuid.uuid4() new_row['UID'] = str(uuid.uuid4())
new_row['Cell_Phone'] = formatted_number new_row['Cell_Phone'] = formatted_number
@ -400,3 +402,32 @@ class AFCMUniverseMapFile:
self.voterset_s3_connection.put_object(bucket=self.voterset_s3_bucket, self.voterset_s3_connection.put_object(bucket=self.voterset_s3_bucket,
key=s3_key, key=s3_key,
data=json_data) data=json_data)
def get_voter_object(self) -> dict:
"""
get_voter_object Get the voter to the API object
:return Dictionary object of the AF-VOTER
"""
# Check if there is data
if len(self.final_rows) < 1:
return None
# Build the AF Voter object
voter_row = self.final_rows[0]
filter_set = {'UID', 'FName', 'LName', 'Cell_Phone'}
data_fields_dict = {k:voter_row[k] for k in voter_row if k not in filter_set}
voter_dict = {
"voter_id": voter_row['UID'],
"first_name": voter_row['FName'],
"last_name": voter_row['LName'],
"voterset_keys": [self.voterset_key],
"data_fields": data_fields_dict,
"cell_phone": voter_row['Cell_Phone']
}
return voter_dict

View File

@ -9,7 +9,7 @@ with open('README.md', 'r') as f:
setup( setup(
name='lib_afc_mosiac', name='lib_afc_mosiac',
version='0.1.3', version='0.1.4',
author='', author='',
author_email='', author_email='',
description='', description='',