Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: third_party/pylint/reporters/json.py

Issue 876793002: pylint: upgrade to 1.4.1 (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/pylint/lint.py ('k') | third_party/pylint/reporters/text.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright (c) 2003-2014 LOGILAB S.A. (Paris, FRANCE).
2 # This program is free software; you can redistribute it and/or modify it under
3 # the terms of the GNU General Public License as published by the Free Software
4 # Foundation; either version 2 of the License, or (at your option) any later
5 # version.
6 #
7 # This program is distributed in the hope that it will be useful, but WITHOUT
8 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
10 #
11 # You should have received a copy of the GNU General Public License along with
12 # this program; if not, write to the Free Software Foundation, Inc.,
13 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
14 """JSON reporter"""
15 from __future__ import absolute_import, print_function
16
17 import json
18 import sys
19 from cgi import escape
20
21 from pylint.interfaces import IReporter
22 from pylint.reporters import BaseReporter
23
24
25 class JSONReporter(BaseReporter):
26 """Report messages and layouts in JSON."""
27
28 __implements__ = IReporter
29 name = 'json'
30 extension = 'json'
31
32 def __init__(self, output=sys.stdout):
33 BaseReporter.__init__(self, output)
34 self.messages = []
35
36 def handle_message(self, message):
37 """Manage message of different type and in the context of path."""
38
39 self.messages.append({
40 'type': message.category,
41 'module': message.module,
42 'obj': message.obj,
43 'line': message.line,
44 'column': message.column,
45 'path': message.path,
46 'symbol': message.symbol,
47 'message': escape(message.msg or ''),
48 })
49
50 def _display(self, layout):
51 """Launch layouts display"""
52 if self.messages:
53 print(json.dumps(self.messages, indent=4), file=self.out)
54
55
56 def register(linter):
57 """Register the reporter classes with the linter."""
58 linter.register_reporter(JSONReporter)
OLDNEW
« no previous file with comments | « third_party/pylint/lint.py ('k') | third_party/pylint/reporters/text.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698