catch load style.csv error

This commit is contained in:
w-e-w 2024-02-01 15:40:15 +09:00
parent 652a7bbf80
commit bbe8e02d74
1 changed files with 17 additions and 13 deletions

View File

@ -1,4 +1,5 @@
from pathlib import Path
from modules import errors
import csv
import os
import typing
@ -128,6 +129,7 @@ class StyleDatabase:
self.load_from_csv(styles_file)
def load_from_csv(self, path: str | Path):
try:
with open(path, "r", encoding="utf-8-sig", newline="") as file:
reader = csv.DictReader(file, skipinitialspace=True)
for row in reader:
@ -141,6 +143,8 @@ class StyleDatabase:
self.styles[row["name"]] = PromptStyle(
row["name"], prompt, negative_prompt, str(path)
)
except Exception:
errors.report(f'Error loading styles from {path}: ', exc_info=True)
def get_style_paths(self) -> set:
"""Returns a set of all distinct paths of files that styles are loaded from."""