tips:gource_analysis
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
tips:gource_analysis [2010-05-16 15:41] – created 79.85.106.47 | tips:gource_analysis [2010-05-20 15:53] (current) – some versions of gource need RGB hex colour to be in upper case 193.9.13.135 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Visualize Changes in Gource ====== | ||
+ | I am fond of the wonderful videos made with [[http:// | ||
- | <code python> | + | |
+ | More information on this [[http:// | ||
+ | |||
+ | I wrote a small python script to generate logs from **.changes** files that can be used by Gource : | ||
+ | |||
+ | <code python | ||
# | # | ||
Line 13: | Line 20: | ||
""" | """ | ||
+ | import glob | ||
import os.path | import os.path | ||
import getopt | import getopt | ||
Line 19: | Line 26: | ||
import re | import re | ||
+ | WHITE = " | ||
+ | GREEN = " | ||
+ | vector = (1,10,100) | ||
+ | start_page_name = " | ||
+ | def RGBToHTMLColor(rgb_tuple): | ||
+ | """ | ||
+ | hexcolor = '# | ||
+ | # that's it! ' | ||
+ | return hexcolor | ||
+ | |||
+ | def HTMLColorToRGB(colorstring): | ||
+ | """ | ||
+ | colorstring = colorstring.strip() | ||
+ | if colorstring[0] == '#': | ||
+ | if len(colorstring) != 6: | ||
+ | raise ValueError, "input #%s is not in #RRGGBB format" | ||
+ | r, g, b = colorstring[: | ||
+ | r, g, b = [int(n, 16) for n in (r, g, b)] | ||
+ | return (r, g, b) | ||
+ | |||
+ | def colormodify(colorstring): | ||
+ | rgb_tuple = HTMLColorToRGB(colorstring) | ||
+ | r, g, b = (rgb_tuple[0]+vector[0]) % 255, | ||
+ | return RGBToHTMLColor((r, | ||
+ | |||
+ | def listdirectory(path, | ||
+ | l = glob.glob(path+"/ | ||
+ | for i in l: | ||
+ | if os.path.isdir(i): | ||
+ | listdirectory(i, | ||
+ | else: | ||
+ | readfile(i, | ||
def listdirectory2(path): | def listdirectory2(path): | ||
Line 29: | Line 68: | ||
if (re.search(' | if (re.search(' | ||
fichier = os.path.join(root, | fichier = os.path.join(root, | ||
- | myfile = open(fichier, | + | |
- | for line in myfile.readlines(): | + | |
- | mots = line.split() | + | def readfile(fichier, |
- | if len(mots)> | + | """ |
- | resultat = mots[0] + " | + | file a log line for Gource |
- | resultat += mots[5] + " | + | """ |
- | resultat += translate(mots[2]) + " | + | |
- | resultat += fichier | + | |
- | print resultat | + | for line in myfile.readlines(): |
- | elif len(mots)==4: | + | mots = line.split(' |
- | | + | if len(mots)> |
- | resultat += translate(mots[2]) + " | + | resultat = mots[0] + " |
- | resultat += fichier | + | if mots[4] == '': |
- | print resultat | + | mots[4] |
- | myfile.close() | + | |
+ | resultat += translate(mots[2]) + " | ||
+ | resultat += mots[3].replace(' | ||
+ | | ||
+ | resultat | ||
+ | | ||
+ | | ||
+ | print resultat | ||
+ | myfile.close() | ||
def translate(mot): | def translate(mot): | ||
""" | """ | ||
- | C -> A | + | |
- | E -> M | + | |
+ | D (also dc and hc from discssion plugin) -> D | ||
other -> M | other -> M | ||
""" | """ | ||
- | if mot == " | + | if mot.upper |
return " | return " | ||
- | elif mot == " | + | elif mot.upper |
return " | return " | ||
+ | elif mot.upper == " | ||
+ | return " | ||
else: | else: | ||
return " | return " | ||
Line 71: | Line 122: | ||
sys.exit() | sys.exit() | ||
elif opt in (" | elif opt in (" | ||
- | print listdirectory2(arg) | + | print listdirectory(arg,WHITE) |
Line 91: | Line 142: | ||
main(sys.argv[1: | main(sys.argv[1: | ||
+ | </ | ||
+ | launch the script inside your dokuwiki directory : | ||
+ | <code bash> | ||
+ | python gourcedoku.py -d ~/ | ||
+ | </ | ||
+ | then you can use Gource to watch logs : | ||
+ | < | ||
+ | gource --log-format custom dokusort.log --stop-position 1.0 --stop-on-idle --file-idle-time 10000000 | ||
</ | </ |
tips/gource_analysis.1274017287.txt.gz · Last modified: 2010-05-16 15:41 by 79.85.106.47