homes/common/.local/lib/python2.7/site-packages/powerline/matcher.py

20 lines
522 B
Python
Raw Normal View History

2013-05-02 18:11:33 +02:00
# vim:fileencoding=utf-8:noet
from __future__ import absolute_import
import sys
def gen_matcher_getter(ext, import_paths):
def get(match_name):
match_module, separator, match_function = match_name.rpartition('.')
if not separator:
match_module = 'powerline.matchers.{0}'.format(ext)
match_function = match_name
oldpath = sys.path
sys.path = import_paths + sys.path
try:
return getattr(__import__(match_module, fromlist=[match_function]), match_function)
finally:
sys.path = oldpath
return get