Skip to content

Commit

Permalink
Add support for --wildcards-dir cmd argument
Browse files Browse the repository at this point in the history
Refactor PR #229 a bit to share code with this
  • Loading branch information
DominikDoom committed Sep 2, 2023
1 parent d4cca00 commit e23bb6d
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions scripts/shared_paths.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from pathlib import Path

from modules import scripts, shared

try:
Expand Down Expand Up @@ -33,6 +34,7 @@
except AttributeError:
LYCO_PATH = None


def find_ext_wildcard_paths():
"""Returns the path to the extension wildcards folder"""
found = list(EXT_PATH.glob("*/wildcards/"))
Expand All @@ -42,11 +44,15 @@ def find_ext_wildcard_paths():
except ImportError: # likely not in an a1111 context
opts = None

wildcard_dir = getattr(opts, "wildcard_dir", None)
if wildcard_dir is not None:
wildcard_dir = Path(wildcard_dir)
if wildcard_dir.exists():
found.append(wildcard_dir)
# Append custom wildcard paths
custom_paths = [
getattr(shared.cmd_opts, "wildcards_dir", None), # Cmd arg from the wildcard extension
getattr(opts, "wildcard_dir", None), # Custom path from sd-dynamic-prompts
]
for path in [Path(p) for p in custom_paths if p is not None]:
if path.exists():
found.append(path)

return found


Expand Down

0 comments on commit e23bb6d

Please sign in to comment.