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 [{}] |