Mercurial > ~mikael > mcabber > hg
view mcabber/contrib/filter_statusmsg.py @ 1497:35020a2ed115
Do not use srand()/rand() if better alternatives exist (mirabilos)
arc4random(3) is a self-seeding PRNG available on a lot of OSes (all BSDs,
Darwin / Mac OSX, Interix / Microsoft® Services for Unix, Windows® 2003SR1,
Windows® Vista, Debian with the new libbsd package installed, ???) and much
better than srand(3)/rand(3).
Thanks to GNU autoconf, this can be made portable.
http://www.mirbsd.org/man/arc4random.3
//mirabilos
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Mon, 30 Jun 2008 23:13:50 +0200 |
parents | c31b1c41929c |
children |
line wrap: on
line source
#!/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 if [[ ! -h $i ]]; then ./filter_statusmsg.py $i > foo; mv foo $i; fi; 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