beb173d604c9f975b7eed1c6e8e1152a3d4aab12,bokeh/io.py,,export,#Any#Any#,567

Before Change


    // assert that phantomjs is in path for webdriver
    detect_phantomjs()

    driver = webdriver.PhantomJS()

    // generate the html as tempfile
    temp_html = tempfile.NamedTemporaryFile(suffix=".html").name
    save(obj, filename=temp_html, resources=INLINE, title="")

    if filename is None:
        filename = _detect_filename("png")

    driver.get("file:///" + temp_html)

    class element_to_start_resizing(object):
        
        An expectation for checking if an element has started resizing
        
        def __init__(self, element):
            self.element = element
            self.previous_width = self.element.size["width"]

        def __call__(self, driver):
            current_width = self.element.size["width"]
            if self.previous_width != current_width:
                return True
            else:
                self.previous_width = current_width
                return False


    class element_to_finish_resizing(object):
        
        An expectation for checking if an element has finished resizing
        
        def __init__(self, element):
            self.element = element
            self.previous_width = self.element.size["width"]

        def __call__(self, driver):
            current_width = self.element.size["width"]
            if self.previous_width == current_width:
                return True
            else:
                self.previous_width = current_width
                return False


    def wait_for_canvas_resize(canvas, test_driver):
        try:
            wait = WebDriverWait(test_driver, 1)
            wait.until(element_to_start_resizing(canvas))
            wait.until(element_to_finish_resizing(canvas))
        except TimeoutException:
            // Resize may or may not happen instantaneously,
            // Put the waits in to give some time, but allow test to
            // try and process.
            pass

    canvas = driver.find_element_by_tag_name("canvas")
    wait_for_canvas_resize(canvas, driver)

    driver.maximize_window()

    browser_logs = driver.get_log("browser")
    severe_errors = [l for l in browser_logs if l.get("level") == "SEVERE"]
    if len(severe_errors) > 0:
        logger.warn("There were severe browser errors that may have affected your export: {}".format(severe_errors))

    driver.save_screenshot(filename)

After Change


    if filename is None:
        filename = _detect_filename("png")

    with open(filename, "wb") as f:
        f.write(png)

    return os.path.abspath(filename)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 7

Instances


Project Name: bokeh/bokeh
Commit Name: beb173d604c9f975b7eed1c6e8e1152a3d4aab12
Time: 2017-04-25
Author: lcanavan@continuum.io
File Name: bokeh/io.py
Class Name:
Method Name: export


Project Name: hanxiao/bert-as-service
Commit Name: d97188ee62bc0627235578485c5df7d3245fa1ed
Time: 2018-12-02
Author: hanhxiao@tencent.com
File Name: example6.py
Class Name:
Method Name:


Project Name: lanpa/tensorboardX
Commit Name: f4a6c738beabc312a848804e5c4d4f384919f026
Time: 2020-06-29
Author: prafullasd@gmail.com
File Name: tensorboardX/summary.py
Class Name:
Method Name: audio