def on_done(self, index): if index == -1: return sel_path = self.path_list[index] if arduino.isSketchFolder(sel_path): example_name = os.path.split(sel_path)[1] sketchbook_root = arduino_info.getSketchbookRoot() new_path = os.path.join(sketchbook_root, example_name) if os.path.exists(new_path): org_msg = '%(Sketch_Exists)s' msg = org_msg % cur_lang.getDisplayTextDict() sublime.message_dialog(msg) version = arduino_info.getVersion() if version >= 100: example_file = example_name + '.ino' else: example_file = example_name + '.pde' file_path = os.path.join(sel_path, example_file) view = self.window.open_file(file_path) else: shutil.copytree(sel_path, new_path, True) cur_menu.sketchbookUpdate() utils.openSketch(new_path) else: (self.level, self.path_list) = utils.enterNext(index, self.level, self.top_path_list, sel_path) file_list = utils.getFileList(self.path_list) self.window.show_quick_panel(file_list, self.on_done)
def on_done(self, index): if index == -1: return sel_path = self.path_list[index] if arduino.isArduinoFolder(sel_path): real_path = sel_path if sys.platform == 'darwin': real_path = os.path.join(sel_path, 'Contents/Resources/JAVA') (ver_text, ver) = arduino.genVersion(real_path) text = '%s: %s\n%s: %s' % ('%(Arduino)s', sel_path, '%(Version)s', ver_text) msg = text % cur_lang.getDisplayTextDict() sublime.message_dialog(msg) if ver < 10: text = '%(Version_Not_Supported)s' msg = text % cur_lang.getDisplayTextDict() sublime.message_dialog(msg) else: pre_arduino_root = Settings.get('Arduino_root') if sel_path != pre_arduino_root: Settings.set('Arduino_root', sel_path) Settings.set('full_compilation', True) sublime.save_settings(Setting_File) cur_menu.fullUpdate() else: (self.level, self.path_list) = utils.enterNext(index, self.level, self.top_path_list, sel_path, False) file_list = utils.getFileList(self.path_list) self.window.show_quick_panel(file_list, self.on_done)
def on_done(self, index): if index == -1: return sel_path = self.path_list[index] if os.path.isfile(sel_path): active_file = self.window.active_view().file_name() sketch_folder = os.path.split(active_file)[0] is_new = True basename = os.path.split(sel_path)[1] basename = utils.regFilename(basename) file_path = os.path.join(sketch_folder, basename) if os.path.exists(file_path): is_new = False if is_new: content = utils.readFile(sel_path) utils.writeFile(file_path, content) view = self.window.open_file(file_path) else: org_msg = '%(File_Exists)s' msg = org_msg % cur_lang.getDisplayTextDict() is_new = sublime.message_dialog(msg) else: (self.level, self.path_list) = utils.enterNext(index, self.level, self.top_path_list, sel_path) file_list = utils.getFileList(self.path_list) self.window.show_quick_panel(file_list, self.on_done)
def on_done(self, index): if index == -1: return sel_path = self.path_list[index] if os.path.isfile(sel_path): view = self.window.open_file(sel_path) else: (self.level, self.path_list) = utils.enterNext(index, self.level, self.top_path_list, sel_path) file_list = utils.getFileList(self.path_list) self.window.show_quick_panel(file_list, self.on_done)
def on_done(self, index): if index == -1: return if self.level > 0 and index == 0: cur_path = os.path.split(self.path_list[1])[0] zip_path = os.path.join(cur_path, self.zip_file) opened_zipfile = zipfile.ZipFile(zip_path, 'w' ,zipfile.ZIP_DEFLATED) for file_path in self.file_list: opened_zipfile.write(file_path) opened_zipfile.close() else: sel_path = self.path_list[index] (self.level, self.path_list) = utils.enterNext(index, self.level, self.top_path_list, sel_path, False) file_list = utils.getFileList(self.path_list) if not self.path_list == self.top_path_list: text = '%(Select_Current_Folder)s' msg = text % cur_lang.getDisplayTextDict() self.path_list.insert(0, msg) file_list.insert(0, msg) self.window.show_quick_panel(file_list, self.on_done)
def on_done(self, index): if index == -1: return if self.level > 0 and index == 0: pre_sketchbook_root = arduino_info.getSketchbookRoot() sketchbook_root = os.path.split(self.path_list[1])[0] if not sketchbook_root == pre_sketchbook_root: Settings.set('sketchbook_root', sketchbook_root) sublime.save_settings(Setting_File) cur_menu.fullUpdate() else: sel_path = self.path_list[index] (self.level, self.path_list) = utils.enterNext(index, self.level, self.top_path_list, sel_path, False) file_list = utils.getFileList(self.path_list) if not self.path_list == self.top_path_list: text = '%(Select_Current_Folder)s' msg = text % cur_lang.getDisplayTextDict() self.path_list.insert(0, msg) file_list.insert(0, msg) self.window.show_quick_panel(file_list, self.on_done)