a8a37622f0ef987ca83c9b401700d0fcbece9b70,sos/converter.py,,script_to_html,#Any#Any#Any#Any#,654

Before Change


    if unknown_args:
        raise ValueError("Unrecognized parameter {}".format(" ".join(unknown_args)))
    formatter = ContinuousHtmlFormatter(cssclass="source", full=False,
        **{x:y for x,y in sargs.items() if x != "raw"})
    with open(html_file, "w") as html:
        html.write(template_pre_style % os.path.basename(script_file))
        html.write(inline_css)
        // remove background definition so that we can use our own
        html.write("\n".join(x for x in formatter.get_style_defs().split("\n") if "background" not in x))
        if "raw" in sargs and sargs["raw"]:
            raw_link = "<a href="{}" class="commit-tease-sha">{}</a>".format(sargs["raw"], script_file)
            script_link = "<a href="{}">{}</a>".format(sargs["raw"], os.path.basename(script_file))
        else:
            raw_link = script_file
            script_link = os.path.basename(script_file)

After Change


    if unknown_args:
        raise ValueError("Unrecognized parameter {}".format(" ".join(unknown_args)))
    formatter = ContinuousHtmlFormatter(cssclass="source", full=False,
        **{x:y for x,y in vars(args).items() if x != ("raw", "view")})
    with open(html_file, "w") as html:
        html.write(template_pre_style % os.path.basename(script_file))
        html.write(inline_css)
        // remove background definition so that we can use our own
        html.write("\n".join(x for x in formatter.get_style_defs().split("\n") if "background" not in x))
        if args.raw:
            raw_link = "<a href="{}" class="commit-tease-sha">{}</a>".format(args.raw, script_file)
            script_link = "<a href="{}">{}</a>".format(args.raw, os.path.basename(script_file))
        else:
            raw_link = script_file
            script_link = os.path.basename(script_file)
        html.write(template_pre_table % (script_link, raw_link,
            pretty_size(os.path.getsize(script_file))))
        //
        html.write("<table class="highlight tab-size js-file-line-container">")
        with open(transcript_file) as script:
            content = []
            content_type = None
            content_number = None
            next_type = None
            for line in script:
                line_type, line_no, script_line = line.split("\t", 2)
                // Does not follow section because it has to be one line
                if line_type == "FOLLOW" and content_type in (None, "SECTION"):
                    line_type = "COMMENT"
                if content_type == line_type or line_type == "FOLLOW":
                    if next_type is not None and not script_line.rstrip().endswith(","):
                        formatter.linenostart = content_number
                        write_html_content(content_type, content, formatter, html)
                        content = [script_line]
                        content_type = next_type
                        content_number = int(line_no)
                        next_type = None
                    else:
                        content.append(script_line)
                else:
                    if content:
                        formatter.linenostart = content_number
                        write_html_content(content_type, content, formatter, html)
                    if line_type.startswith("SCRIPT_"):
                        content_type = "DIRECTIVE"
                        next_type = line_type[7:]
                    else:
                        content_type = line_type
                    content_number = int(line_no)
                    content = [script_line]
        if content:
            formatter.linenostart = content_number
            write_html_content(content_type, content, formatter, html)
        html.write("</table>")
        html.write(template_post_table)
    //
    try:
        os.remove(transcript_file)
    except:
        pass
    //
    if no_output_file:
        if not args.view:
            with open(html_file) as html:
                sys.stdout.write(html.read())
    else:
        env.logger.info("SoS script saved to {}".format(html_file))
    //
    if args.view:
        url = "file://{}".format(html_file)
        env.logger.info("Viewing {} in a browser".format(url))
        webbrowser.open(url, new=2)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 5

Instances


Project Name: vatlab/SoS
Commit Name: a8a37622f0ef987ca83c9b401700d0fcbece9b70
Time: 2016-12-12
Author: ben.bog@gmail.com
File Name: sos/converter.py
Class Name:
Method Name: script_to_html


Project Name: ruotianluo/ImageCaptioning.pytorch
Commit Name: 79fc09d66d3f4736b9fb4f5756a78725719f3808
Time: 2017-02-10
Author: rluo@ttic.edu
File Name: train.py
Class Name:
Method Name: train


Project Name: vatlab/SoS
Commit Name: a8a37622f0ef987ca83c9b401700d0fcbece9b70
Time: 2016-12-12
Author: ben.bog@gmail.com
File Name: sos/converter.py
Class Name:
Method Name: script_to_html