Skip to content

Commit

Permalink
compatibility fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Psykopear committed Dec 1, 2016
1 parent 9da85c6 commit dad4515
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 16 deletions.
6 changes: 5 additions & 1 deletion djmoney_rates/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
from django.core.exceptions import ImproperlyConfigured
from django.utils import six

from .compat import urlopen
try:
from urllib2 import urlopen
except ImportError:
from urllib.request import urlopen

from .exceptions import RateBackendError
from .models import RateSource, Rate
from .settings import money_rates_settings
Expand Down
9 changes: 0 additions & 9 deletions djmoney_rates/compat.py

This file was deleted.

10 changes: 6 additions & 4 deletions djmoney_rates/management/commands/update_rates.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@


class Command(BaseCommand):
args = '<backend_path>'
help = 'Update rates for configured source'

def add_arguments(self, parser):
parser.add_argument('backend_path')

def handle(self, *args, **options):
if args:
if 'backend_path' in options and options['backend_path']:
try:
backend_class = import_from_string(args[0], "")
backend_class = import_from_string(options['backend_path'], "")
except ImportError:
raise CommandError("Cannot find custom backend %s. Is it correct" % args[0])
raise CommandError("Cannot find custom backend %s. Is it correct" % options['backend_path'])
else:
backend_class = money_rates_settings.DEFAULT_BACKEND

Expand Down
8 changes: 7 additions & 1 deletion djmoney_rates/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@
"""

from django.conf import settings
from django.utils import importlib, six

try:
from django.utils import importlib, six
except ImportError:
import importlib
import six


USER_SETTINGS = getattr(settings, 'DJANGO_MONEY_RATES', None)
Expand Down Expand Up @@ -105,4 +110,5 @@ def validate_setting(self, attr, val):
if not val and attr in self.mandatory:
raise AttributeError("django-money-rates setting: '%s' is mandatory" % attr)


money_rates_settings = MoneyRatesSettings(USER_SETTINGS, DEFAULTS, IMPORT_STRINGS, MANDATORY)
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ commands =
commands=python runtests.py
deps =
django18: Django==1.8.16
-rrequirements/testing.txt
virtualenv<14
-rrequirements-test.txt

[testenv:flake8]
deps =
Expand Down

0 comments on commit dad4515

Please sign in to comment.