(message_text)
The magic string users enter looks like: cc_wa_template:template_name:lang_code:{var1}{var2}{var3}
The magic string users enter looks like: cc_wa_template:template_name:lang_code:{var1}{var2}{var3}
The magic string users enter looks like : cc_wa_template : template_name : lang_code : { var1 } { var2 } { var3 }
def get_template_hsm_parts(message_text):
    """The magic string users enter looks like: cc_wa_template:template_name:lang_code:{var1}{var2}{var3}
    """
    HsmParts = namedtuple("hsm_parts", "template_name lang_code params")
    parts = message_text.split(":", maxsplit=3)

    try:
        params = re.findall("{(.+?)}+", parts[3])
    except IndexError:
        params = []

    try:
        return HsmParts(template_name=parts[1], lang_code=parts[2], params=params)
    except IndexError:
        raise WhatsAppTemplateStringException
def get_template_hsm_parts ( message_text ) : HsmParts = namedtuple ( "hsm_parts" , "template_name lang_code params" ) parts = message_text . split ( ":" , maxsplit = 3 ) try : params = re . findall ( "{(.+?)}+" , parts [ 3 ] ) except IndexError : params = [ ] try : return HsmParts ( template_name = parts [ 1 ] , lang_code = parts [ 2 ] , params = params ) except IndexError : raise WhatsAppTemplateStringException