Skip to content

Commit

Permalink
Fix usage of imp module in newer Python versions.
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Oct 27, 2015
1 parent 674cceb commit 9a97f71
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions project/settings.py
@@ -1,9 +1,19 @@
import imp
import os
import sys
import yaml

import django

if sys.version_info[:2] >= (3, 4):
import importlib
find_module = lambda c: importlib.machinery.PathFinder.find_spec(c)
elif sys.version_info[:2] >= (3, 1):
import importlib
find_module = lambda c: importlib.machinery.PathFinder.find_module(c)
else:
import imp
find_module = lambda c: imp.find_module(c)

# Path to here is something like
# .../<repo>/<project_name>/settings.py
PROJECT_DIR = os.path.abspath(os.path.dirname(__file__))
Expand Down Expand Up @@ -241,7 +251,7 @@
if MAPIT_COUNTRY:
try:
c = 'mapit_%s' % MAPIT_COUNTRY.lower()
imp.find_module(c)
find_module(c)
# Put before 'mapit', so country templates take precedence
INSTALLED_APPS.insert(INSTALLED_APPS.index('mapit'), c)
except:
Expand Down

0 comments on commit 9a97f71

Please sign in to comment.