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

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

Issue 10447014: Add pylint to depot_tools. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Fix unittests. Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/pylint/pyreverse/writer.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
new file mode 100644
index 0000000000000000000000000000000000000000..0582a6f06c112bd67876ccbc66594436e28eaee6
--- /dev/null
+++ b/third_party/pylint/reporters/__init__.py
@@ -0,0 +1,79 @@
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+"""utilities methods and classes for reporters
+
+Copyright (c) 2000-2003 LOGILAB S.A. (Paris, FRANCE).
+http://www.logilab.fr/ -- mailto:contact@logilab.fr
+"""
+
+import sys, locale
+
+CMPS = ['=', '-', '+']
+
+def diff_string(old, new):
+ """given a old and new int value, return a string representing the
+ difference
+ """
+ diff = abs(old - new)
+ diff_str = "%s%s" % (CMPS[cmp(old, new)], diff and ('%.2f' % diff) or '')
+ return diff_str
+
+
+class EmptyReport(Exception):
+ """raised when a report is empty and so should not be displayed"""
+
+class BaseReporter:
+ """base class for reporters"""
+
+ extension = ''
+
+ def __init__(self, output=None):
+ self.linter = None
+ self.include_ids = None
+ self.section = 0
+ self.out = None
+ self.out_encoding = None
+ self.set_output(output)
+
+ def set_output(self, output=None):
+ """set output stream"""
+ self.out = output or sys.stdout
+ # py3k streams handle their encoding :
+ if sys.version_info >= (3, 0):
+ self.encode = lambda x: x
+ return
+
+ def encode(string):
+ if not isinstance(string, unicode):
+ return string
+ encoding = (getattr(self.out, 'encoding', None) or
+ locale.getdefaultlocale()[1] or
+ sys.getdefaultencoding())
+ return string.encode(encoding)
+ self.encode = encode
+
+ def writeln(self, string=''):
+ """write a line in the output buffer"""
+ print >> self.out, self.encode(string)
+
+ def display_results(self, layout):
+ """display results encapsulated in the layout tree"""
+ self.section = 0
+ if self.include_ids and hasattr(layout, 'report_id'):
+ layout.children[0].children[0].data += ' (%s)' % layout.report_id
+ self._display(layout)
+
+ def _display(self, layout):
+ """display the layout"""
+ raise NotImplementedError()
+
« no previous file with comments | « third_party/pylint/pyreverse/writer.py ('k') | third_party/pylint/reporters/guireporter.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698