fix: split_strip() arg must be str

This commit is contained in:
relikd
2022-08-06 17:45:38 +02:00
parent e67489ab0b
commit 5387256b93
2 changed files with 4 additions and 2 deletions

View File

@@ -52,13 +52,15 @@ class Config:
def set_order_by(self, order_by: Optional[str]) -> None: def set_order_by(self, order_by: Optional[str]) -> None:
''' If specified, children will be sorted according to keys. ''' ''' If specified, children will be sorted according to keys. '''
self.order_by = split_strip(order_by, ',') or None self.order_by = split_strip(order_by or '', ',') or None
def __repr__(self) -> str: def __repr__(self) -> str:
txt = '<GroupByConfig' txt = '<GroupByConfig'
for x in ['key', 'root', 'slug', 'template', 'enabled']: for x in ['key', 'root', 'slug', 'template', 'enabled']:
txt += ' {}="{}"'.format(x, getattr(self, x)) txt += ' {}="{}"'.format(x, getattr(self, x))
txt += f' fields="{", ".join(self.fields)}"' txt += f' fields="{", ".join(self.fields)}"'
if self.order_by:
txt += ' order_by="{}"'.format(' ,'.join(self.order_by))
return txt + '>' return txt + '>'
@staticmethod @staticmethod

View File

@@ -32,7 +32,7 @@ def most_used_key(keys: List[str]) -> str:
def split_strip(data: str, delimiter: str = ',') -> List[str]: def split_strip(data: str, delimiter: str = ',') -> List[str]:
''' Split by delimiter and strip each str separately. Omit if empty. ''' ''' Split by delimiter and strip each str separately. Omit if empty. '''
ret = [] ret = []
for x in (data or '').split(delimiter): for x in data.split(delimiter):
x = x.strip() x = x.strip()
if x: if x:
ret.append(x) ret.append(x)