From b34482bcfd899086b724865444e0bd5a8c6377b4 Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Thu, 23 Jul 2015 13:00:40 -0600 Subject: [PATCH] Add command for building all git_stats directories This just builds each one with a subprocess call and then creates an index page you I can easily navigate between them --- bin/build-stats | 35 +++++++++++++++++++++++++++++++++++ setup.py | 1 + templates/git_stats.html | 9 +++++++++ 3 files changed, 45 insertions(+) create mode 100755 bin/build-stats create mode 100644 templates/git_stats.html diff --git a/bin/build-stats b/bin/build-stats new file mode 100755 index 0000000..b815764 --- /dev/null +++ b/bin/build-stats @@ -0,0 +1,35 @@ +#!/usr/bin/env python +import argparse +import jinja2 +import os +import subprocess +import teamanalysis.git +import teamanalysis.repos +import webbrowser + +def _git_stats(abspath): + output = subprocess.check_output(['git_stats', 'generate', '--path=' + abspath, '--out-path=' + os.path.join(abspath, 'git_stats')]) + return output + +def main(): + for repo in teamanalysis.repos.REPOSITORIES: + print(repo) + abspath = '/Users/eliribble/src/{}/'.format(repo) + #output = _git_stats(abspath) + + template_loader = jinja2.FileSystemLoader(searchpath=os.path.abspath('./templates/')) + template_environment = jinja2.Environment(loader=template_loader) + template = template_environment.get_template('git_stats.html') + output = template.render(repos=teamanalysis.repos.REPOSITORIES) + + try: + os.mkdir('git_stats') + except OSError: + pass + + with open('git_stats/index.html', 'w') as f: + f.write(output) + webbrowser.open(os.path.abspath('./git_stats/index.html')) + +if __name__ == '__main__': + main() diff --git a/setup.py b/setup.py index ad19f57..3c7668f 100644 --- a/setup.py +++ b/setup.py @@ -76,6 +76,7 @@ def main(): author = "Eli Ribble", author_email = "eli@theribbles.org", install_requires = [ + 'Jinja2==2.7.3', ], packages = ['teamanalysis'], package_data = { diff --git a/templates/git_stats.html b/templates/git_stats.html new file mode 100644 index 0000000..c26dbd4 --- /dev/null +++ b/templates/git_stats.html @@ -0,0 +1,9 @@ + + + + +