2019-09-01 19:18:30 +00:00
|
|
|
import random
|
2019-09-28 19:37:09 +00:00
|
|
|
import re
|
|
|
|
|
2019-09-01 19:18:30 +00:00
|
|
|
|
|
|
|
def getColor():
|
|
|
|
r = random.randrange(255)
|
|
|
|
g = random.randrange(255)
|
|
|
|
b = random.randrange(255)
|
2019-09-28 19:37:09 +00:00
|
|
|
return 'rgb({:0},{:0},{:0})'.format(r, g, b)
|
|
|
|
|
2019-09-01 19:18:30 +00:00
|
|
|
|
2019-09-28 19:37:09 +00:00
|
|
|
def createElement(label, color, data):
|
2019-09-01 19:18:30 +00:00
|
|
|
return {
|
2019-09-28 19:37:09 +00:00
|
|
|
"label": label,
|
|
|
|
"backgroundColor": color,
|
|
|
|
"data": data
|
2019-09-01 19:18:30 +00:00
|
|
|
}
|
|
|
|
|
2019-09-28 19:37:09 +00:00
|
|
|
def setTopicsInfo(topics, messagesDataTopic, id, length):
|
|
|
|
for topic in topics:
|
|
|
|
if topic not in messagesDataTopic:
|
|
|
|
messagesDataTopic[topic] = [0] * 30
|
|
|
|
messagesDataTopic[topic][id] += length
|
2019-09-01 19:18:30 +00:00
|
|
|
|
2019-09-28 19:37:09 +00:00
|
|
|
def getTopics(channel):
|
|
|
|
if 'description' in channel:
|
|
|
|
topics = re.findall(r"#(\w+)\W?", channel['description'])
|
|
|
|
if len(topics) == 0:
|
|
|
|
topics.append('global')
|
|
|
|
return topics
|
|
|
|
return ['global']
|
2019-09-01 19:18:30 +00:00
|
|
|
|
2019-09-28 19:37:09 +00:00
|
|
|
if __name__ == "__main__":
|
|
|
|
print("not executable")
|