in jobs/webcompat-kb/webcompat_kb/bugzilla.py [0:0]
def parse_user_story(input_string: str) -> Mapping[str, str | list[str]]:
if not input_string:
return {}
lines = input_string.splitlines()
result_dict: dict[str, str | list[str]] = {}
for line in lines:
if line:
key_value = line.split(":", 1)
if len(key_value) == 2:
key, value = key_value
if key in result_dict:
current_value = result_dict[key]
if isinstance(current_value, list):
current_value.append(value)
else:
result_dict[key] = [current_value, value]
else:
result_dict[key] = value
if not result_dict:
return {}
return result_dict