File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -119,6 +119,13 @@ def _get_data(self, currency_code):
119119 currency_dict = next ((item for item in currency_data if item ["cc" ] == currency_code ), None )
120120 return currency_dict
121121
122+ def _get_data_from_symbol (self , symbol ):
123+ file_path = os .path .dirname (os .path .abspath (__file__ ))
124+ with open (file_path + '/raw_data/currencies.json' ) as f :
125+ currency_data = json .loads (f .read ())
126+ currency_dict = next ((item for item in currency_data if item ["symbol" ] == symbol ), None )
127+ return currency_dict
128+
122129 def get_symbol (self , currency_code ):
123130 currency_dict = self ._get_data (currency_code )
124131 if currency_dict :
@@ -131,6 +138,13 @@ def get_currency_name(self, currency_code):
131138 return currency_dict .get ('name' )
132139 return None
133140
141+ def get_currency_code_from_symbol (self , symbol ):
142+ currency_dict = self ._get_data_from_symbol (symbol )
143+ if currency_dict :
144+ return currency_dict .get ('cc' )
145+ return None
146+
147+
134148_CURRENCY_CODES = CurrencyCodes ()
135149
136150
You can’t perform that action at this time.
0 commit comments