Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions forex_python/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ def _get_data(self, currency_code):
currency_dict = next((item for item in currency_data if item["cc"] == currency_code), None)
return currency_dict

def _get_data_from_symbol(self, symbol):
file_path = os.path.dirname(os.path.abspath(__file__))
with open(file_path + '/raw_data/currencies.json') as f:
currency_data = json.loads(f.read())
currency_dict = next((item for item in currency_data if item["symbol"] == symbol), None)
return currency_dict

def get_symbol(self, currency_code):
currency_dict = self._get_data(currency_code)
if currency_dict:
Expand All @@ -131,6 +138,13 @@ def get_currency_name(self, currency_code):
return currency_dict.get('name')
return None

def get_currency_code_from_symbol(self, symbol):
currency_dict = self._get_data_from_symbol(symbol)
if currency_dict:
return currency_dict.get('cc')
return None


_CURRENCY_CODES = CurrencyCodes()


Expand Down