Created
November 11, 2014 20:45
-
-
Save Deepwalker/bc2ecc16b83c2bb0d150 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import sys | |
| from importlib.machinery import ModuleSpec, SourceFileLoader | |
| pundles = dict([item.strip() for item in line.split(',')] for line in open('Pundlerfile').readlines()) | |
| class PundlerFinder(object): | |
| def find_spec(self, fullname, path, target_module): | |
| if path is not None: | |
| return None | |
| if fullname not in pundles: | |
| return None | |
| version = pundles[fullname] | |
| path = '{module}-{version}/{module}/__init__.py'.format(module=fullname, version=version) | |
| return ModuleSpec(fullname, SourceFileLoader(fullname, path), origin=path) | |
| sys.meta_path.insert(0, PundlerFinder()) | |
| import trafaret as t | |
| print(repr(t)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment