diff -r b2e75ba58a30 -r 7f7ff7456904 src/eric7/RemoteServer/EricServerEditorConfigRequestHandler.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/eric7/RemoteServer/EricServerEditorConfigRequestHandler.py Tue Jun 11 16:42:56 2024 +0200 @@ -0,0 +1,68 @@ +# -*- coding: utf-8 -*- + +# Copyright (c) 2024 Detlev Offenbach <detlev@die-offenbachs.de> +# + +""" +Module implementing the editor config request handler of the eric-ide server. +""" + +import editorconfig + +from .EricRequestCategory import EricRequestCategory +from .EricServerBaseRequestHandler import EricServerBaseRequestHandler + + +class EricServerEditorConfigRequestHandler(EricServerBaseRequestHandler): + """ + Class implementing the editor config request handler of the eric-ide server. + """ + + def __init__(self, server): + """ + Constructor + + @param server reference to the eric-ide server object + @type EricServer + """ + super().__init__(server) + + self._category = EricRequestCategory.EditorConfig + + self._requestMethodMapping = { + "LoadEditorConfig": self.__loadEditorConfig, + } + + ############################################################################ + ## Editor Config related methods below + ############################################################################ + + def __loadEditorConfig(self, params): + """ + Private method to load the EditorConfig properties for the given + file name. + + @param params dictionary containing the request data + @type dict + @return dictionary containing the reply data + @rtype dict + """ + fileName = params["filename"] + + if fileName: + try: + editorConfig = editorconfig.get_properties(fileName) + return { + "ok": True, + "config": editorConfig, + } + except editorconfig.EditorConfigError: + return { + "ok": False, + "config": {}, + } + + return { + "ok": True, + "config": {}, + }