Update strip iteration suffix behavior
This commit is contained in:
@@ -29,7 +29,7 @@
|
||||
- `Dumas Strip Iteration Suffix`
|
||||
- Input: `filename`
|
||||
- Output: cleaned `STRING`
|
||||
- Removes a trailing `_<digits>` iteration suffix before the file extension, for example `asset_003.png -> asset.png`.
|
||||
- Removes the final underscore segment before the file extension, for example `asset_003.png -> asset.png` and `char123_pose.png -> char123.png`.
|
||||
|
||||
- `Dumas Slugify String`
|
||||
- Input: `text`
|
||||
@@ -170,7 +170,7 @@ decr -> use index - 1
|
||||
|
||||
`Save Image Dumas` leaves `folder` empty to use ComfyUI's output directory. `name` feeds `%input%` and `name_2` feeds `%input2%`, so a pattern like `project/%input%_%input2%_%counter%` can combine two upstream strings into the saved filename.
|
||||
|
||||
`Dumas Strip Iteration Suffix` only strips a final numeric suffix. Names like `my_asset_final.png` are left untouched, while `my_asset_012.png` becomes `my_asset.png`.
|
||||
`Dumas Strip Iteration Suffix` strips everything after the last underscore, plus that underscore itself. Names like `my_asset_final.png` become `my_asset.png`, while names with no underscore such as `char123.png` are left untouched.
|
||||
|
||||
`Dumas Slugify String` lowercases text, strips accents, replaces non-alphanumeric runs with `-`, and trims leading or trailing dashes.
|
||||
|
||||
|
||||
+1
-4
@@ -254,10 +254,7 @@ def _strip_iteration_suffix(value):
|
||||
if "_" not in root:
|
||||
return value
|
||||
|
||||
prefix, suffix = root.rsplit("_", 1)
|
||||
if not suffix.isdigit():
|
||||
return value
|
||||
|
||||
prefix, _suffix = root.rsplit("_", 1)
|
||||
return f"{prefix}{extension}"
|
||||
|
||||
|
||||
|
||||
@@ -57,12 +57,19 @@ class DumasJSONNodeTests(unittest.TestCase):
|
||||
|
||||
self.assertEqual(result, ("asset_build",))
|
||||
|
||||
def test_strip_iteration_suffix_leaves_names_without_numeric_suffix_unchanged(self):
|
||||
def test_strip_iteration_suffix_removes_last_underscore_segment_even_when_not_numeric(self):
|
||||
node = DumasStripIterationSuffixNode()
|
||||
|
||||
result = node.strip_iteration_suffix("my_asset_final.png")
|
||||
|
||||
self.assertEqual(result, ("my_asset_final.png",))
|
||||
self.assertEqual(result, ("my_asset.png",))
|
||||
|
||||
def test_strip_iteration_suffix_leaves_names_without_underscore_unchanged(self):
|
||||
node = DumasStripIterationSuffixNode()
|
||||
|
||||
result = node.strip_iteration_suffix("char123.png")
|
||||
|
||||
self.assertEqual(result, ("char123.png",))
|
||||
|
||||
def test_slugify_string_normalizes_text(self):
|
||||
node = DumasSlugifyStringNode()
|
||||
|
||||
Reference in New Issue
Block a user