aboutsummaryrefslogtreecommitdiffstats
path: root/modules/scripts.py
diff options
context:
space:
mode:
authorAUTOMATIC <16777216c@gmail.com>2023-01-05 09:08:11 +0000
committerAUTOMATIC <16777216c@gmail.com>2023-01-05 09:08:11 +0000
commitf8d0cf6a6ec4911559cfecb9a9d1d46b547b38e8 (patch)
treee0072c8de53402a21020219880007252b1546508 /modules/scripts.py
parent997461d3dd86f51c06ea0c2eff17ce8b8b48c0af (diff)
downloadstable-diffusion-webui-gfx803-f8d0cf6a6ec4911559cfecb9a9d1d46b547b38e8.tar.gz
stable-diffusion-webui-gfx803-f8d0cf6a6ec4911559cfecb9a9d1d46b547b38e8.tar.bz2
stable-diffusion-webui-gfx803-f8d0cf6a6ec4911559cfecb9a9d1d46b547b38e8.zip
rework #6329 to remove duplicate code and add prevent tab names for showing in ids for scripts that only exist on one tab
Diffstat (limited to 'modules/scripts.py')
-rw-r--r--modules/scripts.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/modules/scripts.py b/modules/scripts.py
index 722f8685..0c44f191 100644
--- a/modules/scripts.py
+++ b/modules/scripts.py
@@ -1,4 +1,5 @@
import os
+import re
import sys
import traceback
from collections import namedtuple
@@ -128,6 +129,15 @@ class Script:
"""unused"""
return ""
+ def elem_id(self, item_id):
+ """helper function to generate id for a HTML element, constructs final id out of script name, tab and user-supplied item_id"""
+
+ need_tabname = self.show(True) == self.show(False)
+ tabname = ('img2img' if self.is_img2img else 'txt2txt') + "_" if need_tabname else ""
+ title = re.sub(r'[^a-z_0-9]', '', re.sub(r'\s', '_', self.title().lower()))
+
+ return f'script_{tabname}{title}_{item_id}'
+
current_basedir = paths.script_path