from typing import Any, Dict, List, Optional import flag from apollo_messages_views.constants.base import GLOBAL_MARKET, GLOBE_FLAG, UNKNOWN_FLAG def get_flag(country_code: Optional[str], unknown_as: str = "") -> str: if country_code == GLOBAL_MARKET: return GLOBE_FLAG if country_code is None or len(country_code) < 2 or len(country_code) >= 7: # these cases flag raises error return unknown_as _flag = flag.flag(country_code) if _flag == UNKNOWN_FLAG: return unknown_as return _flag def get_artists_str(artists: List[Dict[str, Any]]) -> str: """As we have a list of artists we need to handle situation when there are more than one artist for the track""" artists = " & ".join(artist["name"] for artist in artists) return artists