Single direction field (combo or optional input); unique list IDs per node instance
This commit is contained in:
@@ -17,51 +17,19 @@ def _discover_directories():
|
||||
|
||||
candidates = set()
|
||||
|
||||
for root, dirs, files in os.walk(base_dir, followlinks=True):
|
||||
for root, dirs, _ in os.walk(base_dir, followlinks=True):
|
||||
rel = os.path.relpath(root, base_dir)
|
||||
if rel == ".":
|
||||
continue
|
||||
|
||||
dirs_lower = {d.lower() for d in dirs}
|
||||
|
||||
if VALID_DIRECTIONS & dirs_lower:
|
||||
candidates.add(rel)
|
||||
elif VALID_MODALITIES & dirs_lower:
|
||||
if VALID_DIRECTIONS & dirs_lower or VALID_MODALITIES & dirs_lower:
|
||||
candidates.add(rel)
|
||||
|
||||
return sorted(candidates)
|
||||
|
||||
|
||||
def _discover_children(parent_rel):
|
||||
base_dir = folder_paths.get_input_directory()
|
||||
if parent_rel:
|
||||
parent_abs = os.path.join(base_dir, parent_rel)
|
||||
else:
|
||||
parent_abs = base_dir
|
||||
|
||||
if not os.path.isdir(parent_abs):
|
||||
return []
|
||||
|
||||
children = set()
|
||||
try:
|
||||
for name in os.listdir(parent_abs):
|
||||
full = os.path.join(parent_abs, name)
|
||||
if os.path.isdir(full):
|
||||
rel = os.path.relpath(full, base_dir)
|
||||
children.add(rel)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
my_children = set()
|
||||
for child in children:
|
||||
child_parts = child.split("/")
|
||||
parent_parts = parent_rel.split("/") if parent_rel else []
|
||||
if len(child_parts) == len(parent_parts) + 1:
|
||||
my_children.add(child_parts[-1])
|
||||
|
||||
return sorted(my_children)
|
||||
|
||||
|
||||
def _resolve_target_dir(base_dir, directory, direction):
|
||||
if not directory or not (isinstance(directory, str) and directory.strip()):
|
||||
raise ValueError("directory must be a non-empty string")
|
||||
@@ -120,14 +88,17 @@ class CompassImageLoader:
|
||||
return {
|
||||
"required": {
|
||||
"directory": (directories if directories else ["(none found)"],),
|
||||
"direction": (["", "n", "ne", "e", "se", "s", "sw", "w", "nw"],),
|
||||
"direction": (
|
||||
["", "n", "ne", "e", "se", "s", "sw", "w", "nw"],
|
||||
{"default": ""},
|
||||
),
|
||||
"modality": (["image", "depth", "openpose"],),
|
||||
"frame": ("STRING", {"default": ""}),
|
||||
"width": ("INT", {"default": 0, "min": 0, "max": 16384, "step": 1}),
|
||||
"height": ("INT", {"default": 0, "min": 0, "max": 16384, "step": 1}),
|
||||
},
|
||||
"optional": {
|
||||
"direction_in": ("STRING", {"default": ""}),
|
||||
"direction_override": ("STRING", {"default": ""}),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -138,12 +109,12 @@ class CompassImageLoader:
|
||||
|
||||
def load_images(
|
||||
self, directory, direction, modality, frame=None, width=0, height=0,
|
||||
direction_in=None
|
||||
direction_override=None
|
||||
):
|
||||
if direction_in and direction_in.strip():
|
||||
resolved_direction = direction_in.strip()
|
||||
if direction_override is not None and str(direction_override).strip():
|
||||
resolved_direction = str(direction_override).strip()
|
||||
elif direction and direction.strip():
|
||||
resolved_direction = direction.strip()
|
||||
resolved_direction = str(direction).strip()
|
||||
else:
|
||||
resolved_direction = ""
|
||||
|
||||
@@ -198,14 +169,14 @@ class CompassImageLoader:
|
||||
@classmethod
|
||||
def IS_CHANGED(
|
||||
cls, directory, direction, modality, frame=None, width=0, height=0,
|
||||
direction_in=None
|
||||
direction_override=None
|
||||
):
|
||||
import hashlib
|
||||
|
||||
if direction_in and direction_in.strip():
|
||||
resolved_direction = direction_in.strip()
|
||||
if direction_override is not None and str(direction_override).strip():
|
||||
resolved_direction = str(direction_override).strip()
|
||||
elif direction and direction.strip():
|
||||
resolved_direction = direction.strip()
|
||||
resolved_direction = str(direction).strip()
|
||||
else:
|
||||
resolved_direction = ""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user