show any, support a list

This commit is contained in:
Crystian
2023-12-23 22:47:10 +01:00
parent 5c3fb2603d
commit 89eb50bfa4
5 changed files with 69 additions and 31 deletions
+4 -1
View File
@@ -44,10 +44,13 @@ Show metadata, compare between two JSONs, compare between two images, show any v
## List
> A set of nodes with list of values (any or strings/texts)
> With strings you can concatenate them
> With strings you can concatenate them
![Lists](./docs/lists.png)
> Important: You can use with others nodes like "Show any" to see the values of the list
![Lists](./docs/lists-any.png)
## Switch
> A set of nodes to switch between flows
> All switches are boolean, you can switch between flows by simply changing the value of the switch.
Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

+12 -2
View File
@@ -24,6 +24,8 @@ class CConsoleAny:
}
CATEGORY = CATEGORY.MAIN.value + CATEGORY.DEBUGGER.value
INPUT_IS_LIST = True
RETURN_TYPES = ()
OUTPUT_NODE = True
@@ -35,7 +37,15 @@ class CConsoleAny:
if any_value is not None:
try:
text = str(any_value)
if type(any_value) == list:
for item in any_value:
try:
text += str(item) + "\n"
except Exception as e:
text += "source exists, but could not be serialized.\n"
logger.warn(e)
else:
text = str(any_value)
except Exception:
try:
text = json.dumps(any_value)[1:-1]
@@ -54,6 +64,6 @@ class CConsoleAny:
textToDisplay = text
value = [console, display, prefix, textToDisplay]
setWidgetValues(value, unique_id, extra_pnginfo)
# setWidgetValues(value, unique_id, extra_pnginfo)
return {"ui": {"text": value}}
+51 -26
View File
@@ -1,4 +1,4 @@
from ..core import STRING, TEXTS, KEYS, CATEGORY, any
from ..core import STRING, TEXTS, KEYS, CATEGORY, any, logger
from ._names import CLASSES
@@ -26,6 +26,7 @@ class CListAny:
CATEGORY = CATEGORY.MAIN.value + CATEGORY.LIST.value
RETURN_TYPES = (any,),
RETURN_NAMES = ("any_list",)
OUTPUT_IS_LIST = (True,)
FUNCTION = "execute"
@@ -41,24 +42,48 @@ class CListAny:
list = []
if any_1:
list.append(any_1)
if any_2:
list.append(any_2)
if any_3:
list.append(any_3)
if any_4:
list.append(any_4)
if any_5:
list.append(any_5)
if any_6:
list.append(any_6)
if any_7:
list.append(any_7)
if any_8:
list.append(any_8)
if any_1 is not None:
try:
list.append(any_1)
except Exception as e:
logger.warn(e)
if any_2 is not None:
try:
list.append(any_2)
except Exception as e:
logger.warn(e)
if any_3 is not None:
try:
list.append(any_3)
except Exception as e:
logger.warn(e)
if any_4 is not None:
try:
list.append(any_4)
except Exception as e:
logger.warn(e)
if any_5 is not None:
try:
list.append(any_5)
except Exception as e:
logger.warn(e)
if any_6 is not None:
try:
list.append(any_6)
except Exception as e:
logger.warn(e)
if any_7 is not None:
try:
list.append(any_7)
except Exception as e:
logger.warn(e)
if any_8 is not None:
try:
list.append(any_8)
except Exception as e:
logger.warn(e)
return list
return [list]
class CListString:
@@ -102,21 +127,21 @@ class CListString:
list = []
if string_1:
if string_1 is not None:
list.append(string_1)
if string_2:
if string_2 is not None:
list.append(string_2)
if string_3:
if string_3 is not None:
list.append(string_3)
if string_4:
if string_4 is not None:
list.append(string_4)
if string_5:
if string_5 is not None:
list.append(string_5)
if string_6:
if string_6 is not None:
list.append(string_6)
if string_7:
if string_7 is not None:
list.append(string_7)
if string_8:
if string_8 is not None:
list.append(string_8)
return delimiter.join(list), list
+2 -2
View File
@@ -5,7 +5,7 @@ from ..core import CATEGORY, CONFIG, JSON_WIDGET, TEXTS, findJsonStrDiff, findJs
class CMetadataExtractor:
@classmethod
def INPUT_TYPES(s):
def INPUT_TYPES(cls):
return {
"required": {
"metadata_raw": ("METADATA_RAW", {"forceInput": True}),
@@ -65,7 +65,7 @@ class CMetadataExtractor:
class CMetadataCompare:
@classmethod
def INPUT_TYPES(s):
def INPUT_TYPES(cls):
return {
"required": {
"metadata_raw_old": ("METADATA_RAW", {"forceInput": True}),