mod: removed reverse option

This commit is contained in:
uihp
2025-02-09 02:37:18 +08:00
parent f323a35e3e
commit 98a3f3ad04
3 changed files with 9 additions and 18 deletions
+5 -6
View File
@@ -2,14 +2,13 @@ class StringChain:
@classmethod
def INPUT_TYPES(cls) -> dict:
return {
'optional': { 'previous': ('STRING', {'forceInput': True, 'default': '', 'multiline': True}) },
'required': {
'separator': ('STRING', {'default': ', '}),
'string': ('STRING', {'default': '', 'multiline': True}),
'optional': {
'previous': ('STRING', {'forceInput': True, 'default': '', 'multiline': True}),
'string': ('STRING', {'default': '', 'multiline': True})
}
}
RETURN_TYPES = ('STRING',)
FUNCTION = 'combine'
CATEGORY = 'utils'
def combine(self, string: str, separator: str, previous: str = '') -> tuple[str]:
return (f'{previous}{separator}{string}',) if previous and string else (previous or string,)
def combine(self, previous: str = '', string: str = '') -> tuple[str]:
return (f'{previous}, {string}',) if previous and string else (previous or string,)
+2 -6
View File
@@ -6,14 +6,10 @@ class StringConcat:
'previous': ('STRING', {'forceInput': True, 'default': '', 'multiline': True}),
'string': ('STRING', {'default': '', 'multiline': True})
},
'required': {
'separator': ('STRING', {'default': ', '}),
'reverse': ('BOOLEAN', {'default': False})
}
'required': { 'separator': ('STRING', { 'default': '' }) }
}
RETURN_TYPES = ('STRING',)
FUNCTION = 'concat'
CATEGORY = 'utils'
def concat(self, separator: str, reverse: bool, previous: str = '', string: str = '') -> tuple[str]:
if reverse: previous, string = string, previous
def concat(self, separator: str, previous: str = '', string: str = '') -> tuple[str]:
return (f'{previous}{separator}{string}',) if previous and string else (previous or string,)
+2 -6
View File
@@ -9,19 +9,15 @@ class StringToggle:
@classmethod
def INPUT_TYPES(cls) -> dict:
return {
'required': {
'separator': ('STRING', {'default': ', '}),
'reverse': ('BOOLEAN', {'default': False})
},
'required': { 'separator': ('STRING', {'default': ', '}) },
'optional': optional
}
RETURN_TYPES = ('STRING',)
FUNCTION = 'join'
CATEGORY = 'utils'
def join(self, separator: str, reverse: bool, previous: str = '', **kwargs) -> tuple[str]:
def join(self, separator: str, previous: str = '', **kwargs) -> tuple[str]:
arguments = {}
for (argtype, unique), value in [(k.split('_'),v) for k,v in kwargs.items() if '_' in k]:
arguments.setdefault(argtype, {})[unique] = value
strings = ([previous] if previous else []) + [text for unique, text in arguments['text'].items() if arguments['append'][unique]]
if reverse: strings = strings[::-1]
return (separator.join(strings),)