From 23d3ba5e29a92b31cfbca32721836fbb6075ecd1 Mon Sep 17 00:00:00 2001 From: jesopo Date: Sun, 26 Jan 2020 11:21:23 +0000 Subject: [PATCH] add tstring spec type, string with trimmed consecutive spaces --- src/utils/parse/spec.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/utils/parse/spec.py b/src/utils/parse/spec.py index bb0dcc9d..46ab9ad5 100644 --- a/src/utils/parse/spec.py +++ b/src/utils/parse/spec.py @@ -39,6 +39,9 @@ class SpecArgumentTypeString(SpecArgumentType): return "%s ..." % SpecArgumentType.name(self) def simple(self, args: typing.List[str]) -> typing.Tuple[typing.Any, int]: return " ".join(args), len(args) +class SpecArgumentTypeTrimString(SpecArgumentTypeString): + def simple(self, args: typing.List[str]): + return SpecArgumentTypeString.simple(self, list(filter(None, args))) class SpecArgumentTypeDuration(SpecArgumentType): def name(self): @@ -57,6 +60,7 @@ SPEC_ARGUMENT_TYPES = { "word": SpecArgumentTypeWord, "wordlower": SpecArgumentTypeWordLower, "string": SpecArgumentTypeString, + "tstring": SpecArgumentTypeTrimString, "duration": SpecArgumentTypeDuration }