Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Python2.6 support. #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
10 changes: 6 additions & 4 deletions exchange/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ def _get_cache_key(source_currency, target_currency):

def update_rates_cached():
rates = ExchangeRate.objects.all()
cache_map = {_get_cache_key(rate.source.code, rate.target.code): rate.rate
for rate in rates}
cache_map = dict(
((_get_cache_key(rate.source.code, rate.target.code), rate.rate)
for rate in rates)
)
cache.set_many(cache_map, timeout=CACHE_TIMEOUT)
local_cache.clear()
return cache_map
Expand All @@ -49,6 +51,6 @@ def get_rate_cached(source_currency, target_currency):


def get_rates_cached(args_list):
key_map = {_get_cache_key(*args): args for args in args_list}
key_map = dict(((_get_cache_key(*args), args) for args in args_list))
cache_map = cache.get_many(key_map.keys())
return {key_map[key]: cache_map.get(key) for key in key_map.keys()}
return dict(((key_map[key], cache_map.get(key)) for key in key_map.keys()))
8 changes: 4 additions & 4 deletions exchange/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,16 @@ def get_rates(currencies):
sources.append(source)
targets.append(target)
else:
rate_map = {c: None for c in currencies}
rate_map = dict(((c, None) for c in currencies))
sources = map(itemgetter(0), currencies)
targets = map(itemgetter(1), currencies)

rates = ExchangeRate.objects.filter(
source__code__in=sources,
target__code__in=targets).values_list(
'source__code',
'target__code',
'rate')
'source__code',
'target__code',
'rate')

for source, target, rate in rates:
key = (source, target)
Expand Down
2 changes: 2 additions & 0 deletions test_project/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'

OPENEXCHANGERATES_API_KEY = '<DUMMY_KEY>'

SECRET_KEY = '<DummySecret>'