<pre style='margin:0'>
Rainer Müller (raimue) pushed a commit to branch master
in repository trac.macports.org.
</pre>
<p><a href="https://github.com/macports/trac.macports.org/commit/c9036843938f9198346541d7bb662f77c5c9cf2f">https://github.com/macports/trac.macports.org/commit/c9036843938f9198346541d7bb662f77c5c9cf2f</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit c9036843938f9198346541d7bb662f77c5c9cf2f
</span>Author: Rainer Müller <raimue@macports.org>
AuthorDate: Wed Nov 9 00:39:36 2016 +0100
<span style='display:block; white-space:pre;color:#404040;'> trac-github-update: inline object initialization
</span>---
plugins/hooks/trac-github-update.py | 26 ++++++++++++--------------
1 file changed, 12 insertions(+), 14 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/plugins/hooks/trac-github-update.py b/plugins/hooks/trac-github-update.py
</span><span style='display:block; white-space:pre;color:#808080;'>index 95001a0..00f8bd8 100755
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/plugins/hooks/trac-github-update.py
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/plugins/hooks/trac-github-update.py
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -53,8 +53,8 @@ git_multimail.LINK_HTML_TEMPLATE = """\
</span>
class TracDB(object):
<span style='display:block; white-space:pre;background:#ffe0e0;'>- def __init__(self, tracenv):
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- self.env = tracenv
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ def __init__(self, tracenvpath):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ self.env = trac.env.Environment(path=tracenvpath, create=False)
</span> self.cache = {}
def get_user(self, username):
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -86,8 +86,8 @@ class TracDB(object):
</span>
class GitHubAPI(object):
<span style='display:block; white-space:pre;background:#ffe0e0;'>- def __init__(self, github):
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- self.github = github
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ def __init__(self, githubtoken):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ self.github = Github(githubtoken)
</span> self.cache = {}
def get_user(self, username):
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -106,9 +106,9 @@ class GitHubAPI(object):
</span>
class GitHubWebhookEnvironment(GenericEnvironment):
<span style='display:block; white-space:pre;background:#ffe0e0;'>- def __init__(self, github, tracenv, **kw):
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- self._github = GitHubAPI(github)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- self._tracdb = TracDB(tracenv)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ def __init__(self, githubtoken, tracenvpath, **kw):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ self._github = GitHubAPI(githubtoken)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ self._tracdb = TracDB(tracenvpath)
</span> self._data = None
self._pusher = None
self._pusher_email = None
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -246,14 +246,13 @@ def main(args):
</span> config = Config('multimailhook')
# GitHub API
<span style='display:block; white-space:pre;background:#ffe0e0;'>- token = os.getenv("GITHUB_ACCESS_TOKEN")
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if not token:
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- token = config.get("githubAccessToken")
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if not token:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ githubtoken = os.getenv("GITHUB_ACCESS_TOKEN")
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if not githubtoken:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ githubtoken = config.get("githubAccessToken")
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if not githubtoken:
</span> sys.stderr.write("Set GITHUB_ACCESS_TOKEN in environment or " +
"'git config multimailhook.githubAccessToken <token>'!\n")
sys.exit(1)
<span style='display:block; white-space:pre;background:#ffe0e0;'>- github = Github(token)
</span>
# Trac Environment
tracenvpath = os.getenv("TRAC_ENV")
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -263,11 +262,10 @@ def main(args):
</span> sys.stderr.write("Set TRAC_ENV in environment or " +
"'git config multimailhook.tracEnv <path>'!\n")
sys.exit(1)
<span style='display:block; white-space:pre;background:#ffe0e0;'>- tracenv = trac.env.Environment(path=tracenvpath, create=False)
</span>
# Select the type of environment:
try:
<span style='display:block; white-space:pre;background:#ffe0e0;'>- environment = GitHubWebhookEnvironment(github, tracenv, config=config)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ environment = GitHubWebhookEnvironment(githubtoken, tracenvpath, config=config)
</span> except ConfigurationException:
sys.stderr.write("%s\n" % sys.exc_info()[1])
sys.exit(1)
</pre><pre style='margin:0'>
</pre>