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
d7d6e8cf
Commit
d7d6e8cf
authored
Jul 08, 2023
by
AUTOMATIC1111
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use natural sort for shared.walk_files and shared.listfiles, as well as for dirs in extra networks
parent
7a6abc59
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
6 deletions
+14
-6
extensions-builtin/Lora/lora.py
extensions-builtin/Lora/lora.py
+1
-1
modules/shared.py
modules/shared.py
+11
-3
modules/ui_extra_networks.py
modules/ui_extra_networks.py
+2
-2
No files found.
extensions-builtin/Lora/lora.py
View file @
d7d6e8cf
...
...
@@ -443,7 +443,7 @@ def list_available_loras():
os
.
makedirs
(
shared
.
cmd_opts
.
lora_dir
,
exist_ok
=
True
)
candidates
=
list
(
shared
.
walk_files
(
shared
.
cmd_opts
.
lora_dir
,
allowed_extensions
=
[
".pt"
,
".ckpt"
,
".safetensors"
]))
for
filename
in
sorted
(
candidates
,
key
=
str
.
lower
)
:
for
filename
in
candidates
:
if
os
.
path
.
isdir
(
filename
):
continue
...
...
modules/shared.py
View file @
d7d6e8cf
import
datetime
import
json
import
os
import
re
import
sys
import
threading
import
time
...
...
@@ -832,8 +833,12 @@ mem_mon = modules.memmon.MemUsageMonitor("MemMon", device, opts)
mem_mon
.
start
()
def
natural_sort_key
(
s
,
regex
=
re
.
compile
(
'([0-9]+)'
)):
return
[
int
(
text
)
if
text
.
isdigit
()
else
text
.
lower
()
for
text
in
regex
.
split
(
s
)]
def
listfiles
(
dirname
):
filenames
=
[
os
.
path
.
join
(
dirname
,
x
)
for
x
in
sorted
(
os
.
listdir
(
dirname
),
key
=
str
.
lower
)
if
not
x
.
startswith
(
"."
)]
filenames
=
[
os
.
path
.
join
(
dirname
,
x
)
for
x
in
sorted
(
os
.
listdir
(
dirname
),
key
=
natural_sort_key
)
if
not
x
.
startswith
(
"."
)]
return
[
file
for
file
in
filenames
if
os
.
path
.
isfile
(
file
)]
...
...
@@ -858,8 +863,11 @@ def walk_files(path, allowed_extensions=None):
if
allowed_extensions
is
not
None
:
allowed_extensions
=
set
(
allowed_extensions
)
for
root
,
_
,
files
in
os
.
walk
(
path
,
followlinks
=
True
):
for
filename
in
files
:
items
=
list
(
os
.
walk
(
path
,
followlinks
=
True
))
items
=
sorted
(
items
,
key
=
lambda
x
:
natural_sort_key
(
x
[
0
]))
for
root
,
_
,
files
in
items
:
for
filename
in
sorted
(
files
,
key
=
natural_sort_key
):
if
allowed_extensions
is
not
None
:
_
,
ext
=
os
.
path
.
splitext
(
filename
)
if
ext
not
in
allowed_extensions
:
...
...
modules/ui_extra_networks.py
View file @
d7d6e8cf
...
...
@@ -90,8 +90,8 @@ class ExtraNetworksPage:
subdirs
=
{}
for
parentdir
in
[
os
.
path
.
abspath
(
x
)
for
x
in
self
.
allowed_directories_for_previews
()]:
for
root
,
dirs
,
_
in
os
.
walk
(
parentdir
,
followlinks
=
True
):
for
dirname
in
dirs
:
for
root
,
dirs
,
_
in
sorted
(
os
.
walk
(
parentdir
,
followlinks
=
True
),
key
=
lambda
x
:
shared
.
natural_sort_key
(
x
[
0
])
):
for
dirname
in
sorted
(
dirs
,
key
=
shared
.
natural_sort_key
)
:
x
=
os
.
path
.
join
(
root
,
dirname
)
if
not
os
.
path
.
isdir
(
x
):
...
...
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