1
0
Fork 0
forked from github/pelican

Further remove python2-isms

This commit is contained in:
Deniz Turgut 2019-11-17 19:19:37 +03:00 committed by Kevin Yap
commit 49bc6ed47f
11 changed files with 35 additions and 91 deletions

View file

@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
import copy
import importlib.util
import inspect
import locale
import logging
@ -12,19 +13,11 @@ from posixpath import join as posix_join
from pelican.log import LimitFilter
try:
# spec_from_file_location is the recommended way in Python 3.5+
import importlib.util
def load_source(name, path):
spec = importlib.util.spec_from_file_location(name, path)
mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mod)
return mod
except ImportError:
# but it does not exist in Python 2.7, so fall back to imp
import imp
load_source = imp.load_source
def load_source(name, path):
spec = importlib.util.spec_from_file_location(name, path)
mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mod)
return mod
logger = logging.getLogger(__name__)