From a4019bce8e2ae484ee40b12a82465d1eb525fe84 Mon Sep 17 00:00:00 2001 From: Eric Callahan Date: Sun, 3 Apr 2022 17:04:47 -0400 Subject: [PATCH] confighelper: add support for optional separators If "None" is specified as a separator for getdict and the getlist variants then strings will split along any whitespace character. Signed-off-by: Eric Callahan --- moonraker/confighelper.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/moonraker/confighelper.py b/moonraker/confighelper.py index 17788a9..c3de97d 100644 --- a/moonraker/confighelper.py +++ b/moonraker/confighelper.py @@ -208,7 +208,7 @@ class ConfigHelper: option: str, default: Union[SentinelClass, _T] = SENTINEL, list_type: Type = str, - separators: Tuple[str, ...] = ('\n',), + separators: Tuple[Optional[str], ...] = ('\n',), count: Optional[Tuple[Optional[int], ...]] = None, deprecate: bool = False ) -> Union[List[Any], _T]: @@ -222,7 +222,7 @@ class ConfigHelper: def list_parser(value: str, ltype: Type, - seps: Tuple[str, ...], + seps: Tuple[Optional[str], ...], expected_cnt: Tuple[Optional[int], ...] ) -> List[Any]: sep = seps[0] @@ -257,7 +257,7 @@ class ConfigHelper: def getlist(self, option: str, default: Union[SentinelClass, _T] = SENTINEL, - separator: str = '\n', + separator: Optional[str] = '\n', count: Optional[int] = None, deprecate: bool = False ) -> Union[List[str], _T]: @@ -267,7 +267,7 @@ class ConfigHelper: def getintlist(self, option: str, default: Union[SentinelClass, _T] = SENTINEL, - separator: str = '\n', + separator: Optional[str] = '\n', count: Optional[int] = None, deprecate: bool = False ) -> Union[List[int], _T]: @@ -277,7 +277,7 @@ class ConfigHelper: def getfloatlist(self, option: str, default: Union[SentinelClass, _T] = SENTINEL, - separator: str = '\n', + separator: Optional[str] = '\n', count: Optional[int] = None, deprecate: bool = False ) -> Union[List[float], _T]: @@ -287,7 +287,7 @@ class ConfigHelper: def getdict(self, option: str, default: Union[SentinelClass, _T] = SENTINEL, - separators: Tuple[str, str] = ('\n', '='), + separators: Tuple[Optional[str], Optional[str]] = ('\n', '='), dict_type: Type = str, allow_empty_fields: bool = False, deprecate: bool = False