#!/usr/bin/python
"""
Strip varying data (PIDs, pointer values) from Gabble logs to make them
easier to compare.
"""

import re
import sys

def sanitise(line):
    return (
        re.sub('^(\*\* )?\(telepathy-gabble:\d+\)', '',
        re.sub('\x1b\[0m', '',
        re.sub('^RECV \[\d+\]', 'RECV [???]',
        re.sub('0x[0-9A-Fa-f]{5,8}', '0x???????',
        re.sub("('?<[^ ]+ [^>]*id=)[\"'][^\"']+[\"']",
            lambda m: m.group(1) + '"?????"', line))))))

def main():
    for line in sys.stdin:
        print sanitise(line),

if __name__ == '__main__':
    main()


@@ -111,16 +111,55 @@
 e.%0A%22%22%22%0A%0A
+from __future__ import with_statement%0A%0A
 import r
@@ -505,21 +505,28 @@
 ))%0A%0Adef 
-main(
+process(file
 ):%0A    f
@@ -540,17 +540,12 @@
  in 
-sys.stdin
+file
 :%0A  
@@ -573,16 +573,183 @@
 line),%0A%0A
+def main():%0A    if len(sys.argv) %3E 1:%0A        for fn in sys.argv%5B1:%5D:%0A            with open(fn) as f:%0A                process(f)%0A    else:%0A        process(sys.stdin)%0A%0A
 if __nam

Make log-strip.py process its arguments