(xml, lang)
return data
Copies emoji.UNICODE_EMOJI[lang] and adds the new names from the xml
Copies emoji.UNICODE_EMOJI[lang] and adds the new names from the xml
Copies emoji . UNICODE_EMOJI [ lang ] and adds the new names from the xml
def extract_names(xml, lang):
    """Copies emoji.UNICODE_EMOJI[lang] and adds the new names from the xml"""

    if lang in emoji_pkg.UNICODE_EMOJI:
        data = emoji_pkg.UNICODE_EMOJI[lang].copy()
    else:
        data = {}

    tree = ET.fromstring(xml)
    annotations = tree.find('annotations')
    for annotation in annotations:
        if annotation.get('type') == 'tts':
            emj = annotation.get('cp')
            text = annotation.text.strip()
            # Fix German clock times "12:30 Uhr" -> "12.30 Uhr"
            text_replaced_colon = re.sub(r"(\d+):(\d+)", r"\1.\2", text)
            separated_name = text_replaced_colon.split(" ")
            emoji_name = ":" + (
                "_".join(separated_name)
                .lower()
                .removeprefix("flag:_")
                .replace(":", "")
                .replace(",", "")
                .replace('"', "")
                .replace("\u201e", "")
                .replace("\u201f", "")
                .replace("\u229b", "")
                .strip()
                .replace(" ", "_")
            ) + ":"
            if lang == "de":
                emoji_name = emoji_name.replace("\u201c", "").replace("\u201d", "")

            if emj in data and data[emj] != emoji_name:
                print(
                    f"# {lang}: CHANGED {data[emj]} TO {emoji_name} \t\t(Original: {text})")
            data[emj] = emoji_name
    return data
def extract_names ( xml , lang ) : if lang in emoji_pkg . UNICODE_EMOJI : data = emoji_pkg . UNICODE_EMOJI [ lang ] . copy ( ) else : data = { } tree = ET . fromstring ( xml ) annotations = tree . find ( 'annotations' ) for annotation in annotations : if annotation . get ( 'type' ) == 'tts' : emj = annotation . get ( 'cp' ) text = annotation . text . strip ( ) # Fix German clock times "12:30 Uhr" -> "12.30 Uhr" text_replaced_colon = re . sub ( r"(\d+):(\d+)" , r"\1.\2" , text ) separated_name = text_replaced_colon . split ( " " ) emoji_name = ":" + ( "_" . join ( separated_name ) . lower ( ) . removeprefix ( "flag:_" ) . replace ( ":" , "" ) . replace ( "," , "" ) . replace ( '"' , "" ) . replace ( "\u201e" , "" ) . replace ( "\u201f" , "" ) . replace ( "\u229b" , "" ) . strip ( ) . replace ( " " , "_" ) ) + ":" if lang == "de" : emoji_name = emoji_name . replace ( "\u201c" , "" ) . replace ( "\u201d" , "" ) if emj in data and data [ emj ] != emoji_name : print ( f"# {lang}: CHANGED {data[emj]} TO {emoji_name} \t\t(Original: {text})" ) data [ emj ] = emoji_name return data