mirror of
https://github.com/ejwa/gitinspector.git
synced 2024-11-16 00:28:25 +01:00
Add github avatars to html output.
Add '--github file.csv' argument. The file should have a first column of emails and a second one of github usernames. The html output will then use the github avatar for each committer.
This commit is contained in:
parent
6d77989e34
commit
c66f96cf39
2 changed files with 14 additions and 1 deletions
|
@ -125,7 +125,10 @@ def __get_validated_git_repos__(repos_relative):
|
|||
|
||||
return repos
|
||||
|
||||
github_usernames = None
|
||||
|
||||
def main():
|
||||
global github_usernames
|
||||
terminal.check_terminal_encoding()
|
||||
terminal.set_stdin_encoding()
|
||||
argv = terminal.convert_command_line_to_utf8()
|
||||
|
@ -136,7 +139,7 @@ def main():
|
|||
opts, args = optval.gnu_getopt(argv[1:], "f:F:hHlLmrTwx:", ["exclude=", "file-types=", "format=",
|
||||
"hard:true", "help", "list-file-types:true", "localize-output:true",
|
||||
"metrics:true", "responsibilities:true", "since=", "grading:true",
|
||||
"timeline:true", "until=", "version", "weeks:true"])
|
||||
"timeline:true", "until=", "version", "weeks:true", "github="])
|
||||
repos = __get_validated_git_repos__(set(args))
|
||||
|
||||
#We need the repos above to be set before we read the git config.
|
||||
|
@ -149,6 +152,13 @@ def main():
|
|||
sys.exit(0)
|
||||
elif o in("-f", "--file-types"):
|
||||
extensions.define(a)
|
||||
elif o == "--github":
|
||||
import csv
|
||||
github_usernames = {}
|
||||
with open(a, 'rt') as f:
|
||||
reader = csv.reader(f)
|
||||
for row in reader:
|
||||
github_usernames[row[0]] = row[1]
|
||||
elif o in("-F", "--format"):
|
||||
if not format.select(a):
|
||||
raise format.InvalidFormatError(_("specified output format not supported."))
|
||||
|
|
|
@ -26,8 +26,11 @@ except:
|
|||
from urllib import urlencode
|
||||
|
||||
from . import format
|
||||
from . import gitinspector
|
||||
|
||||
def get_url(email, size=20):
|
||||
if gitinspector.github_usernames and email in gitinspector.github_usernames:
|
||||
return "https://github.com/" + gitinspector.github_usernames[email] + ".png?size=20"
|
||||
md5hash = hashlib.md5(email.encode("utf-8").lower().strip()).hexdigest()
|
||||
base_url = "https://www.gravatar.com/avatar/" + md5hash
|
||||
params = None
|
||||
|
|
Loading…
Reference in a new issue