Skip to content

Instantly share code, notes, and snippets.

@Deepwalker
Created November 11, 2014 20:45
Show Gist options
  • Select an option

  • Save Deepwalker/bc2ecc16b83c2bb0d150 to your computer and use it in GitHub Desktop.

Select an option

Save Deepwalker/bc2ecc16b83c2bb0d150 to your computer and use it in GitHub Desktop.
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