lib/ui: fix human_list for lists with one item

This commit is contained in:
Jens Langhammer 2020-05-10 15:29:10 +02:00
parent fbc3ac6b30
commit 358922b09b
1 changed files with 4 additions and 1 deletions

View File

@ -1,8 +1,11 @@
"""passbook UI utils"""
from typing import Any, List
def human_list(_list) -> str:
def human_list(_list: List[Any]) -> str:
"""Convert a list of items into 'a, b or c'"""
last_item = _list.pop()
if len(_list) < 1:
return last_item
result = ", ".join(_list)
return "%s or %s" % (result, last_item)