src/eric7/Plugins/CheckerPlugins/SyntaxChecker/tomlCheckSyntax.py

branch
eric7
changeset 9467
1798115ba35c
parent 9292
a5c8a0213fe3
child 9473
3f23dbf37dbe
equal deleted inserted replaced
9466:0406710080ba 9467:1798115ba35c
174 errors), the message, a list with arguments for the message) 174 errors), the message, a list with arguments for the message)
175 @rtype dict 175 @rtype dict
176 """ 176 """
177 try: 177 try:
178 import tomlkit 178 import tomlkit
179 from tomlkit.exceptions import ParseError 179 from tomlkit.exceptions import ParseError, KeyAlreadyPresent
180 except ImportError: 180 except ImportError:
181 error = "tomlkit not available. Install it via the PyPI interface." 181 error = "tomlkit not available. Install it via the PyPI interface."
182 return [{"error": (file, 0, 0, "", error)}] 182 return [{"error": (file, 0, 0, "", error)}]
183 183
184 codestring = normalizeCode(codestring) 184 codestring = normalizeCode(codestring)
193 193
194 cline = min(len(codestring.splitlines()), int(line)) - 1 194 cline = min(len(codestring.splitlines()), int(line)) - 1
195 code = codestring.splitlines()[cline] 195 code = codestring.splitlines()[cline]
196 196
197 return [{"error": (file, line, column, code, error)}] 197 return [{"error": (file, line, column, code, error)}]
198 except KeyAlreadyPresent as exc:
199 return [{"error": (file, 0, 0, "", str(exc))}]
198 200
199 return [{}] 201 return [{}]

eric ide

mercurial