Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Stable Diffusion Webui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
novelai-storage
Stable Diffusion Webui
Commits
b594f518
Commit
b594f518
authored
Feb 01, 2024
by
AUTOMATIC1111
Committed by
GitHub
Feb 01, 2024
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14814 from AUTOMATIC1111/catch-load-style.csv-error
catch load style.csv error
parents
652a7bbf
bbe8e02d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
13 deletions
+17
-13
modules/styles.py
modules/styles.py
+17
-13
No files found.
modules/styles.py
View file @
b594f518
from
pathlib
import
Path
from
modules
import
errors
import
csv
import
os
import
typing
...
...
@@ -128,19 +129,22 @@ class StyleDatabase:
self
.
load_from_csv
(
styles_file
)
def
load_from_csv
(
self
,
path
:
str
|
Path
):
with
open
(
path
,
"r"
,
encoding
=
"utf-8-sig"
,
newline
=
""
)
as
file
:
reader
=
csv
.
DictReader
(
file
,
skipinitialspace
=
True
)
for
row
in
reader
:
# Ignore empty rows or rows starting with a comment
if
not
row
or
row
[
"name"
]
.
startswith
(
"#"
):
continue
# Support loading old CSV format with "name, text"-columns
prompt
=
row
[
"prompt"
]
if
"prompt"
in
row
else
row
[
"text"
]
negative_prompt
=
row
.
get
(
"negative_prompt"
,
""
)
# Add style to database
self
.
styles
[
row
[
"name"
]]
=
PromptStyle
(
row
[
"name"
],
prompt
,
negative_prompt
,
str
(
path
)
)
try
:
with
open
(
path
,
"r"
,
encoding
=
"utf-8-sig"
,
newline
=
""
)
as
file
:
reader
=
csv
.
DictReader
(
file
,
skipinitialspace
=
True
)
for
row
in
reader
:
# Ignore empty rows or rows starting with a comment
if
not
row
or
row
[
"name"
]
.
startswith
(
"#"
):
continue
# Support loading old CSV format with "name, text"-columns
prompt
=
row
[
"prompt"
]
if
"prompt"
in
row
else
row
[
"text"
]
negative_prompt
=
row
.
get
(
"negative_prompt"
,
""
)
# Add style to database
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."""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment