add new functions

This commit is contained in:
nolan 2023-12-08 23:22:21 -08:00
parent cc5e509e7d
commit 2695ad5c69
2 changed files with 20 additions and 4 deletions

View File

@ -269,7 +269,7 @@ class AFCMUniverseMapFile:
# Evaluate this row has a valid phone number # Evaluate this row has a valid phone number
try: try:
parsed_number = phonenumbers.parse(cell_phone_num,'US') parsed_number = phonenumbers.parse(cell_phone_num,'US')
except Exception: # pylint: disable=broad-exception-caught except Exception: # pylint: disable=broad-except
r['afc_error'] = f"bad row #{i} in {voterset_filename}; reason='could not parse phone number'" r['afc_error'] = f"bad row #{i} in {voterset_filename}; reason='could not parse phone number'"
removed_rows.append(r) removed_rows.append(r)
if "could not parse phone number" in self.stats["removed_details"]: if "could not parse phone number" in self.stats["removed_details"]:
@ -369,7 +369,7 @@ class AFCMUniverseMapFile:
if len(amplify_rows) > 0: if len(amplify_rows) > 0:
try: try:
write_csv_file(prep_full_pathname, amplify_rows[0].keys(), amplify_rows) write_csv_file(prep_full_pathname, amplify_rows[0].keys(), amplify_rows)
except Exception as ex: except Exception as ex: # pylint: disable=broad-except
print(f"[WRITING {prep_file_name}] [{str(ex)}]") print(f"[WRITING {prep_file_name}] [{str(ex)}]")
# write S3 # write S3
@ -389,7 +389,7 @@ class AFCMUniverseMapFile:
if len(removed_rows) > 0: if len(removed_rows) > 0:
try: try:
write_csv_file(removed_full_pathname, removed_rows[0].keys(), removed_rows) write_csv_file(removed_full_pathname, removed_rows[0].keys(), removed_rows)
except Exception as ex: except Exception as ex: # pylint: disable=broad-except
print(f"[WRITING {removed_file_name}] [{str(ex)}]") print(f"[WRITING {removed_file_name}] [{str(ex)}]")
# write S3 # write S3
@ -430,6 +430,9 @@ class AFCMUniverseMapFile:
write_final_file Writes the final CSV to S3 write_final_file Writes the final CSV to S3
""" """
# Set the length of the final file
self.metadata["total_rows"] = len(self.final_rows)
# Need to write the FINAL file # Need to write the FINAL file
if len(self.final_rows) > 0: if len(self.final_rows) > 0:
final_filename = self.metadata.get('mosaic_filename', 'MOSAIC.csv') final_filename = self.metadata.get('mosaic_filename', 'MOSAIC.csv')
@ -460,6 +463,19 @@ class AFCMUniverseMapFile:
data=json_data) data=json_data)
def get_mosaic_map_dict(self) -> dict:
"""
get_mosaic_map_dict Generate the dictionary for the VoterSet mosaic map json
:return A generated dict
"""
return {
"mosaic": self.mosaic_head,
"metadata": self.metadata,
"files": self.mosaic_file_list
}
def get_voter_object(self) -> dict: def get_voter_object(self) -> dict:
""" """
get_voter_object Get the voter to the API object get_voter_object Get the voter to the API object

View File

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