Skip to content

Commit

Permalink
(fix) Fixed the logic to get the full path to the ofac.json file
Browse files Browse the repository at this point in the history
  • Loading branch information
aarmoa committed Sep 23, 2024
1 parent 387b1fc commit c8ad358
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions pyinjective/ofac.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,17 @@
class OfacChecker:
def __init__(self):
self._ofac_list_path = self.get_ofac_list_path()
if not os.path.exists(self._ofac_list_path):
try:
with open(self._ofac_list_path, "r") as f:
self._ofac_list = set(json.load(f))
except Exception as e:
raise Exception(
"OFAC list is missing on the disk. Please, download it by running python3 pyinjective/ofac_list.py"
f"Error parsing OFAC list. Please, download it by running python3 pyinjective/ofac_list.py ({e})"
)

with open(self._ofac_list_path, "r") as f:
self._ofac_list = set(json.load(f))

@classmethod
def get_ofac_list_path(cls):
current_directory = os.getcwd()
while os.path.basename(current_directory) != "sdk-python":
current_directory = os.path.dirname(current_directory)
return os.path.join(os.path.join(current_directory, "pyinjective"), OFAC_LIST_FILENAME)
return os.path.join(os.path.dirname(__file__), OFAC_LIST_FILENAME)

@classmethod
async def download_ofac_list(cls):
Expand Down

0 comments on commit c8ad358

Please sign in to comment.