From 8767dcbe43c247c1bde5331fb9bb74034f882caa Mon Sep 17 00:00:00 2001 From: NogaNHS Date: Mon, 2 Sep 2024 14:10:51 +0100 Subject: [PATCH] [PRMP-760] - format --- lambda/bulk-ods-update/bulk_ods_update.py | 20 +++++++++---------- .../event-enrichment/event_enrichment_main.py | 7 +++---- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/lambda/bulk-ods-update/bulk_ods_update.py b/lambda/bulk-ods-update/bulk_ods_update.py index daed7f0..35a29fb 100644 --- a/lambda/bulk-ods-update/bulk_ods_update.py +++ b/lambda/bulk-ods-update/bulk_ods_update.py @@ -1,8 +1,9 @@ +import calendar +import csv +import logging import os import tempfile from datetime import date, timedelta, datetime -import calendar -import csv import boto3 @@ -10,9 +11,6 @@ from utils.models.ods_models import PracticeOds, IcbOds from utils.services.ssm_service import SsmSecretManager from utils.services.trud_api_service import TrudApiService - -import logging - from utils.trud_files import ( GP_FILE_HEADERS, ICB_FILE_HEADERS, @@ -151,10 +149,10 @@ def extract_and_process_ods_icb_data(trud_service: TrudApiService): logger.info("Extracting and processing ODS ICB data") if icb_zip_file := trud_service.unzipping_files( - download_file, icb_zip_file_path, TEMP_DIR, True + download_file, icb_zip_file_path, TEMP_DIR, True ): if icb_csv_file := trud_service.unzipping_files( - icb_zip_file, icb_csv_file_name, TEMP_DIR + icb_zip_file, icb_csv_file_name, TEMP_DIR ): icb_ods_data = trud_csv_to_dict(icb_csv_file, ICB_FILE_HEADERS) icb_ods_data_amended_data = get_amended_records(icb_ods_data) @@ -201,7 +199,8 @@ def compare_and_overwrite(download_type: OdsDownloadType, data: list[dict]): PracticeOds.icb_ods_code.set(amended_record.get("IcbOdsCode")), ] ) - logger.info(f'Overwriting for ODS: {amended_record.get("PracticeOdsCode")} - Name: {amended_record.get("PracticeName")} | ICB: {amended_record.get("IcbOdsCode")}') + logger.info( + f'Overwriting for ODS: {amended_record.get("PracticeOdsCode")} - Name: {amended_record.get("PracticeName")} | ICB: {amended_record.get("IcbOdsCode")}') except Exception as e: logger.info( f"Failed to create/update record by Practice ODS code: {str(e)}" @@ -213,10 +212,11 @@ def compare_and_overwrite(download_type: OdsDownloadType, data: list[dict]): try: icb = IcbOds(amended_record.get("IcbOdsCode")) icb.update(actions=[IcbOds.icb_name.set(amended_record.get("IcbName"))]) - logger.info(f'Overwriting for ODS: {amended_record.get("IcbOdsCode")} - Name: {amended_record.get("IcbName")}') + logger.info( + f'Overwriting for ODS: {amended_record.get("IcbOdsCode")} - Name: {amended_record.get("IcbName")}') except Exception as e: logger.info(f"Failed to create/update record by ICB ODS code: {str(e)}") class UnableToGetReleaseDate(Exception): - pass \ No newline at end of file + pass diff --git a/lambda/event-enrichment/event_enrichment_main.py b/lambda/event-enrichment/event_enrichment_main.py index e61eb30..c87b669 100644 --- a/lambda/event-enrichment/event_enrichment_main.py +++ b/lambda/event-enrichment/event_enrichment_main.py @@ -281,7 +281,6 @@ def _publish_enriched_events_to_sns_topic(enriched_events: list): def _fetch_supplier_details(practice_ods_code: str) -> dict: - if not practice_ods_code or practice_ods_code.isspace(): return EMPTY_ORGANISATION @@ -315,9 +314,9 @@ def _fetch_supplier_details(practice_ods_code: str) -> dict: def _has_supplier_ods_code(extension: dict) -> bool: return ( - "SDS-ManufacturingOrganisation" in extension["url"] - and "ods-organization-code" - in extension["valueReference"]["identifier"]["system"] + "SDS-ManufacturingOrganisation" in extension["url"] + and "ods-organization-code" + in extension["valueReference"]["identifier"]["system"] )