Пример #1
0
	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)
Пример #2
0
	def run(self, menu_str):
		example = menu_str
		example_path = arduino_info.getExampleFolder(example)
		
		if arduino.isSketchFolder(example_path):
			example_name = os.path.split(example_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(example_path, example_file)
				view = self.window.open_file(file_path)
			else:
				shutil.copytree(example_path, new_path, True)
				cur_menu.sketchbookUpdate()
				utils.openSketch(new_path)
		else:
			file_list = utils.listDir(example_path)
			self.level = 0
			self.top_path_list = [os.path.join(example_path, cur_file) for cur_file in file_list]
			self.path_list = self.top_path_list
			self.window.show_quick_panel(file_list, self.on_done)