Mercurial > hg
changeset 1119:c68b3c9f616e
Merge Franky's contrib scripts
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Sat, 06 Jan 2007 12:15:28 +0100 |
parents | 14e458020e23 (current diff) 71422d407a34 (diff) |
children | c15e935a3b3f |
files | |
diffstat | 2 files changed, 61 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mcabber/contrib/filter_statusmsg.py Sat Jan 06 12:15:28 2007 +0100 @@ -0,0 +1,23 @@ +#!/usr/bin/env python +# This script can be used to delete status messages from history files. +# +# If you want to clean all histories from status messages: +# $ for i in ~/.mcabber/histo/*; do ./filter_statusmsg.py $i > foo; mv foo $i; done +# +# Frank Zschockelt, 05.01.2007 +import sys + +if(len(sys.argv) != 2): + print "usage:",sys.argv[0],"history > history_without_status" + sys.exit(0) +file=open(sys.argv[1], "r") +lines=file.readlines() +file.close() + +i=0 +while(i<len(lines)): + l=int(lines[i][22:25]) + if(lines[i][0] != 'S'): + for s in lines[i:i+l+1]: + print s, + i+=l+1
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mcabber/contrib/merge_history.py Sat Jan 06 12:15:28 2007 +0100 @@ -0,0 +1,38 @@ +#!/usr/bin/env python +# This script is provided under the terms of the GNU General Public License, +# see the file COPYING in the root mcabber source directory. +# +# Frank Zschockelt, 05.01.2007 + +import sys + +if(len(sys.argv) != 3): + print "usage:",sys.argv[0],"histA histB > histA+B" + sys.exit(0) +file=open(sys.argv[1], "r") +linesA=file.readlines() +file.close() +file=open(sys.argv[2], "r") +linesB=file.readlines() +file.close() + +i=j=0 +while(i<len(linesA) and j < len(linesB)): + if(linesA[i][3:20] <= linesB[j][3:20]): + l=int(linesA[i][22:25]) + for s in linesA[i:i+l+1]: + print s, + if(linesA[i]==linesB[j]): + j+=l+1 + i+=l+1 + else: + l=int(linesB[j][22:25]) + for s in linesB[j:j+l+1]: + print s, + j+=l+1 + +for s in linesA[i:len(linesA)]: + print s, +for s in linesB[j:len(linesB)]: + print s, +