aboutsummaryrefslogtreecommitdiff
path: root/modules/scripts.py
diff options
context:
space:
mode:
authorAarni Koskela <akx@iki.fi>2023-05-09 22:17:58 +0300
committerAarni Koskela <akx@iki.fi>2023-05-09 22:25:39 +0300
commit3ba6c3c83c0983a025c7bddc08bb7f49481b3cbb (patch)
tree77b2bea31c0e94ac67fddf86fdc7cba65a24af2c /modules/scripts.py
parent8fb16ceb288a93f6ecaa45a0afcb3db718333e3e (diff)
Fix up string formatting/concatenation to f-strings where feasible
Diffstat (limited to 'modules/scripts.py')
-rw-r--r--modules/scripts.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/modules/scripts.py b/modules/scripts.py
index 4d0bbd66..d945b89f 100644
--- a/modules/scripts.py
+++ b/modules/scripts.py
@@ -163,7 +163,8 @@ class Script:
"""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 ""
+ tabkind = 'img2img' if self.is_img2img else 'txt2txt'
+ tabname = f"{tabkind}_" 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}'
@@ -526,7 +527,7 @@ def add_classes_to_gradio_component(comp):
this adds gradio-* to the component for css styling (ie gradio-button to gr.Button), as well as some others
"""
- comp.elem_classes = ["gradio-" + comp.get_block_name(), *(comp.elem_classes or [])]
+ comp.elem_classes = [f"gradio-{comp.get_block_name()}", *(comp.elem_classes or [])]
if getattr(comp, 'multiselect', False):
comp.elem_classes.append('multiselect')