aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorw-e-w <40751091+w-e-w@users.noreply.github.com>2024-01-27 09:31:53 +0000
committerw-e-w <40751091+w-e-w@users.noreply.github.com>2024-01-27 12:55:52 +0000
commiteae0bb89fd0e0836098235540765d934c377d15c (patch)
tree09e983bf30cc8b405bdaf4263a740d5d3b847a98
parent36d1fefc19ecb7f1f8b11a8f3bc269be0a36de5e (diff)
downloadstable-diffusion-webui-gfx803-eae0bb89fd0e0836098235540765d934c377d15c.tar.gz
stable-diffusion-webui-gfx803-eae0bb89fd0e0836098235540765d934c377d15c.tar.bz2
stable-diffusion-webui-gfx803-eae0bb89fd0e0836098235540765d934c377d15c.zip
set_named_arg fuzzy option
-rw-r--r--modules/scripts.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/modules/scripts.py b/modules/scripts.py
index 4b38ca32..94690a22 100644
--- a/modules/scripts.py
+++ b/modules/scripts.py
@@ -939,13 +939,14 @@ class ScriptRunner:
except Exception:
errors.report(f"Error running setup: {script.filename}", exc_info=True)
- def set_named_arg(self, args, script_name, arg_elem_id, value):
+ def set_named_arg(self, args, script_name, arg_elem_id, value, fuzzy=False):
"""Locate an arg of a specific script in script_args and set its value
Args:
args: all script args of process p, p.script_args
script_name: the name target script name to
arg_elem_id: the elem_id of the target arg
value: the value to set
+ fuzzy: if True, arg_elem_id can be a substring of the control.elem_id else exact match
Returns:
Updated script args
when script_name in not found or arg_elem_id is not found in script controls, raise RuntimeError
@@ -955,7 +956,7 @@ class ScriptRunner:
raise RuntimeError(f"script {script_name} not found")
for i, control in enumerate(script.controls):
- if arg_elem_id == control.elem_id:
+ if arg_elem_id in control.elem_id if fuzzy else arg_elem_id == control.elem_id:
index = script.args_from + i
if isinstance(args, tuple):