You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

__init__.py 425B

1234567891011121314151617
  1. import sys
  2. class temporary_python_path(object):
  3. """
  4. Acts as a context manager to temporarily prepend a list of paths to
  5. sys.path
  6. """
  7. def __init__(self, paths):
  8. self.paths = paths
  9. def __enter__(self):
  10. self.original_paths = sys.path[:]
  11. sys.path = self.paths + self.original_paths
  12. def __exit__(self, exc_type, exc_value, traceback):
  13. sys.path = self.original_paths