-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
bblocks-datacommons-tools/src/bblocks/datacommons_tools/custom_data/models/common.py
Line 49 in db78e09
def mcf_str(value: str | list[str] | None) -> str | None: |
def mcf_str(value: str | list[str] | None) -> str | None:
"""Serialise a string or list of strings without adding quotes.
Args:
value: A string, list of strings, or None to serialise.
Returns:
A comma-delimited string, a single string, or None if input is None or an empty list.
"""
if value is None:
return None
if isinstance(value, list):
if not value:
return None # <-- add something like this to deal with empty lists
if len(value) == 1:
return str(value[0])
return ", ".join(str(item) for item in value)
return value