Skip to content

Commit

Permalink
Fixed Python 2 import handler
Browse files Browse the repository at this point in the history
  • Loading branch information
glitchassassin committed Dec 27, 2017
1 parent fed20e3 commit 3acb844
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
6 changes: 3 additions & 3 deletions coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 8 additions & 4 deletions lackey/ImportHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def find_spec(self, fullname, path, target=None):
return None # we don't know how to import this
sys.meta_path.append(SikuliFinder())
elif sys.version_info[0] == 2:
import importlib
import imp

class SikuliFinder(object):
def __init__(self, path):
Expand All @@ -45,8 +45,12 @@ def find_module(cls, name, path=None):

# Found what we're looking for. Add to path.
sys.path.append(sikuli_path)
return cls(sikuli_path)
return cls(filename)

def load_module(self, fullname):
return importlib.import_module(fullname, self.path)
def load_module(self, name):
if name in sys.modules:
return sys.modules[name]
with open(self.path, "r") as project:
mod = imp.load_module(name, project, self.path, (".py", "r", imp.PY_SOURCE))
return mod
sys.meta_path.append(SikuliFinder)

0 comments on commit 3acb844

Please sign in to comment.