utils.py•925 B
from typing import List, Dict
import os
def format_creators(creators: List[Dict[str, str]]) -> str:
"""
Format creator names into a string.
Args:
creators: List of creator objects from Zotero.
Returns:
Formatted string with creator names.
"""
names = []
for creator in creators:
if "firstName" in creator and "lastName" in creator:
names.append(f"{creator['lastName']}, {creator['firstName']}")
elif "name" in creator:
names.append(creator["name"])
return "; ".join(names) if names else "No authors listed"
def is_local_mode() -> bool:
"""Return True if running in local mode.
Local mode is enabled when environment variable `ZOTERO_LOCAL` is set to a
truthy value ("true", "yes", or "1", case-insensitive).
"""
value = os.getenv("ZOTERO_LOCAL", "")
return value.lower() in {"true", "yes", "1"}