Skip to content

Commit

Permalink
base:py: Keep compatibly with Python 2 previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Hains committed Nov 10, 2023
1 parent 48bf9bd commit 118b2c0
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions plugin/controllers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
import os
import json
import six
from importlib.util import spec_from_file_location, module_from_spec
if six.PY3:
from importlib.util import spec_from_file_location, module_from_spec
else:
import imp

from twisted.web import server, http, resource
from twisted.web.resource import EncodingResourceWrapper
Expand Down Expand Up @@ -126,11 +129,11 @@ def load_source(self, module, pathname):
def loadTemplate(self, path, module, args):
template = None
if fileExists(getViewsPath(path + ".pyo")):
template = self.load_source(module, getViewsPath(path + ".pyo"))
template = self.load_source(module, getViewsPath(path + ".pyo")) if six.PY3 else imp.load_compiled(module, getViewsPath(path + ".pyo"))
elif fileExists(getViewsPath(path + ".pyc")):
template = self.load_source(module, getViewsPath(path + ".pyc"))
template = self.load_source(module, getViewsPath(path + ".pyc")) if six.PY3 else imp.load_compiled(module, getViewsPath(path + ".pyc"))
elif fileExists(getViewsPath(path + ".py")):
template = self.load_source(module, getViewsPath(path + ".py"))
template = self.load_source(module, getViewsPath(path + ".py")) if six.PY3 else imp.load_source(module, getViewsPath(path + ".py"))
if template:
mod = getattr(template, module, None)
if callable(mod):
Expand Down

0 comments on commit 118b2c0

Please sign in to comment.