コード例 #1
0
ファイル: lang.py プロジェクト: 343max/Stino
	def genLangList(self):
		plugin_root = utils.getPluginRoot()
		lang_dir = os.path.join(plugin_root, 'lang')
		files = os.listdir(lang_dir)
		for lang_file in files:
			lang_file = os.path.join(lang_dir, lang_file)
			if os.path.isfile(lang_file):
				f = open(lang_file, 'r')
				lines = f.readlines()
				f.close()

				for line in lines:
					(key, value) = utils.getKeyValue(line)
					if key == 'LANG':
						value = value.decode('utf-8', 'replace')
						pattern = re.compile(r'\([\S\s]+\)')
						match = pattern.search(value)
						if match:
							lang = match.group()[1:-1]
						else:
							lang = value
						self.lang_list.append(lang)
						self.lang_text_dict[lang] = value
						self.file_dict[value] = lang_file
						break
		self.lang_list.sort()
コード例 #2
0
ファイル: run.py プロジェクト: 343max/Stino
	def run(self):
		plugin_root = utils.getPluginRoot()
		readme_file = os.path.join(plugin_root, 'readme.txt')
		try:
			f = open(readme_file, 'r')
			text = f.read()
			f.close()
			encoding = codecs.lookup(locale.getpreferredencoding()).name
			if not isinstance(text, unicode):
				text = text.decode(encoding, 'replace')
		except:
			text = '%(Stino_Lic)s'
			msg = text % cur_lang.getDisplayTextDict()
		sublime.message_dialog(msg)
コード例 #3
0
ファイル: lang.py プロジェクト: 343max/Stino
	def genDefaultTransDict(self):
		plugin_root = utils.getPluginRoot()
		template_dir = os.path.join(plugin_root, 'template')
		mod_dir = os.path.join(plugin_root, 'stino')
		dirs = [plugin_root, template_dir, mod_dir]
		pattern = re.compile(r'%\([\S\s]+?\)s')

		for cur_dir in dirs:
			files = os.listdir(cur_dir)
			files = [os.path.join(cur_dir, cur_file) for cur_file in files if (not '.pyc' in cur_file) and (not '.sublime' in cur_file) and (not '.tm' in cur_file)]
			files = [cur_file for cur_file in files if os.path.isfile(cur_file)]
			for cur_file in files:
				lines = utils.readFile(cur_file, mode = 'lines')
				for cur_line in lines:
					match = pattern.search(cur_line)
					if match:
						captions = pattern.findall(cur_line)
						for caption in captions:
							caption = caption[2:-2]
							caption_txt = caption.replace('_', ' ')
							if not caption in self.trans_dict:
								self.trans_dict[caption] = caption_txt
コード例 #4
0
ファイル: run.py プロジェクト: 343max/Stino
	def on_done(self, input_text):
		sketchbook_root = arduino_info.getSketchbookRoot()
		is_new = True
		sketch_name = utils.regFilename(input_text)
		if sketch_name:
			sketch_folder_path = os.path.join(sketchbook_root, sketch_name)
			if os.path.exists(sketch_folder_path):
				org_msg = '%(Sketch_Exists)s'
				msg = org_msg % cur_lang.getDisplayTextDict()
				is_new = sublime.ok_cancel_dialog(msg)
		else:
			is_new = False

		if is_new:
			if not os.path.exists(sketch_folder_path):
				os.mkdir(sketch_folder_path)
			sketch_file_name = '%s.ino' % sketch_name
			sketch_file_path = os.path.join(sketch_folder_path, sketch_file_name)

			# Write Sketch File
			plugin_root = utils.getPluginRoot()
			template_dir = os.path.join(plugin_root, 'template')
			temp_path = os.path.join(template_dir, 'sketch')
			temp_file = open(temp_path, 'r')
			sketch = temp_file.read()
			temp_file.close()

			utils.writeFile(sketch_file_path, sketch)
			cur_menu.sketchbookUpdate()

			#open a new window for new project
			utils.openSketch(sketch_folder_path)	
		else:
			org_caption = '%(Name_for_new_sketch:)s'
			caption = org_caption % cur_lang.getDisplayTextDict()
			self.window.show_input_panel(caption, '', self.on_done, None, self.on_cancel)