Skip to content

Commit 772d52f

Browse files
committed
comments
1 parent 391c418 commit 772d52f

File tree

2 files changed

+3
-29
lines changed

2 files changed

+3
-29
lines changed

recordprocessor/src/batch_processor.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ def process_csv_to_fhir(incoming_message_body: dict) -> int:
2222
"""
2323
encoder = "utf-8" # default encoding
2424
try:
25-
# and encoder to the incoming message body
2625
incoming_message_body["encoder"] = encoder
2726
interim_message_body = file_level_validation(incoming_message_body=incoming_message_body)
2827
except (InvalidHeaders, NoOperationPermissions, Exception) as e: # pylint: disable=broad-exception-caught
@@ -77,14 +76,11 @@ def process_rows(file_id, vaccine, supplier, file_key, allowed_operations, creat
7776
row_id = f"{file_id}^{row_count}"
7877
logger.info("MESSAGE ID : %s", row_id)
7978
# Log progress every 1000 rows and the first 10 rows after a restart
80-
if (total_rows_processed_count % 1000 == 0):
79+
if total_rows_processed_count % 1000 == 0:
8180
logger.info(f"Process: {total_rows_processed_count+1}")
82-
if (start_row > 0 and row_count <= start_row+10):
81+
if start_row > 0 and row_count <= start_row+10:
8382
logger.info(f"Restarted Process (log up to first 10): {total_rows_processed_count+1}")
8483

85-
total_rows_processed_count += 1
86-
logger.info(f"Process row: {total_rows_processed_count}")
87-
8884
# Process the row to obtain the details needed for the message_body and ack file
8985
details_from_processing = process_row(target_disease, allowed_operations, row)
9086
# Create the message body for sending
@@ -97,6 +93,7 @@ def process_rows(file_id, vaccine, supplier, file_key, allowed_operations, creat
9793
**details_from_processing,
9894
}
9995
send_to_kinesis(supplier, outgoing_message_body, vaccine)
96+
total_rows_processed_count += 1
10097

10198
except Exception as error: # pylint: disable=broad-exception-caught
10299
# if error reason is 'invalid continuation byte', then it's a decode error

recordprocessor/tests/test_recordprocessor_edge_cases.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -150,26 +150,3 @@ def test_process_small_file_utf8(self):
150150
self.mock_logger_warning.assert_not_called()
151151
self.mock_logger_error.assert_not_called()
152152

153-
def test_fix_cp1252(self):
154-
# create a cp1252 string that contains an accented E
155-
# this is not a unit test as such but checks/confirms encoding assumptions
156-
source_text = b'D\xe9cembre'
157-
test_dict = {
158-
"date": source_text,
159-
"name": "Test Name"}
160-
utf8_dict = dict_decode(test_dict, "cp1252")
161-
self.assertEqual(utf8_dict["date"], "Décembre")
162-
self.assertEqual(utf8_dict["name"], "Test Name")
163-
164-
165-
def dict_decode(input_dict: dict, encoding: str) -> dict:
166-
"""
167-
Decode all byte strings in a dictionary to UTF-8 strings using the specified encoding.
168-
"""
169-
decoded_dict = {}
170-
for key, value in input_dict.items():
171-
if isinstance(value, bytes):
172-
decoded_dict[key] = value.decode(encoding)
173-
else:
174-
decoded_dict[key] = value
175-
return decoded_dict

0 commit comments

Comments
 (0)