aboutsummaryrefslogtreecommitdiff
path: root/modules/paths.py
diff options
context:
space:
mode:
authorInvincibleDude <81354513+InvincibleDude@users.noreply.github.com>2023-01-24 15:44:09 +0300
committerGitHub <noreply@github.com>2023-01-24 15:44:09 +0300
commit44c0e6b993d00bb2f441f0fde409bcb79136f034 (patch)
treee27a45d1a3ceb8aab884631c7a806c5fe2c8386d /modules/paths.py
parent3bc8ee998db5f461b8011a72e6f167012ccb8bc1 (diff)
parent602a1864b05075ca4283986e6f5c7d5bce864e11 (diff)
Merge branch 'AUTOMATIC1111:master' into master
Diffstat (limited to 'modules/paths.py')
-rw-r--r--modules/paths.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/modules/paths.py b/modules/paths.py
index 4dd03a35..20b3e4d8 100644
--- a/modules/paths.py
+++ b/modules/paths.py
@@ -38,3 +38,17 @@ for d, must_exist, what, options in path_dirs:
else:
sys.path.append(d)
paths[what] = d
+
+
+class Prioritize:
+ def __init__(self, name):
+ self.name = name
+ self.path = None
+
+ def __enter__(self):
+ self.path = sys.path.copy()
+ sys.path = [paths[self.name]] + sys.path
+
+ def __exit__(self, exc_type, exc_val, exc_tb):
+ sys.path = self.path
+ self.path = None