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 <arksine.code@gmail.com>
This commit is contained in:
parent
f3b0fbaa34
commit
a4019bce8e
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue