From: Eric S. Raymond Date: Thu, 27 Sep 2012 15:38:57 +0000 (-0400) Subject: nenolod's patch fixing URL generation. X-Git-Tag: 1.0~23 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=37907644ad1b709f21607e1f21368aa52e91adc8;p=irker.git nenolod's patch fixing URL generation. --- diff --git a/irkbot.py b/irkbot.py index 47dad13..dd7f308 100755 --- a/irkbot.py +++ b/irkbot.py @@ -72,6 +72,15 @@ version = "1.0" def do(command): return commands.getstatusoutput(command)[1] +def urlify(extractor, commit): + prefix = urlprefix % extractor.__dict__ + # Try to tinyfy a reference to a web view for this commit. + try: + url = open(urllib.urlretrieve(tinyifier + prefix + commit)[0]).read() + except: + url = prefix + commit + return url + class GitExtractor: "Metadata extraction for the git version control system." def __init__(self, project=None): @@ -99,11 +108,7 @@ class GitExtractor: # Revision level self.refname = do("git symbolic-ref HEAD 2>/dev/null") self.commit = do("git rev-parse HEAD") - # Try to tinyfy a reference to a web view for this commit. - try: - self.url = open(urllib.urlretrieve(tinyifier + urlprefix + self.commit)[0]).read() - except: - self.url = urlprefix + self.commit + self.url = urlify(self, self.commit) self.branch = os.path.basename(self.refname)