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,
|
option: str,
|
||||||
default: Union[SentinelClass, _T] = SENTINEL,
|
default: Union[SentinelClass, _T] = SENTINEL,
|
||||||
list_type: Type = str,
|
list_type: Type = str,
|
||||||
separators: Tuple[str, ...] = ('\n',),
|
separators: Tuple[Optional[str], ...] = ('\n',),
|
||||||
count: Optional[Tuple[Optional[int], ...]] = None,
|
count: Optional[Tuple[Optional[int], ...]] = None,
|
||||||
deprecate: bool = False
|
deprecate: bool = False
|
||||||
) -> Union[List[Any], _T]:
|
) -> Union[List[Any], _T]:
|
||||||
|
@ -222,7 +222,7 @@ class ConfigHelper:
|
||||||
|
|
||||||
def list_parser(value: str,
|
def list_parser(value: str,
|
||||||
ltype: Type,
|
ltype: Type,
|
||||||
seps: Tuple[str, ...],
|
seps: Tuple[Optional[str], ...],
|
||||||
expected_cnt: Tuple[Optional[int], ...]
|
expected_cnt: Tuple[Optional[int], ...]
|
||||||
) -> List[Any]:
|
) -> List[Any]:
|
||||||
sep = seps[0]
|
sep = seps[0]
|
||||||
|
@ -257,7 +257,7 @@ class ConfigHelper:
|
||||||
def getlist(self,
|
def getlist(self,
|
||||||
option: str,
|
option: str,
|
||||||
default: Union[SentinelClass, _T] = SENTINEL,
|
default: Union[SentinelClass, _T] = SENTINEL,
|
||||||
separator: str = '\n',
|
separator: Optional[str] = '\n',
|
||||||
count: Optional[int] = None,
|
count: Optional[int] = None,
|
||||||
deprecate: bool = False
|
deprecate: bool = False
|
||||||
) -> Union[List[str], _T]:
|
) -> Union[List[str], _T]:
|
||||||
|
@ -267,7 +267,7 @@ class ConfigHelper:
|
||||||
def getintlist(self,
|
def getintlist(self,
|
||||||
option: str,
|
option: str,
|
||||||
default: Union[SentinelClass, _T] = SENTINEL,
|
default: Union[SentinelClass, _T] = SENTINEL,
|
||||||
separator: str = '\n',
|
separator: Optional[str] = '\n',
|
||||||
count: Optional[int] = None,
|
count: Optional[int] = None,
|
||||||
deprecate: bool = False
|
deprecate: bool = False
|
||||||
) -> Union[List[int], _T]:
|
) -> Union[List[int], _T]:
|
||||||
|
@ -277,7 +277,7 @@ class ConfigHelper:
|
||||||
def getfloatlist(self,
|
def getfloatlist(self,
|
||||||
option: str,
|
option: str,
|
||||||
default: Union[SentinelClass, _T] = SENTINEL,
|
default: Union[SentinelClass, _T] = SENTINEL,
|
||||||
separator: str = '\n',
|
separator: Optional[str] = '\n',
|
||||||
count: Optional[int] = None,
|
count: Optional[int] = None,
|
||||||
deprecate: bool = False
|
deprecate: bool = False
|
||||||
) -> Union[List[float], _T]:
|
) -> Union[List[float], _T]:
|
||||||
|
@ -287,7 +287,7 @@ class ConfigHelper:
|
||||||
def getdict(self,
|
def getdict(self,
|
||||||
option: str,
|
option: str,
|
||||||
default: Union[SentinelClass, _T] = SENTINEL,
|
default: Union[SentinelClass, _T] = SENTINEL,
|
||||||
separators: Tuple[str, str] = ('\n', '='),
|
separators: Tuple[Optional[str], Optional[str]] = ('\n', '='),
|
||||||
dict_type: Type = str,
|
dict_type: Type = str,
|
||||||
allow_empty_fields: bool = False,
|
allow_empty_fields: bool = False,
|
||||||
deprecate: bool = False
|
deprecate: bool = False
|
||||||
|
|
Loading…
Reference in New Issue