def _remove_old_user_settings(): settings = sublime.load_settings(COLOR_HIGHLIGHTER_SETTINGS_NAME) # pylint: disable=assignment-from-none if settings.get("channels", None) is None: return user_settings_path = os.path.join(path.packages_path(path.ABSOLUTE), "User", COLOR_HIGHLIGHTER_SETTINGS_NAME) os.remove(user_settings_path) shutil.rmtree(path.data_path(path.ABSOLUTE)) if Settings(sublime.load_settings(COLOR_HIGHLIGHTER_SETTINGS_NAME)).debug: print("ColorHighlighter: action=remove_old_settings")
def _remove_old_user_settings(): settings = sublime.load_settings(COLOR_HIGHLIGHTER_SETTINGS_NAME) # pylint: disable=assignment-from-none if settings.get("channels", None) is None: return user_settings_path = os.path.join(path.packages_path(path.ABSOLUTE), "User", COLOR_HIGHLIGHTER_SETTINGS_NAME) os.remove(user_settings_path) shutil.rmtree(path.data_path(path.ABSOLUTE)) if Settings(sublime.load_settings(COLOR_HIGHLIGHTER_SETTINGS_NAME)).debug: print("ColorHighlighter: action=remove_old_settings")
def get_binary_resource_size(file_path): """ Polyfill for ST3 sublime.load_binary_resource function. Arguments: - file_path - a resource path. Returns a byte string with the resource's content. """ if st_helper.is_st3(): return len(sublime.load_binary_resource(file_path)) file_path = os.path.join(os.path.dirname(path.packages_path(path.ABSOLUTE)), file_path) return os.path.getsize(file_path)
def load_resource(file_path): """ Polyfill for ST3 sublime.load_resource function. Arguments: - file_path - a resource path. Returns a string with the resource's content. """ if st_helper.is_st3(): return sublime.load_resource(file_path) file_path = os.path.join(os.path.dirname(path.packages_path(path.ABSOLUTE)), file_path) return _read_file(file_path)
def add_scopes(self, scopes): """ Add scopes to the color scheme. Arguments: - scopes -- an iterable of Elements with scopes to add. """ self._scopes_array_element.extend(scopes) if self._debug: packages_path = os.path.dirname(path.packages_path(path.ABSOLUTE)) print("ColorHighlighter: action=write_color_scheme scheme=%s" % self._color_scheme[len(packages_path) + 1:]) init_color_scheme_dir() self._xml_tree.write(self._color_scheme, encoding="utf-8") try: os.remove(path.cached_scheme_path(self._color_scheme)) except FileNotFoundError: # No cache -- no problems. pass
def add_scopes(self, scopes): """ Add scopes to the color scheme. Arguments: - scopes -- an iterable of Elements with scopes to add. """ self._scopes_array_element.extend(scopes) if self._debug: packages_path = os.path.dirname(path.packages_path(path.ABSOLUTE)) print("ColorHighlighter: action=write_color_scheme scheme=%s" % self._color_scheme[len(packages_path) + 1:]) init_color_scheme_dir() self._xml_tree.write(self._color_scheme, encoding="utf-8") try: os.remove(path.cached_scheme_path(self._color_scheme)) except FileNotFoundError: # No cache -- no problems. pass