diff --git a/funcs_dict_add_string.py b/funcs_dict_add_string.py index da61249..902d003 100644 --- a/funcs_dict_add_string.py +++ b/funcs_dict_add_string.py @@ -10,12 +10,13 @@ from frozendict import deepfreeze as _deepfreeze from .enums import T as _T from .funcs_common import _raise_from_errors_dict, _validate_key, _verify_input_dict + def set_dict_string( name: str, value: str, strip_lines=True, in_dict: _t.Dict[str, _T] = None, # unique_id: str = None, -): +) -> _t.Tuple[_t.Dict[str, _t.Union[_T, str]]]: """Update/append a string to the dict.""" - out_dict: _t.Dict[str, _T] = _verify_input_dict(in_dict) + out_dict: _t.Dict[str, _t.Union[_T, str]] = _verify_input_dict(in_dict) errors_dict: _t.Dict[_t.Any, str] = dict() name = _validate_key(name, errors_dict) _raise_from_errors_dict(errors_dict) @@ -26,4 +27,4 @@ def set_dict_string( ) new_dict: _t.Dict[str, str] = {name: value} out_dict.update(new_dict) - return (_deepfreeze(out_dict),) + return (_deepfreeze(out_dict), ) diff --git a/node_dict_add_string.py b/node_dict_add_string.py index 189c7ff..58d9c44 100644 --- a/node_dict_add_string.py +++ b/node_dict_add_string.py @@ -23,16 +23,13 @@ _input_types = _deepfreeze({ "Name of the substring inserted into the dict. " "It must comprise only of latin letters, digits and underscores + it can't start with a digit." )}), - 'cleanup': (_IO.BOOLEAN, {'default': True, 'label_on': 'extra spaces', 'label_off': 'no', 'tooltip': ( + 'cleanup': (_IO.BOOLEAN, {'default': True, 'label_on': 'leading/trailing spaces', 'label_off': 'no', 'tooltip': ( "When enabled, each line in the sub-string is stripped from any spaces at its start and end." )}), - 'string': (_IO.STRING, {'multiline': True, 'tooltip': "The actual sub-string to set into the dict."}), + 'string': (_IO.STRING, {'multiline': True, 'tooltip': "The actual sub-string to add into the dict."}), }, 'optional': { - 'str_dict': _DataTypes.input_str_dict(tooltip=( - "The dictionary to take named sub-strings from. It could be left unconnected, if the pattern doesn't reference " - "any sub-strings - then, this node acts exactly the same as a regular string-primitive node." - )), + 'str_dict': _DataTypes.input_str_dict(tooltip="An optional Format-Dictionary to extend/update."), }, # 'hidden': { # 'unique_id': 'UNIQUE_ID', # used for text display at the bottom of the node @@ -46,8 +43,6 @@ class StringConstructorDictAddString: CATEGORY = _meta.category DESCRIPTION = _format_docstring(_cleandoc(__doc__)) - OUTPUT_NODE = True # Just to show the status message even if not connected to anything - FUNCTION = 'main' RETURN_TYPES = (_DataTypes.STR_DICT, ) RETURN_NAMES = (_DataTypes.STR_DICT.lower(), ) diff --git a/node_dict_from_text.py b/node_dict_from_text.py index b35bab7..62db62f 100644 --- a/node_dict_from_text.py +++ b/node_dict_from_text.py @@ -14,12 +14,13 @@ from . import _meta from .docstring_formatter import format_docstring as _format_docstring from .enums import DataTypes as _DataTypes from .funcs_dict_from_text import parse_dict_from_text as _parse_dict_from_text +from .node_dict_add_string import _input_types as _input_types_str # A tiny optimization by reusing the same immutable dict: _input_types = _deepfreeze({ 'required': { - 'cleanup': (_IO.BOOLEAN, {'default': True, 'label_on': 'extra spaces', 'label_off': 'no', 'tooltip': ( + 'cleanup': (_IO.BOOLEAN, {'default': True, 'label_on': 'leading/trailing spaces', 'label_off': 'no', 'tooltip': ( "When enabled, each line in each sub-string is stripped from any spaces at its start and end." )}), 'strings': (_IO.STRING, {'multiline': True, 'tooltip': ( @@ -32,9 +33,7 @@ _input_types = _deepfreeze({ )}), }, 'optional': { - 'str_dict': _DataTypes.input_str_dict(tooltip=( - "An optional input dictionary. If it's connected, it will be expanded/updated with new strings." - )), + 'str_dict': _input_types_str['optional']['str_dict'], }, 'hidden': { 'unique_id': 'UNIQUE_ID', # used for text display at the bottom of the node diff --git a/node_dict_preview.py b/node_dict_preview.py index 64a4b17..48b17dd 100644 --- a/node_dict_preview.py +++ b/node_dict_preview.py @@ -17,7 +17,7 @@ from .funcs_dict_preview import preview_str_dict as _preview_str_dict # A tiny optimization by reusing the same immutable dict: _input_types = _deepfreeze({ 'required': { - 'str_dict': _DataTypes.input_str_dict(tooltip="A dictionary of named substrings."), + 'str_dict': _DataTypes.input_str_dict(tooltip="A Format-Dictionary."), }, # 'optional': {}, 'hidden': {