@contextlib.contextmanager
def fix_import_path(args):
 orig = list(sys.path)
 changes = []
 for arg in args:
  path = _get_python_path(arg)
  if (path in changes):
   continue
  else:
   changes.append(path)
 sys.path[:] = (changes + sys.path)
 try:
  (yield)
 finally:
  sys.path[:] = orig

@ contextlib . contextmanager def fix_import_path ( args ) : orig = list ( sys . path ) changes = [ ] for arg in args : path = _get_python_path ( arg ) if ( path in changes ) : continue else : changes . append ( path ) sys . path [ : ] = ( changes + sys . path ) try : ( yield ) finally : sys . path [ : ] = orig
prepare sys .