src/eric7/RemoteServer/EricServerEditorConfigRequestHandler.py

branch
server
changeset 10774
7f7ff7456904
child 11090
f5f5f5803935
equal deleted inserted replaced
10773:b2e75ba58a30 10774:7f7ff7456904
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2024 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing the editor config request handler of the eric-ide server.
8 """
9
10 import editorconfig
11
12 from .EricRequestCategory import EricRequestCategory
13 from .EricServerBaseRequestHandler import EricServerBaseRequestHandler
14
15
16 class EricServerEditorConfigRequestHandler(EricServerBaseRequestHandler):
17 """
18 Class implementing the editor config request handler of the eric-ide server.
19 """
20
21 def __init__(self, server):
22 """
23 Constructor
24
25 @param server reference to the eric-ide server object
26 @type EricServer
27 """
28 super().__init__(server)
29
30 self._category = EricRequestCategory.EditorConfig
31
32 self._requestMethodMapping = {
33 "LoadEditorConfig": self.__loadEditorConfig,
34 }
35
36 ############################################################################
37 ## Editor Config related methods below
38 ############################################################################
39
40 def __loadEditorConfig(self, params):
41 """
42 Private method to load the EditorConfig properties for the given
43 file name.
44
45 @param params dictionary containing the request data
46 @type dict
47 @return dictionary containing the reply data
48 @rtype dict
49 """
50 fileName = params["filename"]
51
52 if fileName:
53 try:
54 editorConfig = editorconfig.get_properties(fileName)
55 return {
56 "ok": True,
57 "config": editorConfig,
58 }
59 except editorconfig.EditorConfigError:
60 return {
61 "ok": False,
62 "config": {},
63 }
64
65 return {
66 "ok": True,
67 "config": {},
68 }

eric ide

mercurial