column offset in reports (offset_patch.diff)

added column offset to html and plain text reports. skipped the parseable format because I was worried adding the offset would break integration with IDEs etc.

download
# HG changeset patch
# User fawce <fawcett@gmail.com>
# Date 1308241107 14400
# Node ID a867ebb60a41c341b07a5d3906e67e3c378af7e0
# Parent  2599058e6521eef2917b89252395386fb39d5c61
added col_offset

diff -r 2599058e6521 -r a867ebb60a41 reporters/html.py
--- a/reporters/html.py	Tue Jan 11 15:41:15 2011 +0100
+++ b/reporters/html.py	Thu Jun 16 12:18:27 2011 -0400
@@ -35,7 +35,7 @@
 
     def add_message(self, msg_id, location, msg):
         """manage message of different type and in the context of path"""
-        module, obj, line = location[1:]
+        module, obj, line, col_offset = location[1:]
         if self.include_ids:
             sigle = msg_id
         else:
@@ -59,7 +59,7 @@
         """
         if self.msgs:
             # add stored messages to the layout
-            msgs = ['type', 'module', 'object', 'line', 'message']
+            msgs = ['type', 'module', 'object', 'line', 'col_offset', 'message']
             msgs += self.msgs
             sect = Section('Messages')
             layout.append(sect)
diff -r 2599058e6521 -r a867ebb60a41 reporters/text.py
--- a/reporters/text.py	Tue Jan 11 15:41:15 2011 +0100
+++ b/reporters/text.py	Thu Jun 16 12:18:27 2011 -0400
@@ -47,7 +47,7 @@
 
     def add_message(self, msg_id, location, msg):
         """manage message of different type and in the context of path"""
-        module, obj, line = location[1:]
+        module, obj, line, col_offset = location[1:]
         if module not in self._modules:
             if module:
                 self.writeln('************* Module %s' % module)
@@ -60,7 +60,7 @@
             sigle = msg_id
         else:
             sigle = msg_id[0]
-        self.writeln('%s:%3s%s: %s' % (sigle, line, obj, msg))
+        self.writeln('%s:%3s,%s%s: %s' % (sigle, line, col_offset, obj, msg))
 
     def _display(self, layout):
         """launch layouts display"""
@@ -85,7 +85,7 @@
 
     def add_message(self, msg_id, location, msg):
         """manage message of different type and in the context of path"""
-        path, _, obj, line = location
+        path, _, obj, line, _ = location
         if obj:
             obj = ', %s' % obj
         if self.include_ids:
diff -r 2599058e6521 -r a867ebb60a41 utils.py
--- a/utils.py	Tue Jan 11 15:41:15 2011 +0100
+++ b/utils.py	Thu Jun 16 12:18:27 2011 -0400
@@ -249,6 +249,11 @@
         """
         if line is None and node is not None:
             line = node.fromlineno
+        
+        col_offset = None
+        if hasattr(node, 'col_offset'):
+            col_offset = node.col_offset #measured in bytes for utf-8, divide by two for chars?
+            
         # should this message be displayed
         if not self.is_message_enabled(msgid, line):
             return
@@ -273,7 +278,7 @@
             module, obj = get_module_and_frameid(node)
             path = node.root().file
         # add the message
-        self.reporter.add_message(msgid, (path, module, obj, line or 1), msg)
+        self.reporter.add_message(msgid, (path, module, obj, line or 1, col_offset or 0), msg)
 
     def help_message(self, msgids):
         """display help messages for the given message identifiers"""