buddylistgrapher
annotate graph3.sh @ 4:b82703cc3dd4
added sed edition but still incomplete
author | meillo@marmaro.de |
---|---|
date | Mon, 28 May 2007 23:09:06 +0200 |
parents | |
children | e34b27b544b5 |
rev | line source |
---|---|
meillo@4 | 1 #!/bin/bash |
meillo@4 | 2 # |
meillo@4 | 3 # Autor: markus schnalke (prog.marmaro.de) |
meillo@4 | 4 # Autor: Julian Forster (www.ProgMaschine.de.vu) |
meillo@4 | 5 # |
meillo@4 | 6 |
meillo@4 | 7 |
meillo@4 | 8 if [ $# -eq 1 ]; then |
meillo@4 | 9 if [ $1 = '--version' ] ; then |
meillo@4 | 10 echo 'Buddylistgrapher (sed)' |
meillo@4 | 11 echo '======================' |
meillo@4 | 12 echo 'version 0.1' |
meillo@4 | 13 echo |
meillo@4 | 14 echo 'by Julian Forster (http://progmaschine.de.vu)' |
meillo@4 | 15 echo 'and Markus Schnalke (http://prog.marmaro.de)' |
meillo@4 | 16 exit 0 |
meillo@4 | 17 elif [ $1 = '--help' ] ; then |
meillo@4 | 18 echo 'Buddylistgrapher (sed)' |
meillo@4 | 19 echo '======================' |
meillo@4 | 20 echo |
meillo@4 | 21 echo "usage: $0 <input.txt>" |
meillo@4 | 22 echo |
meillo@4 | 23 echo "The grapher generates output to stdout." |
meillo@4 | 24 echo "This output is the input for the graphviz tools." |
meillo@4 | 25 echo |
meillo@4 | 26 echo "You can use it like this:" |
meillo@4 | 27 echo "$0 input.txt | dot -Tpng > pic.png" |
meillo@4 | 28 echo |
meillo@4 | 29 echo "ToDo:" |
meillo@4 | 30 echo "The program was written for one specific kind of input data," |
meillo@4 | 31 echo "so there is still some work to do to use it for general input." |
meillo@4 | 32 exit 0 |
meillo@4 | 33 else |
meillo@4 | 34 |
meillo@4 | 35 file=/tmp/`basename $0`-$$ |
meillo@4 | 36 file2=/tmp/`basename $0`-$$-2 |
meillo@4 | 37 |
meillo@4 | 38 # # collect all profil names (we only want them as nodes) |
meillo@4 | 39 # cat $file | while read line ; do |
meillo@4 | 40 # echo -n "`echo $line | grep "Profil von:" | awk '{print " " $3 " "}'`" >> $file2 |
meillo@4 | 41 # done |
meillo@4 | 42 # echo >> $file2 |
meillo@4 | 43 |
meillo@4 | 44 |
meillo@4 | 45 # TODO: fetch only edges for people having a profile |
meillo@4 | 46 |
meillo@4 | 47 # output |
meillo@4 | 48 echo "digraph G {" |
meillo@4 | 49 |
meillo@4 | 50 sed -n -e ' |
meillo@4 | 51 /^Profil/{ |
meillo@4 | 52 s/Profil von: \(.\+\)/"\1"/ |
meillo@4 | 53 h |
meillo@4 | 54 #p |
meillo@4 | 55 } |
meillo@4 | 56 |
meillo@4 | 57 |
meillo@4 | 58 /^Nachricht/{ |
meillo@4 | 59 G |
meillo@4 | 60 s/ - [-0-9]\+// |
meillo@4 | 61 s/Nachricht schreiben \(.\+\)\n/"\1" / |
meillo@4 | 62 s/"\(.\+\)" "\(.\+\)"/ "\2" -> "\1";/ |
meillo@4 | 63 |
meillo@4 | 64 # write out |
meillo@4 | 65 p |
meillo@4 | 66 } |
meillo@4 | 67 ' $1 |
meillo@4 | 68 |
meillo@4 | 69 |
meillo@4 | 70 echo "}" |
meillo@4 | 71 |
meillo@4 | 72 # rm $file $file2 |
meillo@4 | 73 exit 0 |
meillo@4 | 74 |
meillo@4 | 75 fi |
meillo@4 | 76 else |
meillo@4 | 77 echo "usage: $0 <input.txt>" |
meillo@4 | 78 exit 1 |
meillo@4 | 79 fi |