From 2a6d586349d15d427da4e1c06ca18caa562e9e9d Mon Sep 17 00:00:00 2001 From: Heikki Hokkanen Date: Thu, 16 Aug 2007 15:11:10 +0300 Subject: [PATCH] Workaround for git repository. --- doc/TODO.txt | 4 ++-- gitstats | 13 ++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/doc/TODO.txt b/doc/TODO.txt index 96d1cf5..9ab6a92 100644 --- a/doc/TODO.txt +++ b/doc/TODO.txt @@ -5,11 +5,11 @@ - style class for images (
)? - better style for images & tables (keep next to each other?) +- parameter --style default.css [0.0.1] - copy/link gitstats.css to target dir -- rename to gitstats ? - - make $PROJECT_NAME a variable + - find out pwd or home dir? [Unsorted] - use sortable.js diff --git a/gitstats b/gitstats index 6bb69b3..7c4d27e 100755 --- a/gitstats +++ b/gitstats @@ -6,6 +6,7 @@ import datetime import glob import os import re +import shutil import sys import time @@ -23,6 +24,7 @@ def getkeyssortedbyvalues(dict): # TODO getdictkeyssortedbyvaluekey(dict, key) - eg. dict['author'] = { 'commits' : 512 } - ...key(dict, 'commits') class DataCollector: + """Manages data collection from a revision control repository.""" def __init__(self): self.stamp_created = time.time() pass @@ -230,7 +232,10 @@ class GitDataCollector(DataCollector): self.extensions[ext] = {'files': 0, 'lines': 0} self.extensions[ext]['files'] += 1 - self.extensions[ext]['lines'] += int(getoutput('wc -l < %s' % line, quiet = True)) + try: + self.extensions[ext]['lines'] += int(getoutput('wc -l < %s' % line, quiet = True)) + except: + print 'Warning: Could not count lines for file "%s"' % line def getActivityByDayOfWeek(self): return self.activity_by_day_of_week @@ -283,6 +288,7 @@ class GitDataCollector(DataCollector): return datetime.datetime.fromtimestamp(stamp).strftime('%Y-%m-%d') class ReportCreator: + """Creates the actual report based on given data.""" def __init__(self): pass @@ -294,6 +300,11 @@ class HTMLReportCreator(ReportCreator): def create(self, data, path): ReportCreator.create(self, data, path) + # TODO copy the CSS if it does not exist + if not os.path.exists(path + '/gitstats.css'): + #shutil.copyfile('') + pass + f = open(path + "/index.html", 'w') format = '%Y-%m-%d %H:%m:%S' self.printHeader(f) -- 2.11.4.GIT