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

Unified Diff: third_party/pylint/reporters/__init__.py

Issue 753543006: pylint: upgrade to 1.4.0 (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 6 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/pylint/pyreverse/utils.py ('k') | third_party/pylint/reporters/guireporter.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/pylint/reporters/__init__.py
diff --git a/third_party/pylint/reporters/__init__.py b/third_party/pylint/reporters/__init__.py
index 12d193f5d6982c5af945d63abba168947f54a119..ea3281ff7e8e9f300021b77f01f5e40ae593c223 100644
--- a/third_party/pylint/reporters/__init__.py
+++ b/third_party/pylint/reporters/__init__.py
@@ -12,12 +12,12 @@
# this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
"""utilities methods and classes for reporters"""
+from __future__ import print_function
import sys
import locale
import os
-from pylint.utils import MSG_TYPES
from pylint import utils
@@ -25,13 +25,9 @@ CMPS = ['=', '-', '+']
# py3k has no more cmp builtin
if sys.version_info >= (3, 0):
- def cmp(a, b):
+ def cmp(a, b): # pylint: disable=redefined-builtin
return (a > b) - (a < b)
-if sys.version_info < (2, 6):
- import stringformat
- stringformat.init(True)
-
def diff_string(old, new):
"""given a old and new int value, return a string representing the
difference
@@ -41,27 +37,6 @@ def diff_string(old, new):
return diff_str
-class Message(object):
- """This class represent a message to be issued by the reporters"""
-
- def __init__(self, reporter, msg_id, location, msg):
- self.msg_id = msg_id
- self.abspath, self.module, self.obj, self.line, self.column = location
- self.path = self.abspath.replace(reporter.path_strip_prefix, '')
- self.msg = msg
- self.C = msg_id[0]
- self.category = MSG_TYPES[msg_id[0]]
- self.symbol = reporter.linter.msgs_store.check_message_id(msg_id).symbol
-
- def format(self, template):
- """Format the message according to the given template.
-
- The template format is the one of the format method :
- cf. http://docs.python.org/2/library/string.html#formatstrings
- """
- return template.format(**(self.__dict__))
-
-
class BaseReporter(object):
"""base class for reporters
@@ -82,9 +57,16 @@ class BaseReporter(object):
# Build the path prefix to strip to get relative paths
self.path_strip_prefix = os.getcwd() + os.sep
+ def handle_message(self, msg):
+ """Handle a new message triggered on the current file.
+
+ Invokes the legacy add_message API by default."""
+ self.add_message(
+ msg.msg_id, (msg.abspath, msg.module, msg.obj, msg.line, msg.column),
+ msg.msg)
+
def add_message(self, msg_id, location, msg):
- """Client API to send a message"""
- # Shall we store the message objects somewhere, do some validity checking ?
+ """Deprecated, do not use."""
raise NotImplementedError
def set_output(self, output=None):
@@ -109,7 +91,7 @@ class BaseReporter(object):
def writeln(self, string=''):
"""write a line in the output buffer"""
- print >> self.out, self.encode(string)
+ print(self.encode(string), file=self.out)
def display_results(self, layout):
"""display results encapsulated in the layout tree"""
@@ -133,6 +115,19 @@ class BaseReporter(object):
pass
+class CollectingReporter(BaseReporter):
+ """collects messages"""
+
+ name = 'collector'
+
+ def __init__(self):
+ BaseReporter.__init__(self)
+ self.messages = []
+
+ def handle_message(self, msg):
+ self.messages.append(msg)
+
+
def initialize(linter):
"""initialize linter with reporters in this package """
utils.register_plugins(linter, __path__[0])
« no previous file with comments | « third_party/pylint/pyreverse/utils.py ('k') | third_party/pylint/reporters/guireporter.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698