Attached Documents

path for --line (line_option.patch)

path for --line (line_option.patch)

download
# HG changeset patch
# User Nicolas Cornu <ncornu@aldebaran-robotics.com>
# Date 1365899931 -7200
# Node ID a622621fa20430d698b200331b419c213fc90f69
# Parent  2dc4a9def9345fa141cb434d8d85d2a826d98b67
Add option --line to tell if we want print lines or not

diff -r 2dc4a9def934 -r a622621fa204 lint.py
--- a/lint.py	Mon Nov 12 14:24:55 2012 +0100
+++ b/lint.py	Sun Apr 14 02:38:51 2013 +0200
@@ -249,6 +249,11 @@
                   'help' : 'Add a comment according to your evaluation note. \
 This is used by the global evaluation report (RP0004).'}),
 
+                 ('line',
+                  {'default': 1, 'type' : 'yn', 'metavar' : '<y_or_n>',
+                   'group': 'Reports', 'level': 1,
+                   'help': 'Tells wether print out line numbers or not.'}),
+
                 ('enable',
                  {'type' : 'csv', 'metavar': '<msg ids>',
                   'short': 'e',
@@ -555,6 +560,7 @@
         name.
         """
         self.reporter.include_ids = self.config.include_ids
+        self.reporter.line = self.config.line
         self.reporter.symbols = self.config.symbols
         if not isinstance(files_or_modules, (list, tuple)):
             files_or_modules = (files_or_modules,)
diff -r 2dc4a9def934 -r a622621fa204 reporters/__init__.py
--- a/reporters/__init__.py	Mon Nov 12 14:24:55 2012 +0100
+++ b/reporters/__init__.py	Sun Apr 14 02:38:51 2013 +0200
@@ -41,6 +41,7 @@
     def __init__(self, output=None):
         self.linter = None
         self.include_ids = None
+        self.line = None
         self.symbols = None
         self.section = 0
         self.out = None
diff -r 2dc4a9def934 -r a622621fa204 reporters/html.py
--- a/reporters/html.py	Mon Nov 12 14:24:55 2012 +0100
+++ b/reporters/html.py	Sun Apr 14 02:38:51 2013 +0200
@@ -37,7 +37,11 @@
         """manage message of different type and in the context of path"""
         module, obj, line, col_offset = location[1:]
         sigle = self.make_sigle(msg_id)
-        self.msgs += [sigle, module, obj, str(line), str(col_offset), escape(msg)]
+        current_msg = [sigle, module, obj]
+        if self.line:
+            current_msg.append(str(line))
+        current_msg.extend([str(col_offset), escape(msg)])
+        self.msgs += current_msg
 
     def set_output(self, output=None):
         """set output stream
@@ -56,7 +60,10 @@
         """
         if self.msgs:
             # add stored messages to the layout
-            msgs = ['type', 'module', 'object', 'line', 'col_offset', 'message']
+            msgs = ['type', 'module', 'object']
+            if self.line:
+                msgs.append('line')
+            msgs.extend(['col_offset', 'message'])
             msgs += self.msgs
             sect = Section('Messages')
             layout.append(sect)
diff -r 2dc4a9def934 -r a622621fa204 reporters/text.py
--- a/reporters/text.py	Mon Nov 12 14:24:55 2012 +0100
+++ b/reporters/text.py	Sun Apr 14 02:38:51 2013 +0200
@@ -56,8 +56,12 @@
                 self.writeln('************* %s' % module)
         if obj:
             obj = ':%s' % obj
+        if self.line:
+            line = '%3s,' % line
+        else:
+            line = ""
         sigle = self.make_sigle(msg_id)
-        self.writeln('%s:%3s,%s%s: %s' % (sigle, line, col_offset, obj, msg))
+        self.writeln('%s:%s%s%s: %s' % (sigle, line, col_offset, obj, msg))
 
     def _display(self, layout):
         """launch layouts display"""
@@ -71,7 +75,7 @@
 
     <filename>:<linenum>:<msg>
     """
-    line_format = '%(path)s:%(line)s: [%(sigle)s%(obj)s] %(msg)s'
+    line_format = '%(path)s:%(line)s [%(sigle)s%(obj)s] %(msg)s'
 
     def __init__(self, output=sys.stdout, relative=True):
         TextReporter.__init__(self, output)
@@ -85,6 +89,10 @@
         path, _, obj, line, _ = location
         if obj:
             obj = ', %s' % obj
+        if self.line:
+            line = '%s:' % line
+        else:
+            line = ""
         sigle = self.make_sigle(msg_id)
         if self._prefix:
             path = path.replace(self._prefix, '')
@@ -139,9 +147,13 @@
             self.writeln(modsep)
             self._modules[module] = 1
         if obj:
-            obj = ':%s' % obj
+            obj = '%s:' % obj
+        if self.line:
+            line = '%3s:' %line
+        else:
+            line = ""
         sigle = self.make_sigle(msg_id)
         color, style = self._get_decoration(sigle)
         msg = colorize_ansi(msg, color, style)
         sigle = colorize_ansi(sigle, color, style)
-        self.writeln('%s:%3s%s: %s' % (sigle, line, obj, msg))
+        self.writeln('%s:%s%s %s' % (sigle, line, obj, msg))