|
|
@@ -6,6 +6,7 @@ import datetime
|
|
6
|
6
|
import glob
|
|
7
|
7
|
import os
|
|
8
|
8
|
import re
|
|
|
9
|
+import shutil
|
|
9
|
10
|
import sys
|
|
10
|
11
|
import time
|
|
11
|
12
|
|
|
|
@@ -23,6 +24,7 @@ def getkeyssortedbyvalues(dict):
|
|
23
|
24
|
# TODO getdictkeyssortedbyvaluekey(dict, key) - eg. dict['author'] = { 'commits' : 512 } - ...key(dict, 'commits')
|
|
24
|
25
|
|
|
25
|
26
|
class DataCollector:
|
|
|
27
|
+ """Manages data collection from a revision control repository."""
|
|
26
|
28
|
def __init__(self):
|
|
27
|
29
|
self.stamp_created = time.time()
|
|
28
|
30
|
pass
|
|
|
@@ -230,7 +232,10 @@ class GitDataCollector(DataCollector):
|
|
230
|
232
|
self.extensions[ext] = {'files': 0, 'lines': 0}
|
|
231
|
233
|
|
|
232
|
234
|
self.extensions[ext]['files'] += 1
|
|
233
|
|
- self.extensions[ext]['lines'] += int(getoutput('wc -l < %s' % line, quiet = True))
|
|
|
235
|
+ try:
|
|
|
236
|
+ self.extensions[ext]['lines'] += int(getoutput('wc -l < %s' % line, quiet = True))
|
|
|
237
|
+ except:
|
|
|
238
|
+ print 'Warning: Could not count lines for file "%s"' % line
|
|
234
|
239
|
|
|
235
|
240
|
def getActivityByDayOfWeek(self):
|
|
236
|
241
|
return self.activity_by_day_of_week
|
|
|
@@ -283,6 +288,7 @@ class GitDataCollector(DataCollector):
|
|
283
|
288
|
return datetime.datetime.fromtimestamp(stamp).strftime('%Y-%m-%d')
|
|
284
|
289
|
|
|
285
|
290
|
class ReportCreator:
|
|
|
291
|
+ """Creates the actual report based on given data."""
|
|
286
|
292
|
def __init__(self):
|
|
287
|
293
|
pass
|
|
288
|
294
|
|
|
|
@@ -294,6 +300,11 @@ class HTMLReportCreator(ReportCreator):
|
|
294
|
300
|
def create(self, data, path):
|
|
295
|
301
|
ReportCreator.create(self, data, path)
|
|
296
|
302
|
|
|
|
303
|
+ # TODO copy the CSS if it does not exist
|
|
|
304
|
+ if not os.path.exists(path + '/gitstats.css'):
|
|
|
305
|
+ #shutil.copyfile('')
|
|
|
306
|
+ pass
|
|
|
307
|
+
|
|
297
|
308
|
f = open(path + "/index.html", 'w')
|
|
298
|
309
|
format = '%Y-%m-%d %H:%m:%S'
|
|
299
|
310
|
self.printHeader(f)
|