DokuWiki

It's better when it's simple

User Tools

Site Tools


tips:gource_analysis

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tips:gource_analysis [2010-05-16 15:51] 79.85.106.47tips: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:
-I am fond of the wonderful videos made with Gource. This tool makes a representation of changes made on a version control system like git or SVN. Then I remember that DokuWiki is also a version control system like any other ... Just have a look in the folder tree to find the directory **dokuwiki/data/meta** in which the files ***. changes** contain exactly the information needed. +====== Visualize Changes in Gource ======
  
 +I am fond of the wonderful videos made with [[http://code.google.com/p/gource/|Gource]]. This tool makes a representation of changes made on a version control system like git or SVN. Then I remember that DokuWiki is also a version control system like any other ... Just have a look in the folder tree to find the directory ''dokuwiki/data/meta'' in which the files ''*.changes'' contain exactly the information needed. 
  
-More information on this [[http://wolverinex02.blogspot.com/2010/05/gource-et-dokuwiki.html|blog]] (french version). 
  
 +More information on this [[http://wolverinex02.blogspot.com/2010/05/gource-et-dokuwiki.html|blog]] (french version) or a translate version on this [[http://servalx02.blogspot.com/2010/05/gource-and-dokuwiki.html|blog]].
  
 I wrote a small python script to generate logs from **.changes** files that can be used by Gource : I wrote a small python script to generate logs from **.changes** files that can be used by Gource :
  
-<code python>+<code python gourcedoku.py>
 #!/bin/python #!/bin/python
  
Line 19: Line 20:
  
 """ """
 +import glob
 import os.path import os.path
 import getopt import getopt
Line 25: Line 26:
 import re import re
  
 +WHITE = "11FFAA"
 +GREEN = "00F000"
 +vector = (1,10,100)
 +start_page_name = "start"
  
 +def RGBToHTMLColor(rgb_tuple):
 +    """ convert an (R, G, B) tuple to #RRGGBB """
 +    hexcolor = '#%02X%02X%02X' % rgb_tuple
 +    # that's it! '%02x' means zero-padded, 2-digit hex values
 +    return hexcolor
 +
 +def HTMLColorToRGB(colorstring):
 +    """ convert #RRGGBB to an (R, G, B) tuple """
 +    colorstring = colorstring.strip()
 +    if colorstring[0] == '#': colorstring = colorstring[1:]
 +    if len(colorstring) != 6:
 +        raise ValueError, "input #%s is not in #RRGGBB format" % colorstring
 +    r, g, b = colorstring[:2], colorstring[2:4], colorstring[4:]
 +    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,(rgb_tuple[1]+vector[1]) % 255,(rgb_tuple[2]+vector[2]) % 255
 +    return RGBToHTMLColor((r, g, b))
 +
 +def listdirectory(path,color):
 +    l = glob.glob(path+"/*")
 +    for i in l:
 +        if os.path.isdir(i):
 +                listdirectory(i,colormodify(color))
 +        else:
 +                readfile(i,color)
  
 def listdirectory2(path): def listdirectory2(path):
Line 35: Line 68:
             if  (re.search('\.changes$', i)):             if  (re.search('\.changes$', i)):
                 fichier = os.path.join(root, i)                 fichier = os.path.join(root, i)
-                myfile = open(fichier, 'r'+                readfile(fichier,GREEN) 
-                for line in myfile.readlines(): + 
-                    mots = line.split() +def readfile(fichier,color): 
-                    if len(mots)>=5+    """read the file and output for each line of this 
-                        resultat = mots[0] + "|" +       file a log line for Gource 
-                        resultat += mots[5] + "|" +    """ 
-                        resultat += translate(mots[2]) + "|" + 
-                        resultat += fichier +    myfile = open(fichier, 'r'
-                        print resultat +    for line in myfile.readlines(): 
-                    elif len(mots)==4+        mots = line.split('\t'
-                        resultat = mots[0+ "|Anonymous|" +        if len(mots)>=6
-                        resultat +translate(mots[2]) + "|" +            resultat = mots[0] + "|" 
-                        resultat += fichier +            if mots[4] == '': 
-                        print resultat +                mots[4]  = 'Anonymous' 
-                myfile.close()+            resultat += mots[4] + "|" 
 +            resultat += translate(mots[2]) + "|" 
 +            resultat += mots[3].replace(':', '/') 
 +            if mots[3].rfind(start_page_name) == len(mots[3])-len(start_page_name): 
 +                resultat +"|" + color 
 +            else: 
 +                resultat += "|" + colormodify(color) 
 +            print resultat 
 +    myfile.close() 
  
 def translate(mot): def translate(mot):
     """translate the dokuwiki vocabulary to the gource one     """translate the dokuwiki vocabulary to the gource one
-       C -> A +       (also cc and sc from discussion plugin) ->A 
-       E -> M+       (also ec from discussion plugin) -> M 
 +       D (also dc and hc from discssion plugin) -> D
        other -> M         other -> M 
     """     """
-    if mot == "C":+    if mot.upper == "C" or mot == 'cc' or mot == 'sc':
         return "A"         return "A"
-    elif mot == "E":+    elif mot.upper == "E" or mot == 'ec':
         return "M"         return "M"
 +    elif mot.upper == "D" or mot == 'dc' or mot == 'hc':
 +        return "D"
     else:     else:
         return "M"         return "M"
Line 77: Line 122:
             sys.exit()             sys.exit()
         elif opt in ("-d","--dokuwiki"):         elif opt in ("-d","--dokuwiki"):
-            print listdirectory2(arg)+            print listdirectory(arg,WHITE)
  
  
Line 98: Line 143:
  
 </code> </code>
- +launch the script inside your dokuwiki directory :   
-launch the script inside your dokuwiki directory : +<code bash>  
-<code bash>+
 python gourcedoku.py -d ~/Sites/MyDokuwiki/ | sort > dokusort.log python gourcedoku.py -d ~/Sites/MyDokuwiki/ | sort > dokusort.log
 </code> </code>
tips/gource_analysis.txt · Last modified: 2010-05-20 15:53 by 193.9.13.135

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki