Last active
May 27, 2016 12:55
-
-
Save gdugas/46f18710a5fd43898d2f5ad843543fac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from importlib.machinery import PathFinder | |
import os | |
import sys | |
class PrefixedPathFinder: | |
pathes = { | |
"modload.plugins" : os.path.join(os.path.abspath(os.path.dirname(__file__))) | |
} | |
@classmethod | |
def find_spec(cls, name, import_path, target=None): | |
for prefix in cls.pathes: | |
if name.startswith(prefix): | |
print(name) | |
if name == prefix: | |
import_path = [cls.pathes[prefix]] | |
return PathFinder.find_spec(name, import_path, target=target) | |
return None | |
sys.meta_path.append(PrefixedPathFinder) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment