Make some colours consts per type of content (github)
This commit is contained in:
parent
cedd080f75
commit
58b1e41b5d
1 changed files with 18 additions and 12 deletions
|
@ -1,6 +1,12 @@
|
||||||
import datetime, itertools, json, math, urllib.parse
|
import datetime, itertools, json, math, urllib.parse
|
||||||
from src import ModuleManager, utils
|
from src import ModuleManager, utils
|
||||||
|
|
||||||
|
COLOR_BRANCH = utils.consts.ORANGE
|
||||||
|
COLOR_REPO = utils.consts.GREY
|
||||||
|
COLOR_POSITIVE = utils.consts.RED
|
||||||
|
COLOR_NEGATIVE = utils.consts.GREEN
|
||||||
|
COLOR_ID = utils.consts.PURPLE
|
||||||
|
|
||||||
FORM_ENCODED = "application/x-www-form-urlencoded"
|
FORM_ENCODED = "application/x-www-form-urlencoded"
|
||||||
|
|
||||||
COMMIT_URL = "https://github.com/%s/commit/%s"
|
COMMIT_URL = "https://github.com/%s/commit/%s"
|
||||||
|
@ -405,9 +411,9 @@ class Module(ModuleManager.BaseModule):
|
||||||
def _change_count(self, n, symbol, color):
|
def _change_count(self, n, symbol, color):
|
||||||
return utils.irc.color("%s%d" % (symbol, n), color)+utils.irc.bold("")
|
return utils.irc.color("%s%d" % (symbol, n), color)+utils.irc.bold("")
|
||||||
def _added(self, n):
|
def _added(self, n):
|
||||||
return self._change_count(n, "+", utils.consts.GREEN)
|
return self._change_count(n, "+", COLOR_POSITIVE)
|
||||||
def _removed(self, n):
|
def _removed(self, n):
|
||||||
return self._change_count(n, "-", utils.consts.RED)
|
return self._change_count(n, "-", COLOR_NEGATIVE)
|
||||||
def _modified(self, n):
|
def _modified(self, n):
|
||||||
return self._change_count(n, "~", utils.consts.PURPLE)
|
return self._change_count(n, "~", utils.consts.PURPLE)
|
||||||
|
|
||||||
|
@ -420,7 +426,7 @@ class Module(ModuleManager.BaseModule):
|
||||||
def push(self, full_name, data):
|
def push(self, full_name, data):
|
||||||
outputs = []
|
outputs = []
|
||||||
branch = data["ref"].split("/", 2)[2]
|
branch = data["ref"].split("/", 2)[2]
|
||||||
branch = utils.irc.color(branch, utils.consts.LIGHTBLUE)
|
branch = utils.irc.color(branch, COLOR_BRANCH)
|
||||||
|
|
||||||
forced = ""
|
forced = ""
|
||||||
if data["forced"]:
|
if data["forced"]:
|
||||||
|
@ -473,18 +479,18 @@ class Module(ModuleManager.BaseModule):
|
||||||
action = data["action"]
|
action = data["action"]
|
||||||
action_desc = action
|
action_desc = action
|
||||||
branch = data["pull_request"]["base"]["ref"]
|
branch = data["pull_request"]["base"]["ref"]
|
||||||
colored_branch = utils.irc.color(branch, utils.consts.LIGHTBLUE)
|
colored_branch = utils.irc.color(branch, COLOR_BRANCH)
|
||||||
|
|
||||||
if action == "opened":
|
if action == "opened":
|
||||||
action_desc = "requested merge into %s" % colored_branch
|
action_desc = "requested merge into %s" % colored_branch
|
||||||
elif action == "closed":
|
elif action == "closed":
|
||||||
if data["pull_request"]["merged"]:
|
if data["pull_request"]["merged"]:
|
||||||
action_desc = "%s into %s" % (
|
action_desc = "%s into %s" % (
|
||||||
utils.irc.color("merged", utils.consts.GREEN),
|
utils.irc.color("merged", COLOR_POSITIVE),
|
||||||
colored_branch)
|
colored_branch)
|
||||||
else:
|
else:
|
||||||
action_desc = utils.irc.color("closed without merging",
|
action_desc = utils.irc.color("closed without merging",
|
||||||
utils.consts.RED)
|
COLOR_NEGATIVE)
|
||||||
elif action == "synchronize":
|
elif action == "synchronize":
|
||||||
action_desc = "committed to"
|
action_desc = "committed to"
|
||||||
|
|
||||||
|
@ -533,19 +539,19 @@ class Module(ModuleManager.BaseModule):
|
||||||
if data["changes"]["body"]["from"] == data["comment"]["body"]:
|
if data["changes"]["body"]["from"] == data["comment"]["body"]:
|
||||||
return
|
return
|
||||||
|
|
||||||
number = data["issue"]["number"]
|
number = utils.irc.color("#%s" % data["issue"]["number"], COLOR_ID)
|
||||||
action = data["action"]
|
action = data["action"]
|
||||||
issue_title = data["issue"]["title"]
|
issue_title = data["issue"]["title"]
|
||||||
type = "pr" if "pull_request" in data["issue"] else "issue"
|
type = "pr" if "pull_request" in data["issue"] else "issue"
|
||||||
commenter = utils.irc.bold(data["sender"]["login"])
|
commenter = utils.irc.bold(data["sender"]["login"])
|
||||||
url = self._short_url(data["comment"]["html_url"])
|
url = self._short_url(data["comment"]["html_url"])
|
||||||
return ["[%s #%d] %s %s on: %s - %s" %
|
return ["[%s %s] %s %s on: %s - %s" %
|
||||||
(type, number, commenter, COMMENT_ACTIONS[action], issue_title,
|
(type, number, commenter, COMMENT_ACTIONS[action], issue_title,
|
||||||
url)]
|
url)]
|
||||||
|
|
||||||
def create(self, full_name, data):
|
def create(self, full_name, data):
|
||||||
ref = data["ref"]
|
ref = data["ref"]
|
||||||
ref_color = utils.irc.color(ref, utils.consts.LIGHTBLUE)
|
ref_color = utils.irc.color(ref, COLOR_BRANCH)
|
||||||
type = data["ref_type"]
|
type = data["ref_type"]
|
||||||
sender = utils.irc.bold(data["sender"]["login"])
|
sender = utils.irc.bold(data["sender"]["login"])
|
||||||
url = self._short_url(CREATE_URL % (full_name, ref))
|
url = self._short_url(CREATE_URL % (full_name, ref))
|
||||||
|
@ -593,11 +599,11 @@ class Module(ModuleManager.BaseModule):
|
||||||
status_str = utils.irc.bold("started")
|
status_str = utils.irc.bold("started")
|
||||||
elif status == "completed":
|
elif status == "completed":
|
||||||
conclusion = data["check_run"]["conclusion"]
|
conclusion = data["check_run"]["conclusion"]
|
||||||
conclusion_color = utils.consts.GREEN
|
conclusion_color = COLOR_POSITIVE
|
||||||
if conclusion in CHECK_RUN_FAILURES:
|
if conclusion in CHECK_RUN_FAILURES:
|
||||||
conclusion_color = utils.consts.RED
|
conclusion_color = COLOR_NEGATIVE
|
||||||
if conclusion == "neutral":
|
if conclusion == "neutral":
|
||||||
conclusion_color = utils.consts.LIGHTGREY
|
conclusion_color = utils.consts.GREY
|
||||||
|
|
||||||
status_str = utils.irc.color(
|
status_str = utils.irc.color(
|
||||||
CHECK_RUN_CONCLUSION[conclusion], conclusion_color)
|
CHECK_RUN_CONCLUSION[conclusion], conclusion_color)
|
||||||
|
|
Loading…
Reference in a new issue