Allow array of colors per domain
New JSON format example: 'domains={"koneet":["#BFDADC","#0CBBF0","#0CBBF0","#E15D19","#ED49CF"],"tilat":["#0E8A16","#1E8A16"]}'
This commit is contained in:
parent
95e1e6330f
commit
eab4ec243f
|
@ -6,6 +6,7 @@ from modules.common.module import BotModule
|
||||||
|
|
||||||
# Helper class with reusable code for github project stuff
|
# Helper class with reusable code for github project stuff
|
||||||
class GithubProject:
|
class GithubProject:
|
||||||
|
# New format to support array of colors: domains={"koneet":["#BFDADC","#0CBBF0","#0CBBF0","#E15D19","#ED49CF"],"tilat":["#0E8A16","#1E8A16"]}
|
||||||
def get_domains(description):
|
def get_domains(description):
|
||||||
p = re.compile('domains=\{.*\}')
|
p = re.compile('domains=\{.*\}')
|
||||||
matches = json.loads(p.findall(description)[0][8:])
|
matches = json.loads(p.findall(description)[0][8:])
|
||||||
|
@ -17,16 +18,17 @@ class GithubProject:
|
||||||
domains = GithubProject.get_domains(repo.description)
|
domains = GithubProject.get_domains(repo.description)
|
||||||
if(not len(domains)):
|
if(not len(domains)):
|
||||||
return None, None
|
return None, None
|
||||||
domain_color = domains.get(domain, None)
|
domain_colors = domains.get(domain, None)
|
||||||
if not domain_color:
|
if not domain_colors:
|
||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
open_issues = repo.get_issues(state='open')
|
open_issues = repo.get_issues(state='open')
|
||||||
domain_labels = []
|
domain_labels = []
|
||||||
labels = repo.get_labels()
|
labels = repo.get_labels()
|
||||||
for label in labels:
|
for label in labels:
|
||||||
if label.color == domain_color[1:]:
|
for domain_color in domain_colors:
|
||||||
domain_labels.append(label)
|
if label.color == domain_color[1:]:
|
||||||
|
domain_labels.append(label)
|
||||||
|
|
||||||
domain_issues = dict()
|
domain_issues = dict()
|
||||||
domain_ok = []
|
domain_ok = []
|
||||||
|
|
Loading…
Reference in New Issue