mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2024-06-07 21:20:49 +00:00
fix save styles
This commit is contained in:
parent
f92d61497a
commit
23a0e60b9b
@ -155,10 +155,8 @@ class StyleDatabase:
|
|||||||
row["name"], prompt, negative_prompt, path
|
row["name"], prompt, negative_prompt, path
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_style_paths(self) -> list():
|
def get_style_paths(self) -> set:
|
||||||
"""
|
"""Returns a set of all distinct paths of files that styles are loaded from."""
|
||||||
Returns a list of all distinct paths, including the default path, of
|
|
||||||
files that styles are loaded from."""
|
|
||||||
# Update any styles without a path to the default path
|
# Update any styles without a path to the default path
|
||||||
for style in list(self.styles.values()):
|
for style in list(self.styles.values()):
|
||||||
if not style.path:
|
if not style.path:
|
||||||
@ -172,9 +170,9 @@ class StyleDatabase:
|
|||||||
style_paths.add(style.path)
|
style_paths.add(style.path)
|
||||||
|
|
||||||
# Remove any paths for styles that are just list dividers
|
# Remove any paths for styles that are just list dividers
|
||||||
style_paths.remove("do_not_save")
|
style_paths.discard("do_not_save")
|
||||||
|
|
||||||
return list(style_paths)
|
return style_paths
|
||||||
|
|
||||||
def get_style_prompts(self, styles):
|
def get_style_prompts(self, styles):
|
||||||
return [self.styles.get(x, self.no_style).prompt for x in styles]
|
return [self.styles.get(x, self.no_style).prompt for x in styles]
|
||||||
@ -196,20 +194,7 @@ class StyleDatabase:
|
|||||||
# The path argument is deprecated, but kept for backwards compatibility
|
# The path argument is deprecated, but kept for backwards compatibility
|
||||||
_ = path
|
_ = path
|
||||||
|
|
||||||
# Update any styles without a path to the default path
|
style_paths = self.get_style_paths()
|
||||||
for style in list(self.styles.values()):
|
|
||||||
if not style.path:
|
|
||||||
self.styles[style.name] = style._replace(path=self.default_path)
|
|
||||||
|
|
||||||
# Create a list of all distinct paths, including the default path
|
|
||||||
style_paths = set()
|
|
||||||
style_paths.add(self.default_path)
|
|
||||||
for _, style in self.styles.items():
|
|
||||||
if style.path:
|
|
||||||
style_paths.add(style.path)
|
|
||||||
|
|
||||||
# Remove any paths for styles that are just list dividers
|
|
||||||
style_paths.remove("do_not_save")
|
|
||||||
|
|
||||||
csv_names = [os.path.split(path)[1].lower() for path in style_paths]
|
csv_names = [os.path.split(path)[1].lower() for path in style_paths]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user