Browse Source

Files: Extensions (table).

Heikki Hokkanen 18 years ago
parent
commit
18b9921556
2 changed files with 31 additions and 12 deletions
  1. 2
    10
      doc/TODO.txt
  2. 29
    2
      statgit

+ 2
- 10
doc/TODO.txt View File

54
 	- List of authors
54
 	- List of authors
55
 		- show only first 10 and rest on separate page?
55
 		- show only first 10 and rest on separate page?
56
 	- DONE (T): author, commits (%), LOC?, first commit, last commit
56
 	- DONE (T): author, commits (%), LOC?, first commit, last commit
57
+		- TODO days/time as developer
57
 	- DONE (T): Developer of the Month: month, author, commits, LOC?
58
 	- DONE (T): Developer of the Month: month, author, commits, LOC?
58
 	- DONE (T): Author of Year
59
 	- DONE (T): Author of Year
59
 
60
 
64
 	- Average revisions per file
65
 	- Average revisions per file
65
 	- DONE (G) File Count by Date: x = date, y = files
66
 	- DONE (G) File Count by Date: x = date, y = files
66
 	- (G) Average file size: x = date, y = lines/file
67
 	- (G) Average file size: x = date, y = lines/file
67
-	- (T) File Extensions (or mime types from "file"?): extension, files (%), lines (%), lines/file
68
-		- extensions: ext -> { files, lines? }
69
-			- git-ls-files -> basename -> check ext
68
+	- DONE (T) File Extensions (or mime types from "file"?): extension, files (%), lines (%), lines/file
70
 	- (T) Largest Files?
69
 	- (T) Largest Files?
71
 	- (T) Files With Most Revisions?
70
 	- (T) Files With Most Revisions?
72
 
71
 
127
 - "Repo heatmap"?
126
 - "Repo heatmap"?
128
 - LOC and Churn
127
 - LOC and Churn
129
 
128
 
130
-[Graphics]
131
-- Use gnuplot, graphviz etc ?
132
-
133
-[Usage]
134
-- $ statgit [-o html] /path/to/git /output/dir
135
-
136
 [name]
129
 [name]
137
 - statgit or gitstats (no google hits for either)
130
 - statgit or gitstats (no google hits for either)
138
 
131
 
139
 [Misc]
132
 [Misc]
140
 - use sortable.js ?
133
 - use sortable.js ?
141
 - could show some statistics from last year, month, etc... pisg-like?
134
 - could show some statistics from last year, month, etc... pisg-like?
142
-- style: tabs at top for different pages

+ 29
- 2
statgit View File

11
 
11
 
12
 GNUPLOT_COMMON = 'set terminal png transparent\nset size 0.5,0.5\n'
12
 GNUPLOT_COMMON = 'set terminal png transparent\nset size 0.5,0.5\n'
13
 
13
 
14
-def getoutput(cmd):
15
-	print '>> %s' % cmd
14
+def getoutput(cmd, quiet = False):
15
+	if not quiet:
16
+		print '>> %s' % cmd
16
 	output = commands.getoutput(cmd)
17
 	output = commands.getoutput(cmd)
17
 	return output
18
 	return output
18
 
19
 
204
 				continue
205
 				continue
205
 			(stamp, files) = parts[0:2]
206
 			(stamp, files) = parts[0:2]
206
 			self.files_by_stamp[int(stamp)] = int(files)
207
 			self.files_by_stamp[int(stamp)] = int(files)
208
+
209
+		# extensions
210
+		self.extensions = {} # extension -> files, lines
211
+		lines = getoutput('git-ls-files').split('\n')
212
+		for line in lines:
213
+			base = os.path.basename(line)
214
+			if base.find('.') == -1:
215
+				ext = ''
216
+			else:
217
+				ext = base[(base.rfind('.') + 1):]
218
+
219
+			if ext not in self.extensions:
220
+				self.extensions[ext] = {'files': 0, 'lines': 0}
221
+
222
+			self.extensions[ext]['files'] += 1
223
+			self.extensions[ext]['lines'] += int(getoutput('wc -l < "%s"' % line, quiet = True))
207
 	
224
 	
208
 	def getActivityByDayOfWeek(self):
225
 	def getActivityByDayOfWeek(self):
209
 		return self.activity_by_day_of_week
226
 		return self.activity_by_day_of_week
447
 		f.write('<dt>Average file size</dt><dd>%.2f bytes</dd>' % ((100.0 * data.getTotalLOC()) / data.getTotalFiles()))
464
 		f.write('<dt>Average file size</dt><dd>%.2f bytes</dd>' % ((100.0 * data.getTotalLOC()) / data.getTotalFiles()))
448
 		f.write('</dl>\n')
465
 		f.write('</dl>\n')
449
 
466
 
467
+		# Files :: File count by date
450
 		f.write('<h2>File count by date</h2>')
468
 		f.write('<h2>File count by date</h2>')
451
 
469
 
452
 		fg = open(path + '/files_by_date.dat', 'w')
470
 		fg = open(path + '/files_by_date.dat', 'w')
458
 
476
 
459
 		f.write('<h2>Average file size by date</h2>')
477
 		f.write('<h2>Average file size by date</h2>')
460
 
478
 
479
+		# Files :: Extensions
480
+		f.write('\n<h2>Extensions</h2>\n\n')
481
+		f.write('<table><tr><th>Extension</th><th>Files (%)</th><th>Lines (%)</th><th>Lines/file</th></tr>')
482
+		for ext in sorted(data.extensions.keys()):
483
+			files = data.extensions[ext]['files']
484
+			lines = data.extensions[ext]['lines']
485
+			f.write('<tr><td>%s</td><td>%d (%.2f%%)</td><td>%d (%.2f%%)</td><td>%d</td></tr>' % (ext, files, (100.0 * files) / data.getTotalFiles(), lines, (100.0 * lines) / data.getTotalLOC(), lines / files))
486
+		f.write('</table>')
487
+
461
 		f.write('</body></html>')
488
 		f.write('</body></html>')
462
 		f.close()
489
 		f.close()
463
 
490