src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCheckerUtilities.py

branch
eric7
changeset 10046
35b27af462ef
parent 9653
e67609152c5e
child 10362
cfa7034cccf6
equal deleted inserted replaced
10045:f5c57f8d17a4 10046:35b27af462ef
6 """ 6 """
7 Module implementing utility functions for the code style checker dialogs. 7 Module implementing utility functions for the code style checker dialogs.
8 """ 8 """
9 9
10 from eric7.EricGui import EricPixmapCache 10 from eric7.EricGui import EricPixmapCache
11
12 from .translations import messageCategoryRe
11 13
12 14
13 def setItemIcon(itm, column, msgCode, severity=None): 15 def setItemIcon(itm, column, msgCode, severity=None):
14 """ 16 """
15 Function to set the icon of the passed message item. 17 Function to set the icon of the passed message item.
21 @param msgCode message code 23 @param msgCode message code
22 @type str 24 @type str
23 @param severity severity for message code 'S' (defaults to None) 25 @param severity severity for message code 'S' (defaults to None)
24 @type str (optional) 26 @type str (optional)
25 """ 27 """
26 if msgCode.startswith(("W", "-", "C", "M")): 28 match = messageCategoryRe.match(msgCode)
29 if match:
30 # the message code is OK
31 messageCategory = match.group(1)
32
33 if messageCategory in ("W", "C", "M"):
34 itm.setIcon(column, EricPixmapCache.getIcon("warning"))
35 elif messageCategory == "E":
36 itm.setIcon(column, EricPixmapCache.getIcon("syntaxError"))
37 elif messageCategory in ("A", "N"):
38 itm.setIcon(column, EricPixmapCache.getIcon("namingError"))
39 elif messageCategory == "D":
40 itm.setIcon(column, EricPixmapCache.getIcon("docstringError"))
41 elif messageCategory == "I":
42 itm.setIcon(column, EricPixmapCache.getIcon("imports"))
43 elif messageCategory == "NO":
44 itm.setIcon(column, EricPixmapCache.getIcon("nameOrderError"))
45 elif messageCategory == "P":
46 itm.setIcon(column, EricPixmapCache.getIcon("dirClosed"))
47 elif messageCategory == "Y":
48 itm.setIcon(column, EricPixmapCache.getIcon("filePython"))
49 elif messageCategory == "S":
50 if severity is None:
51 itm.setIcon(column, EricPixmapCache.getIcon("securityLow"))
52 else:
53 if severity == "H":
54 itm.setIcon(column, EricPixmapCache.getIcon("securityLow"))
55 elif severity == "M":
56 itm.setIcon(column, EricPixmapCache.getIcon("securityMedium"))
57 elif severity == "L":
58 itm.setIcon(column, EricPixmapCache.getIcon("securityHigh"))
59 else:
60 itm.setIcon(column, EricPixmapCache.getIcon("securityLow"))
61 else:
62 # unknown category prefix => warning
63 itm.setIcon(column, EricPixmapCache.getIcon("warning"))
64 elif msgCode.startswith("-"):
27 itm.setIcon(column, EricPixmapCache.getIcon("warning")) 65 itm.setIcon(column, EricPixmapCache.getIcon("warning"))
28 elif msgCode.startswith("E"):
29 itm.setIcon(column, EricPixmapCache.getIcon("syntaxError"))
30 elif msgCode.startswith(("A", "N")):
31 itm.setIcon(column, EricPixmapCache.getIcon("namingError"))
32 elif msgCode.startswith("D"):
33 itm.setIcon(column, EricPixmapCache.getIcon("docstringError"))
34 elif msgCode.startswith("I"):
35 itm.setIcon(column, EricPixmapCache.getIcon("imports"))
36 elif msgCode.startswith("P"):
37 itm.setIcon(column, EricPixmapCache.getIcon("dirClosed"))
38 elif msgCode.startswith("Y"):
39 itm.setIcon(column, EricPixmapCache.getIcon("filePython"))
40 elif msgCode.startswith("S"):
41 if severity is None:
42 itm.setIcon(column, EricPixmapCache.getIcon("securityLow"))
43 else:
44 if severity == "H":
45 itm.setIcon(column, EricPixmapCache.getIcon("securityLow"))
46 elif severity == "M":
47 itm.setIcon(column, EricPixmapCache.getIcon("securityMedium"))
48 elif severity == "L":
49 itm.setIcon(column, EricPixmapCache.getIcon("securityHigh"))
50 else:
51 itm.setIcon(column, EricPixmapCache.getIcon("securityLow"))
52 else: 66 else:
53 # unknown category prefix => warning 67 # unknown category prefix => warning
54 itm.setIcon(column, EricPixmapCache.getIcon("warning")) 68 itm.setIcon(column, EricPixmapCache.getIcon("warning"))

eric ide

mercurial