def handle_sketch(view, func, using_programmer=False):
    window = view.window()
    views = window.views()
    if view not in views:
        view = window.active_view()
    if view.file_name() is None:
        tmp_path = pyarduino.base.sys_path.get_tmp_path()
        tmp_path = os.path.join(tmp_path, 'Arduino')
        name = str(time.time()).split('.')[1]
        sketch_path = os.path.join(tmp_path, name)
        os.makedirs(sketch_path)

        settings = st_base.get_settings()
        bare_gcc = settings.get('bare_gcc', False)
        if bare_gcc:
            ext = '.cpp'
        else:
            ext = '.ino'
        src_file_name = name + ext
        src_file_path = os.path.join(sketch_path, src_file_name)

        region = sublime.Region(0, view.size())
        text = view.substr(region)
        src_file = pyarduino.base.abs_file.File(src_file_path)
        src_file.write(text)

        view.set_scratch(True)
        window = view.window()
        window.run_command('close')
        view = window.open_file(src_file_path)

    if view.is_dirty():
        view.run_command('save')
    file_path = view.file_name()
    sketch_path = os.path.dirname(file_path)
    func(view, sketch_path, using_programmer)
dataset/ETHPy150Open Robot-Will/Stino/stino/main.py/handle_sketch/original