def prepare_template(template_name, identifiers):
    tmpl = representation_ms_info[template_name]
    t = ''
    in_template = False
    for c in tmpl:
        t += c
        if (c == '$'):
            in_template = (not in_template)
        elif ((c == '%') and (not in_template)):
            t += c
    t = t.replace('$RepresentationID$', representation_id)
    t = re.sub(('\\$(%s)\\$' % '|'.join(identifiers)), '%(\\1)d', t)
    t = re.sub(('\\$(%s)%%([^$]+)\\$' % '|'.join(identifiers)), '%(\\1)\\2', t)
    t.replace('$$', '$')
    return t
def prepare_template(template_name, identifiers):
    tmpl = representation_ms_info[template_name]
    t = 
    in_template = False
    for c in tmpl:
        t += c
        if (c == '$'):
            in_template = (not in_template)
        elif ((c == '%') and (not in_template)):
            t += c
    t = t.replace('$RepresentationID$', representation_id)
    t = re.sub(('\\$(%s)\\$' % '|'.join(identifiers)), '%(\\1)d', t)
    t = re.sub(('\\$(%s)%%([^$]+)\\$' % '|'.join(identifiers)), '%(\\1)\\2', t)
    t.replace('$$', '$')
    return t