(var, trs)
return "\n".join(html)
Return a html fragment summarizing the changes applied by `trs` list.

    Parameters
    ----------
    var : Variable
        A variable descriptor no which trs operates
    trs : List[Transform]
        A non empty list of `Transform` instances.

    Returns
    -------
    report : str
Return a html fragment summarizing the changes applied by `trs` list.
Return a html fragment summarizing the changes applied by trs list .
def report_transform(var, trs):
    # type: (Variable, List[Transform]) -> str
    """
    Return a html fragment summarizing the changes applied by `trs` list.

    Parameters
    ----------
    var : Variable
        A variable descriptor no which trs operates
    trs : List[Transform]
        A non empty list of `Transform` instances.

    Returns
    -------
    report : str
    """
    # pylint: disable=too-many-branches
    ReinterpretTypeCode = {
        AsCategorical:  "C", AsContinuous: "N", AsString: "S", AsTime: "T",
    }

    def type_char(value: ReinterpretTransform) -> str:
        return ReinterpretTypeCode.get(type(value), "?")

    def strike(text):
        return "<s>{}</s>".format(escape(text))

    def i(text):
        return "<i>{}</i>".format(escape(text))

    def text(text):
        return "<span>{}</span>".format(escape(text))
    assert trs
    rename = annotate = catmap = unlink = None
    reinterpret = None

    for tr in trs:
        if isinstance(tr, Rename):
            rename = tr
        elif isinstance(tr, Annotate):
            annotate = tr
        elif isinstance(tr, CategoriesMapping):
            catmap = tr
        elif isinstance(tr, Unlink):
            unlink = tr
        elif isinstance(tr, ReinterpretTransformTypes):
            reinterpret = tr

    if reinterpret is not None:
        header = "{} → ({}) {}".format(
            var.name, type_char(reinterpret),
            rename.name if rename is not None else var.name
        )
    elif rename is not None:
        header = "{} → {}".format(var.name, rename.name)
    else:
        header = var.name
    if unlink is not None:
        header += "(unlinked from source)"

    values_section = None
    if catmap is not None:
        values_section = ("Values", [])
        lines = values_section[1]
        for ci, cj in catmap.mapping:
            if ci is None:
                item = cj + ("&nbsp;" * 3) + "(added)"
            elif cj is None:
                item = strike(ci)
            else:
                item = ci + " → " + cj
            lines.append(item)

    annotate_section = None
    if annotate is not None:
        annotate_section = ("Labels", [])
        lines = annotate_section[1]
        old = dict(var.annotations)
        new = dict(annotate.annotations)
        for name in sorted(set(old) - set(new)):
            lines.append(
                "<s>" + i(name) + " : " + text(old[name]) + "</s>"
            )
        for name in sorted(set(new) - set(old)):
            lines.append(
                i(name) + " : " + text(new[name]) + "&nbsp;" * 3 + i("(new)")
            )

        for name in sorted(set(new) & set(old)):
            if new[name] != old[name]:
                lines.append(
                    i(name) + " : " + text(old[name]) + " → " + text(new[name])
                )

    html = ["<div style='font-weight: bold;'>{}</div>".format(header)]
    for title, contents in filter(None, [values_section, annotate_section]):
        section_header = "<div>{}:</div>".format(title)
        section_contents = "<br/>\n".join(contents)
        html.append(section_header)
        html.append(
            "<div style='padding-left: 1em;'>" +
            section_contents +
            "</div>"
        )
    return "\n".join(html)
def report_transform ( var , trs ) : # type: (Variable, List[Transform]) -> str # pylint: disable=too-many-branches ReinterpretTypeCode = { AsCategorical : "C" , AsContinuous : "N" , AsString : "S" , AsTime : "T" , } def type_char ( value : ReinterpretTransform ) -> str : return ReinterpretTypeCode . get ( type ( value ) , "?" ) def strike ( text ) : return "<s>{}</s>" . format ( escape ( text ) ) def i ( text ) : return "<i>{}</i>" . format ( escape ( text ) ) def text ( text ) : return "<span>{}</span>" . format ( escape ( text ) ) assert trs rename = annotate = catmap = unlink = None reinterpret = None for tr in trs : if isinstance ( tr , Rename ) : rename = tr elif isinstance ( tr , Annotate ) : annotate = tr elif isinstance ( tr , CategoriesMapping ) : catmap = tr elif isinstance ( tr , Unlink ) : unlink = tr elif isinstance ( tr , ReinterpretTransformTypes ) : reinterpret = tr if reinterpret is not None : header = "{} → ({}) {}".f o rmat( var . name , type_char ( reinterpret ) , rename . name if rename is not None else var . name ) elif rename is not None : header = "{} → {}".f o rmat(v a r.n a me,  r name.n a me) else : header = var . name if unlink is not None : header += "(unlinked from source)" values_section = None if catmap is not None : values_section = ( "Values" , [ ] ) lines = values_section [ 1 ] for ci , cj in catmap . mapping : if ci is None : item = cj + ( "&nbsp;" * 3 ) + "(added)" elif cj is None : item = strike ( ci ) else : item = ci + " → " + c lines . append ( item ) annotate_section = None if annotate is not None : annotate_section = ( "Labels" , [ ] ) lines = annotate_section [ 1 ] old = dict ( var . annotations ) new = dict ( annotate . annotations ) for name in sorted ( set ( old ) - set ( new ) ) : lines . append ( "<s>" + i ( name ) + " : " + text ( old [ name ] ) + "</s>" ) for name in sorted ( set ( new ) - set ( old ) ) : lines . append ( i ( name ) + " : " + text ( new [ name ] ) + "&nbsp;" * 3 + i ( "(new)" ) ) for name in sorted ( set ( new ) & set ( old ) ) : if new [ name ] != old [ name ] : lines . append ( i ( name ) + " : " + text ( old [ name ] ) + " → " + t xt(n e w[n a me]) ) html = [ "<div style='font-weight: bold;'>{}</div>" . format ( header ) ] for title , contents in filter ( None , [ values_section , annotate_section ] ) : section_header = "<div>{}:</div>" . format ( title ) section_contents = "<br/>\n" . join ( contents ) html . append ( section_header ) html . append ( "<div style='padding-left: 1em;'>" + section_contents + "</div>" ) return "\n" . join ( html )