Merged in hotfix/file-errors (pull request #448)

Hotfix/file errors

* Set up test file

* Fix regex pattern in json.loads

*  bug fix No valid JSON object found in the input string

* bug fixes

* moved try statement to parse fn

* invalid literal for int() with base 10 error fixed

* remove test

* remove excess print statements

* Raise error

* Remove todo

* Remove print statement


Approved-by: Katon Minhas
This commit is contained in:
Mayank Aamseek
2025-03-19 22:11:27 +00:00
committed by Katon Minhas
parent 31b2936ae6
commit 138ac82fa2
6 changed files with 25 additions and 9 deletions
+4 -2
View File
@@ -226,13 +226,15 @@ def primary_string_to_dict(string_dict, filename):
def universal_json_load(string_dict):
"""Matches json dicts and list of dicts - NOT simple lists"""
match = re.search(r'\{.*\}|\[\{.*\}\]', string_dict, re.DOTALL)
match = re.search(r'\{.*\}|\[\s*?\{.*\}\s*?\]', string_dict, re.DOTALL) # Updated regex
if match:
try:
return json.loads(match.group())
except json.JSONDecodeError:
pass
raise ValueError("No valid JSON object found in the input string")
raise ValueError("No valid JSON object found in the input string")
else:
return {}
reimbursement_strings = [ # These are for `method='keyword'`
"%",