def genSketchList(self): self.sketch_list = [] self.sketch_path_dict = {} sketchbook_root = self.getSketchbookRoot() sketchbook_root = utils.convertAsciiToUtf8(sketchbook_root) # dir_list = osfile.listDir(sketchbook_root, with_files = False) # for cur_dir in dir_list: # cur_dir_path = os.path.join(sketchbook_root, cur_dir) # if isSketchFolder(cur_dir_path): # self.sketch_list.append(cur_dir) # self.sketch_path_dict[cur_dir] = cur_dir_path for (cur_path, sub_dirs, files) in os.walk(sketchbook_root): if 'libraries' in cur_path or 'hardware' in cur_path: continue if isSketchFolder(cur_path): cur_dir = os.path.split(cur_path)[1] parent_path = os.path.split(cur_path)[0] while cur_dir in self.sketch_list: parent_dir = os.path.split(parent_path)[1] cur_dir = parent_dir + '/' + cur_dir parent_path = os.path.split(parent_path)[0] self.sketch_list.append(cur_dir) self.sketch_path_dict[cur_dir] = cur_path
def translate(self, display_text): display_text = display_text.replace('\n', '\\n') display_text = utils.convertAsciiToUtf8(display_text) trans_text = display_text if display_text in self.trans_dict: trans_text = self.trans_dict[display_text] trans_text = trans_text.replace('\\n', '\n') return trans_text
def listDir(path, with_dirs=True, with_files=True): file_list = [] path = utils.convertAsciiToUtf8(path) if os.path.isdir(path): org_file_list = os.listdir(path) for cur_file in org_file_list: if cur_file[0] == '$' or cur_file[0] == '.': continue cur_file = utils.convertAsciiToUtf8(cur_file) cur_file_path = os.path.join(path, cur_file) if os.path.isdir(cur_file_path): if with_dirs: if isDirAccess(cur_file_path): file_list.append(cur_file) else: if with_files: if isFileAccess(cur_file_path): file_list.append(cur_file) return file_list
def listDir(path, with_dirs = True, with_files = True): file_list = [] path = utils.convertAsciiToUtf8(path) if os.path.isdir(path): org_file_list = os.listdir(path) for cur_file in org_file_list: if cur_file[0] == '$' or cur_file[0] == '.': continue cur_file = utils.convertAsciiToUtf8(cur_file) cur_file_path = os.path.join(path, cur_file) if os.path.isdir(cur_file_path): if with_dirs: if isDirAccess(cur_file_path): file_list.append(cur_file) else: if with_files: if isFileAccess(cur_file_path): file_list.append(cur_file) return file_list
def readFileText(file_path): text = '' if isFileAccess(file_path): opened_file = open(file_path) lines = opened_file.readlines() opened_file.close() for line in lines: line = utils.convertAsciiToUtf8(line) text += line return text
# arch may be "x32" or "x64" sys_arch = sublime.arch() # encoding if sys_platform == 'osx': sys_encoding = 'utf-8' else: sys_encoding = codecs.lookup(locale.getpreferredencoding()).name # language sys_language = locale.getdefaultlocale()[0] if sys_language: sys_language = sys_language.lower() else: sys_language = 'en' # Stino settings file # $packages/User/Stino.sublime-settings settings_file = 'Stino.sublime-settings' settings = sublime.load_settings(settings_file) def save_settings(): sublime.save_settings(settings_file) # Stino plugin root directory plugin_root = utils.convertAsciiToUtf8(os.getcwd()) script_root = os.path.join(plugin_root, 'stino') template_root = os.path.join(plugin_root, 'template') language_root = os.path.join(plugin_root, 'language') compilation_script_root = os.path.join(plugin_root, 'compilation')