1
1
import os
2
2
from decimal import Decimal
3
- import simplejson as json
3
+
4
4
import requests
5
+ import simplejson as json
5
6
6
7
7
8
class RatesNotAvailableError (Exception ):
@@ -45,7 +46,7 @@ def _get_decoded_rate(
45
46
self , response , dest_cur , use_decimal = False , date_str = None ):
46
47
return self ._decode_rates (
47
48
response , use_decimal = use_decimal , date_str = date_str ).get (
48
- dest_cur , None )
49
+ dest_cur , None )
49
50
50
51
51
52
class CurrencyRates (Common ):
@@ -102,7 +103,8 @@ def convert(self, base_cur, dest_cur, amount, date_obj=None):
102
103
converted_amount = rate * amount
103
104
return converted_amount
104
105
except TypeError :
105
- raise DecimalFloatMismatchError ("convert requires amount parameter is of type Decimal when force_decimal=True" )
106
+ raise DecimalFloatMismatchError (
107
+ "convert requires amount parameter is of type Decimal when force_decimal=True" )
106
108
raise RatesNotAvailableError ("Currency Rates Source Not Ready" )
107
109
108
110
@@ -120,7 +122,7 @@ def __init__(self):
120
122
121
123
def _get_data (self , currency_code ):
122
124
file_path = os .path .dirname (os .path .abspath (__file__ ))
123
- with open (file_path + '/raw_data/currencies.json' ) as f :
125
+ with open (file_path + '/raw_data/currencies.json' ) as f :
124
126
currency_data = json .loads (f .read ())
125
127
currency_dict = next ((item for item in currency_data if item ["cc" ] == currency_code ), None )
126
128
return currency_dict
@@ -153,7 +155,6 @@ def get_currency_code_from_symbol(self, symbol):
153
155
154
156
_CURRENCY_CODES = CurrencyCodes ()
155
157
156
-
157
158
get_symbol = _CURRENCY_CODES .get_symbol
158
159
get_currency_name = _CURRENCY_CODES .get_currency_name
159
160
get_currency_code_from_symbol = _CURRENCY_CODES .get_currency_code_from_symbol
0 commit comments