瀏覽代碼

Workaround for git repository.

Heikki Hokkanen 18 年之前
父節點
當前提交
2a6d586349
共有 2 個文件被更改,包括 14 次插入3 次删除
  1. 2
    2
      doc/TODO.txt
  2. 12
    1
      gitstats

+ 2
- 2
doc/TODO.txt 查看文件

@@ -5,11 +5,11 @@
5 5
 
6 6
 - style class for images (<div class="graph">)?
7 7
 - better style for images & tables (keep next to each other?)
8
+- parameter --style default.css
8 9
 
9 10
 [0.0.1]
10 11
 - copy/link gitstats.css to target dir
11
-- rename to gitstats ?
12
-	- make $PROJECT_NAME a variable
12
+	- find out pwd or home dir?
13 13
 
14 14
 [Unsorted]
15 15
 - use sortable.js

+ 12
- 1
gitstats 查看文件

@@ -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)