2 # Copyright (c) 2007 Heikki Hokkanen <hoxu@users.sf.net>
13 GNUPLOT_COMMON
= 'set terminal png transparent\nset size 0.5,0.5\n'
15 exectime_internal
= 0.0
16 exectime_external
= 0.0
17 time_start
= time
.time()
19 def getoutput(cmd
, quiet
= False):
20 global exectime_external
25 output
= commands
.getoutput(cmd
)
28 print '\r[%.5f] >> %s' % (end
- start
, cmd
)
29 exectime_external
+= (end
- start
)
32 def getkeyssortedbyvalues(dict):
33 return map(lambda el
: el
[1], sorted(map(lambda el
: (el
[1], el
[0]), dict.items())))
35 # TODO getdictkeyssortedbyvaluekey(dict, key) - eg. dict['author'] = { 'commits' : 512 } - ...key(dict, 'commits')
38 """Manages data collection from a revision control repository."""
40 self
.stamp_created
= time
.time()
44 # This should be the main function to extract data from the repository.
45 def collect(self
, dir):
47 self
.projectname
= os
.path
.basename(os
.path
.abspath(dir))
50 # : get a dictionary of author
51 def getAuthorInfo(self
, author
):
54 def getActivityByDayOfWeek(self
):
57 def getActivityByHourOfDay(self
):
61 # Get a list of authors
65 def getFirstCommitDate(self
):
66 return datetime
.datetime
.now()
68 def getLastCommitDate(self
):
69 return datetime
.datetime
.now()
71 def getStampCreated(self
):
72 return self
.stamp_created
77 def getTotalAuthors(self
):
80 def getTotalCommits(self
):
83 def getTotalFiles(self
):
86 def getTotalLOC(self
):
89 class GitDataCollector(DataCollector
):
90 def collect(self
, dir):
91 DataCollector
.collect(self
, dir)
93 self
.total_authors
= int(getoutput('git-log |git-shortlog -s |wc -l'))
94 #self.total_lines = int(getoutput('git-ls-files -z |xargs -0 cat |wc -l'))
96 self
.activity_by_hour_of_day
= {} # hour -> commits
97 self
.activity_by_day_of_week
= {} # day -> commits
98 self
.activity_by_month_of_year
= {} # month [1-12] -> commits
99 self
.activity_by_hour_of_week
= {} # weekday -> hour -> commits
101 self
.authors
= {} # name -> {commits, first_commit_stamp, last_commit_stamp}
103 # author of the month
104 self
.author_of_month
= {} # month -> author -> commits
105 self
.author_of_year
= {} # year -> author -> commits
106 self
.commits_by_month
= {} # month -> commits
107 self
.commits_by_year
= {} # year -> commits
108 self
.first_commit_stamp
= 0
109 self
.last_commit_stamp
= 0
113 lines
= getoutput('git-show-ref --tags').split('\n')
117 (hash, tag
) = line
.split(' ')
118 tag
= tag
.replace('refs/tags/', '')
119 output
= getoutput('git-log "%s" --pretty=format:"%%at %%an" -n 1' % hash)
121 parts
= output
.split(' ')
124 stamp
= int(parts
[0])
127 self
.tags
[tag
] = { 'stamp': stamp
, 'hash' : hash, 'date' : datetime
.datetime
.fromtimestamp(stamp
).strftime('%Y-%m-%d') }
130 # Collect revision statistics
133 self
.files_by_stamp
= {} # stamp -> files
134 lines
= getoutput('git-rev-list --pretty=format:"%at %an" HEAD').split('\n')
135 self
.total_commits
= len(lines
) / 2
142 # linux-2.6 says "<unknown>" for one line O_o
143 parts
= line
.split(' ')
146 stamp
= int(parts
[0])
150 author
= ' '.join(parts
[1:])
151 date
= datetime
.datetime
.fromtimestamp(float(stamp
))
153 # First and last commit stamp
154 if self
.last_commit_stamp
== 0:
155 self
.last_commit_stamp
= stamp
156 self
.first_commit_stamp
= stamp
161 if hour
in self
.activity_by_hour_of_day
:
162 self
.activity_by_hour_of_day
[hour
] += 1
164 self
.activity_by_hour_of_day
[hour
] = 1
168 if day
in self
.activity_by_day_of_week
:
169 self
.activity_by_day_of_week
[day
] += 1
171 self
.activity_by_day_of_week
[day
] = 1
174 if day
not in self
.activity_by_hour_of_week
:
175 self
.activity_by_hour_of_week
[day
] = {}
176 if hour
not in self
.activity_by_hour_of_week
[day
]:
177 self
.activity_by_hour_of_week
[day
][hour
] = 1
179 self
.activity_by_hour_of_week
[day
][hour
] += 1
183 if month
in self
.activity_by_month_of_year
:
184 self
.activity_by_month_of_year
[month
] += 1
186 self
.activity_by_month_of_year
[month
] = 1
189 if author
not in self
.authors
:
190 self
.authors
[author
] = {}
192 if 'last_commit_stamp' not in self
.authors
[author
]:
193 self
.authors
[author
]['last_commit_stamp'] = stamp
194 self
.authors
[author
]['first_commit_stamp'] = stamp
195 if 'commits' in self
.authors
[author
]:
196 self
.authors
[author
]['commits'] += 1
198 self
.authors
[author
]['commits'] = 1
200 # author of the month/year
201 yymm
= datetime
.datetime
.fromtimestamp(stamp
).strftime('%Y-%m')
202 if yymm
in self
.author_of_month
:
203 if author
in self
.author_of_month
[yymm
]:
204 self
.author_of_month
[yymm
][author
] += 1
206 self
.author_of_month
[yymm
][author
] = 1
208 self
.author_of_month
[yymm
] = {}
209 self
.author_of_month
[yymm
][author
] = 1
210 if yymm
in self
.commits_by_month
:
211 self
.commits_by_month
[yymm
] += 1
213 self
.commits_by_month
[yymm
] = 1
215 yy
= datetime
.datetime
.fromtimestamp(stamp
).year
216 if yy
in self
.author_of_year
:
217 if author
in self
.author_of_year
[yy
]:
218 self
.author_of_year
[yy
][author
] += 1
220 self
.author_of_year
[yy
][author
] = 1
222 self
.author_of_year
[yy
] = {}
223 self
.author_of_year
[yy
][author
] = 1
224 if yy
in self
.commits_by_year
:
225 self
.commits_by_year
[yy
] += 1
227 self
.commits_by_year
[yy
] = 1
232 files
= int(getoutput('git-ls-tree -r "%s" |wc -l' % commit
, quiet
= True))
235 print 'Warning: failed to collect file statistics for commit "%s"' % commit
236 self
.files_by_stamp
[stamp
] = files
239 self
.extensions
= {} # extension -> files, lines
240 lines
= getoutput('git-ls-files').split('\n')
241 self
.total_files
= len(lines
)
243 base
= os
.path
.basename(line
)
244 if base
.find('.') == -1:
247 ext
= base
[(base
.rfind('.') + 1):]
249 if ext
not in self
.extensions
:
250 self
.extensions
[ext
] = {'files': 0, 'lines': 0}
252 self
.extensions
[ext
]['files'] += 1
254 # Escaping could probably be improved here
255 self
.extensions
[ext
]['lines'] += int(getoutput('wc -l < %s' % re
.sub(r
'(\W)', r
'\\\1', line
), quiet
= True))
257 print 'Warning: Could not count lines for file "%s"' % line
261 # N files changed, N insertions (+), N deletions(-)
263 self
.changes_by_date
= {} # stamp -> { files, ins, del }
264 lines
= getoutput('git-log --shortstat --pretty=format:"%at %an" |tac').split('\n')
265 files
= 0; inserted
= 0; deleted
= 0; total_lines
= 0
271 if line
.find('files changed,') == -1:
274 (stamp
, author
) = (int(line
[:pos
]), line
[pos
+1:])
275 self
.changes_by_date
[stamp
] = { 'files': files
, 'ins': inserted
, 'del': deleted
, 'lines': total_lines
}
277 print 'Warning: unexpected line "%s"' % line
279 numbers
= re
.findall('\d+', line
)
280 if len(numbers
) == 3:
281 (files
, inserted
, deleted
) = map(lambda el
: int(el
), numbers
)
282 total_lines
+= inserted
283 total_lines
-= deleted
285 print 'Warning: failed to handle line "%s"' % line
286 (files
, inserted
, deleted
) = (0, 0, 0)
287 #self.changes_by_date[stamp] = { 'files': files, 'ins': inserted, 'del': deleted }
288 self
.total_lines
= total_lines
290 def getActivityByDayOfWeek(self
):
291 return self
.activity_by_day_of_week
293 def getActivityByHourOfDay(self
):
294 return self
.activity_by_hour_of_day
296 def getAuthorInfo(self
, author
):
297 a
= self
.authors
[author
]
299 commits
= a
['commits']
300 commits_frac
= (100 * float(commits
)) / self
.getTotalCommits()
301 date_first
= datetime
.datetime
.fromtimestamp(a
['first_commit_stamp'])
302 date_last
= datetime
.datetime
.fromtimestamp(a
['last_commit_stamp'])
303 delta
= date_last
- date_first
305 res
= { 'commits': commits
, 'commits_frac': commits_frac
, 'date_first': date_first
.strftime('%Y-%m-%d'), 'date_last': date_last
.strftime('%Y-%m-%d'), 'timedelta' : delta
}
308 def getAuthors(self
):
309 return self
.authors
.keys()
311 def getFirstCommitDate(self
):
312 return datetime
.datetime
.fromtimestamp(self
.first_commit_stamp
)
314 def getLastCommitDate(self
):
315 return datetime
.datetime
.fromtimestamp(self
.last_commit_stamp
)
318 lines
= getoutput('git-show-ref --tags |cut -d/ -f3')
319 return lines
.split('\n')
321 def getTagDate(self
, tag
):
322 return self
.revToDate('tags/' + tag
)
324 def getTotalAuthors(self
):
325 return self
.total_authors
327 def getTotalCommits(self
):
328 return self
.total_commits
330 def getTotalFiles(self
):
331 return self
.total_files
333 def getTotalLOC(self
):
334 return self
.total_lines
336 def revToDate(self
, rev
):
337 stamp
= int(getoutput('git-log --pretty=format:%%at "%s" -n 1' % rev
))
338 return datetime
.datetime
.fromtimestamp(stamp
).strftime('%Y-%m-%d')
341 """Creates the actual report based on given data."""
345 def create(self
, data
, path
):
349 def html_linkify(text
):
350 return text
.lower().replace(' ', '_')
352 def html_header(level
, text
):
353 name
= html_linkify(text
)
354 return '\n<h%d><a href="#%s" name="%s">%s</a></h%d>\n\n' % (level
, name
, name
, text
, level
)
356 class HTMLReportCreator(ReportCreator
):
357 def create(self
, data
, path
):
358 ReportCreator
.create(self
, data
, path
)
359 self
.title
= data
.projectname
361 # TODO copy the CSS if it does not exist
362 if not os
.path
.exists(path
+ '/gitstats.css'):
363 shutil
.copyfile('gitstats.css', path
+ '/gitstats.css')
366 f
= open(path
+ "/index.html", 'w')
367 format
= '%Y-%m-%d %H:%m:%S'
370 f
.write('<h1>GitStats - %s</h1>' % data
.projectname
)
375 f
.write('<dt>Project name</dt><dd>%s</dd>' % (data
.projectname
))
376 f
.write('<dt>Generated</dt><dd>%s (in %d seconds)</dd>' % (datetime
.datetime
.now().strftime(format
), time
.time() - data
.getStampCreated()));
377 f
.write('<dt>Report Period</dt><dd>%s to %s</dd>' % (data
.getFirstCommitDate().strftime(format
), data
.getLastCommitDate().strftime(format
)))
378 f
.write('<dt>Total Files</dt><dd>%s</dd>' % data
.getTotalFiles())
379 f
.write('<dt>Total Lines of Code</dt><dd>%s</dd>' % data
.getTotalLOC())
380 f
.write('<dt>Total Commits</dt><dd>%s</dd>' % data
.getTotalCommits())
381 f
.write('<dt>Authors</dt><dd>%s</dd>' % data
.getTotalAuthors())
384 f
.write('</body>\n</html>');
389 f
= open(path
+ '/activity.html', 'w')
391 f
.write('<h1>Activity</h1>')
394 #f.write('<h2>Last 30 days</h2>')
396 #f.write('<h2>Last 12 months</h2>')
399 f
.write(html_header(2, 'Hour of Day'))
400 hour_of_day
= data
.getActivityByHourOfDay()
401 f
.write('<table><tr><th>Hour</th>')
402 for i
in range(1, 25):
403 f
.write('<th>%d</th>' % i
)
404 f
.write('</tr>\n<tr><th>Commits</th>')
405 fp
= open(path
+ '/hour_of_day.dat', 'w')
406 for i
in range(0, 24):
408 f
.write('<td>%d</td>' % hour_of_day
[i
])
409 fp
.write('%d %d\n' % (i
, hour_of_day
[i
]))
411 f
.write('<td>0</td>')
412 fp
.write('%d 0\n' % i
)
414 f
.write('</tr>\n<tr><th>%</th>')
415 totalcommits
= data
.getTotalCommits()
416 for i
in range(0, 24):
418 f
.write('<td>%.2f</td>' % ((100.0 * hour_of_day
[i
]) / totalcommits
))
420 f
.write('<td>0.00</td>')
421 f
.write('</tr></table>')
422 f
.write('<img src="hour_of_day.png" alt="Hour of Day" />')
423 fg
= open(path
+ '/hour_of_day.dat', 'w')
424 for i
in range(0, 24):
426 fg
.write('%d %d\n' % (i
+ 1, hour_of_day
[i
]))
428 fg
.write('%d 0\n' % (i
+ 1))
432 f
.write(html_header(2, 'Day of Week'))
433 day_of_week
= data
.getActivityByDayOfWeek()
434 f
.write('<div class="vtable"><table>')
435 f
.write('<tr><th>Day</th><th>Total (%)</th></tr>')
436 fp
= open(path
+ '/day_of_week.dat', 'w')
437 for d
in range(0, 7):
440 commits
= day_of_week
[d
]
441 fp
.write('%d %d\n' % (d
+ 1, commits
))
443 f
.write('<th>%d</th>' % (d
+ 1))
445 f
.write('<td>%d (%.2f%%)</td>' % (day_of_week
[d
], (100.0 * day_of_week
[d
]) / totalcommits
))
447 f
.write('<td>0</td>')
449 f
.write('</table></div>')
450 f
.write('<img src="day_of_week.png" alt="Day of Week" />')
454 f
.write(html_header(2, 'Hour of Week'))
457 f
.write('<tr><th>Weekday</th>')
458 for hour
in range(0, 24):
459 f
.write('<th>%d</th>' % (hour
+ 1))
462 for weekday
in range(0, 7):
463 f
.write('<tr><th>%d</th>' % (weekday
+ 1))
464 for hour
in range(0, 24):
466 commits
= data
.activity_by_hour_of_week
[weekday
][hour
]
470 f
.write('<td>%d</td>' % commits
)
478 f
.write(html_header(2, 'Month of Year'))
479 f
.write('<div class="vtable"><table>')
480 f
.write('<tr><th>Month</th><th>Commits (%)</th></tr>')
481 fp
= open (path
+ '/month_of_year.dat', 'w')
482 for mm
in range(1, 13):
484 if mm
in data
.activity_by_month_of_year
:
485 commits
= data
.activity_by_month_of_year
[mm
]
486 f
.write('<tr><td>%d</td><td>%d (%.2f %%)</td></tr>' % (mm
, commits
, (100.0 * commits
) / data
.getTotalCommits()))
487 fp
.write('%d %d\n' % (mm
, commits
))
489 f
.write('</table></div>')
490 f
.write('<img src="month_of_year.png" alt="Month of Year" />')
492 # Commits by year/month
493 f
.write(html_header(2, 'Commits by year/month'))
494 f
.write('<div class="vtable"><table><tr><th>Month</th><th>Commits</th></tr>')
495 for yymm
in reversed(sorted(data
.commits_by_month
.keys())):
496 f
.write('<tr><td>%s</td><td>%d</td></tr>' % (yymm
, data
.commits_by_month
[yymm
]))
497 f
.write('</table></div>')
498 f
.write('<img src="commits_by_year_month.png" alt="Commits by year/month" />')
499 fg
= open(path
+ '/commits_by_year_month.dat', 'w')
500 for yymm
in sorted(data
.commits_by_month
.keys()):
501 fg
.write('%s %s\n' % (yymm
, data
.commits_by_month
[yymm
]))
505 f
.write(html_header(2, 'Commits by Year'))
506 f
.write('<div class="vtable"><table><tr><th>Year</th><th>Commits (% of all)</th></tr>')
507 for yy
in reversed(sorted(data
.commits_by_year
.keys())):
508 f
.write('<tr><td>%s</td><td>%d (%.2f%%)</td></tr>' % (yy
, data
.commits_by_year
[yy
], (100.0 * data
.commits_by_year
[yy
]) / data
.getTotalCommits()))
509 f
.write('</table></div>')
510 f
.write('<img src="commits_by_year.png" alt="Commits by Year" />')
511 fg
= open(path
+ '/commits_by_year.dat', 'w')
512 for yy
in sorted(data
.commits_by_year
.keys()):
513 fg
.write('%d %d\n' % (yy
, data
.commits_by_year
[yy
]))
516 f
.write('</body></html>')
521 f
= open(path
+ '/authors.html', 'w')
524 f
.write('<h1>Authors</h1>')
527 # Authors :: List of authors
528 f
.write(html_header(2, 'List of Authors'))
530 f
.write('<table class="authors">')
531 f
.write('<tr><th>Author</th><th>Commits (%)</th><th>First commit</th><th>Last commit</th><th>Age</th></tr>')
532 for author
in sorted(data
.getAuthors()):
533 info
= data
.getAuthorInfo(author
)
534 f
.write('<tr><td>%s</td><td>%d (%.2f%%)</td><td>%s</td><td>%s</td><td>%s</td></tr>' % (author
, info
['commits'], info
['commits_frac'], info
['date_first'], info
['date_last'], info
['timedelta']))
537 # Authors :: Author of Month
538 f
.write(html_header(2, 'Author of Month'))
540 f
.write('<tr><th>Month</th><th>Author</th><th>Commits (%)</th></tr>')
541 for yymm
in reversed(sorted(data
.author_of_month
.keys())):
542 authordict
= data
.author_of_month
[yymm
]
543 authors
= getkeyssortedbyvalues(authordict
)
545 commits
= data
.author_of_month
[yymm
][authors
[0]]
546 f
.write('<tr><td>%s</td><td>%s</td><td>%d (%.2f%% of %d)</td></tr>' % (yymm
, authors
[0], commits
, (100 * commits
) / data
.commits_by_month
[yymm
], data
.commits_by_month
[yymm
]))
550 f
.write(html_header(2, 'Author of Year'))
551 f
.write('<table><tr><th>Year</th><th>Author</th><th>Commits (%)</th></tr>')
552 for yy
in reversed(sorted(data
.author_of_year
.keys())):
553 authordict
= data
.author_of_year
[yy
]
554 authors
= getkeyssortedbyvalues(authordict
)
556 commits
= data
.author_of_year
[yy
][authors
[0]]
557 f
.write('<tr><td>%s</td><td>%s</td><td>%d (%.2f%% of %d)</td></tr>' % (yy
, authors
[0], commits
, (100 * commits
) / data
.commits_by_year
[yy
], data
.commits_by_year
[yy
]))
560 f
.write('</body></html>')
565 f
= open(path
+ '/files.html', 'w')
567 f
.write('<h1>Files</h1>')
571 f
.write('<dt>Total files</dt><dd>%d</dd>' % data
.getTotalFiles())
572 f
.write('<dt>Total lines</dt><dd>%d</dd>' % data
.getTotalLOC())
573 f
.write('<dt>Average file size</dt><dd>%.2f bytes</dd>' % ((100.0 * data
.getTotalLOC()) / data
.getTotalFiles()))
576 # Files :: File count by date
577 f
.write(html_header(2, 'File count by date'))
579 fg
= open(path
+ '/files_by_date.dat', 'w')
580 for stamp
in sorted(data
.files_by_stamp
.keys()):
581 fg
.write('%s %d\n' % (datetime
.datetime
.fromtimestamp(stamp
).strftime('%Y-%m-%d'), data
.files_by_stamp
[stamp
]))
584 f
.write('<img src="files_by_date.png" alt="Files by Date" />')
586 #f.write('<h2>Average file size by date</h2>')
588 # Files :: Extensions
589 f
.write(html_header(2, 'Extensions'))
590 f
.write('<table><tr><th>Extension</th><th>Files (%)</th><th>Lines (%)</th><th>Lines/file</th></tr>')
591 for ext
in sorted(data
.extensions
.keys()):
592 files
= data
.extensions
[ext
]['files']
593 lines
= data
.extensions
[ext
]['lines']
594 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
))
597 f
.write('</body></html>')
602 f
= open(path
+ '/lines.html', 'w')
604 f
.write('<h1>Lines</h1>')
608 f
.write('<dt>Total lines</dt><dd>%d</dd>' % data
.getTotalLOC())
611 f
.write(html_header(2, 'Lines of Code'))
612 f
.write('<img src="lines_of_code.png" />')
614 fg
= open(path
+ '/lines_of_code.dat', 'w')
615 for stamp
in sorted(data
.changes_by_date
.keys()):
616 fg
.write('%d %d\n' % (stamp
, data
.changes_by_date
[stamp
]['lines']))
619 f
.write('</body></html>')
624 f
= open(path
+ '/tags.html', 'w')
626 f
.write('<h1>Tags</h1>')
630 f
.write('<dt>Total tags</dt><dd>%d</dd>' % len(data
.tags
))
631 if len(data
.tags
) > 0:
632 f
.write('<dt>Average commits per tag</dt><dd>%.2f</dd>' % (data
.getTotalCommits() / len(data
.tags
)))
636 f
.write('<tr><th>Name</th><th>Date</th></tr>')
637 # sort the tags by date desc
638 tags_sorted_by_date_desc
= map(lambda el
: el
[1], reversed(sorted(map(lambda el
: (el
[1]['date'], el
[0]), data
.tags
.items()))))
639 for tag
in tags_sorted_by_date_desc
:
640 f
.write('<tr><td>%s</td><td>%s</td></tr>' % (tag
, data
.tags
[tag
]['date']))
643 f
.write('</body></html>')
646 self
.createGraphs(path
)
649 def createGraphs(self
, path
):
650 print 'Generating graphs...'
653 f
= open(path
+ '/hour_of_day.plot', 'w')
654 f
.write(GNUPLOT_COMMON
)
657 set output 'hour_of_day.png'
659 set xrange [0.5:24.5]
662 plot 'hour_of_day.dat' using 1:2:(0.5) w boxes fs solid
667 f
= open(path
+ '/day_of_week.plot', 'w')
668 f
.write(GNUPLOT_COMMON
)
671 set output 'day_of_week.png'
676 plot 'day_of_week.dat' using 1:2:(0.5) w boxes fs solid
681 f
= open(path
+ '/month_of_year.plot', 'w')
682 f
.write(GNUPLOT_COMMON
)
685 set output 'month_of_year.png'
687 set xrange [0.5:12.5]
690 plot 'month_of_year.dat' using 1:2:(0.5) w boxes fs solid
694 # commits_by_year_month
695 f
= open(path
+ '/commits_by_year_month.plot', 'w')
696 f
.write(GNUPLOT_COMMON
)
699 set output 'commits_by_year_month.png'
704 set xtics rotate by 90 15768000
707 plot 'commits_by_year_month.dat' using 1:2:(0.5) w boxes fs solid
712 f
= open(path
+ '/commits_by_year.plot', 'w')
713 f
.write(GNUPLOT_COMMON
)
716 set output 'commits_by_year.png'
720 plot 'commits_by_year.dat' using 1:2:(0.5) w boxes fs solid
725 f
= open(path
+ '/files_by_date.plot', 'w')
726 f
.write(GNUPLOT_COMMON
)
729 set output 'files_by_date.png'
732 set timefmt "%Y-%m-%d"
733 set format x "%Y-%m-%d"
735 set xtics rotate by 90
737 plot 'files_by_date.dat' using 1:2 smooth csplines
742 f
= open(path
+ '/lines_of_code.plot', 'w')
743 f
.write(GNUPLOT_COMMON
)
746 set output 'lines_of_code.png'
750 set format x "%Y-%m-%d"
752 set xtics rotate by 90
754 plot 'lines_of_code.dat' using 1:2 w lines
759 files
= glob
.glob(path
+ '/*.plot')
761 out
= getoutput('gnuplot %s' % f
)
765 def printHeader(self
, f
, title
= ''):
767 """<?xml version="1.0" encoding="UTF-8"?>
768 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
769 <html xmlns="http://www.w3.org/1999/xhtml">
771 <title>GitStats - %s</title>
772 <link rel="stylesheet" href="gitstats.css" type="text/css" />
773 <meta name="generator" content="GitStats" />
778 def printNav(self
, f
):
782 <li><a href="index.html">General</a></li>
783 <li><a href="activity.html">Activity</a></li>
784 <li><a href="authors.html">Authors</a></li>
785 <li><a href="files.html">Files</a></li>
786 <li><a href="lines.html">Lines</a></li>
787 <li><a href="tags.html">Tags</a></li>
794 Usage: gitstats [options] <gitpath> <outputpath>
799 if len(sys
.argv
) < 3:
803 gitpath
= sys
.argv
[1]
804 outputpath
= os
.path
.abspath(sys
.argv
[2])
808 os
.makedirs(outputpath
)
811 if not os
.path
.isdir(outputpath
):
812 print 'FATAL: Output path is not a directory or does not exist'
815 print 'Git path: %s' % gitpath
816 print 'Output path: %s' % outputpath
820 print 'Collecting data...'
821 data
= GitDataCollector()
822 data
.collect(gitpath
)
826 print 'Generating report...'
827 report
= HTMLReportCreator()
828 report
.create(data
, outputpath
)
830 time_end
= time
.time()
831 exectime_internal
= time_end
- time_start
832 print 'Execution time %.5f secs, %.5f secs (%.2f %%) in external commands)' % (exectime_internal
, exectime_external
, (100.0 * exectime_external
) / exectime_internal
)