#!/usr/bin/env python # -*- coding: utf-8 -*- # Written by Rasmus Toftdahl Olesen # Modified slightly by David A. Wheeler # Released under the GNU General Public License v. 2 or higher from string import * import sys NAME = "sloc2html" VERSION = "0.0.2" if len(sys.argv) != 2: print "Usage:" print "\t" + sys.argv[0] + " " print "\nThe output of sloccount should be with --wide and --multiproject formatting" sys.exit() colors = { "python" : "blue", "ansic" : "yellow", "perl" : "purple", "cpp" : "green", "sh" : "red", "yacc" : "brown", "lex" : "silver", # Feel free to make more specific colors. "ruby" : "maroon", "cs" : "gray", "java" : "navy", "ada" : "olive", "lisp" : "fuchsia", "objc" : "purple", "fortran" : "purple", "cobol" : "purple", "pascal" : "purple", "asm" : "purple", "csh" : "purple", "tcl" : "purple", "exp" : "purple", "awk" : "purple", "sed" : "purple", "makefile" : "purple", "sql" : "purple", "php" : "purple", "modula3" : "purple", "ml" : "purple", "haskell" : "purple" } print "" print "" print "Counted Source Lines of Code (SLOC)" print "" print "" print "

Counted Source Lines of Code

" file = open ( sys.argv[1], "r" ) print "

Projects

" line = "" while line != "SLOC\tDirectory\tSLOC-by-Language (Sorted)\n": line = file.readline() print "" print "" line = file.readline() while line != "\n": num, project, langs = split ( line ) print "" line = file.readline() print "
LinesProjectLanguage distribution
" + num + "" + project + "" print "" for lang in split ( langs, "," ): # print lang, type(lang) if lang != "(none)": # El directorio CVS no se ignora en SLOCCount y obviamente sus ficheros no están en ningún lenguaje (salida SLOCCount = "(none)") l, n = split ( lang, "=" ) print "" print "
" + l + "=" + n + " (" + str(int(float(n) / float(num) * 100)) + "%)
" print "
" print "

Languages

" while line != "Totals grouped by language (dominant language first):\n": line = file.readline() print "" print "" line = file.readline() while line != "\n": lang, lines, per = split ( line ) lang = lang[:-1] print "" line = file.readline() print "
LanguageLines
" + lang + "" + lines + " " + per + "
" print "

Totals

" while line == "\n": line = file.readline() print "" print "" line = file.readline() print "" line = file.readline() line = file.readline() print "" line = file.readline() line = file.readline() print "" print "
Total Physical Lines of Code (SLOC):" + strip(split(line,"=")[1]) + "
Estimated development effort:" + strip(split(line,"=")[1]) + " person-years (person-months)
Schedule estimate:" + strip(split(line,"=")[1]) + " years (months)
Total estimated cost to develop:" + strip(split(line,"=")[1]) + "
" file.close() print "Please credit this data as \"generated using 'SLOCCount' by David A. Wheeler.\"\n" print "" print ""