portail/scripts/common/charthelper.py
2019-09-28 21:37:09 +02:00

34 lines
781 B
Python

import random
import re
def getColor():
r = random.randrange(255)
g = random.randrange(255)
b = random.randrange(255)
return 'rgb({:0},{:0},{:0})'.format(r, g, b)
def createElement(label, color, data):
return {
"label": label,
"backgroundColor": color,
"data": data
}
def setTopicsInfo(topics, messagesDataTopic, id, length):
for topic in topics:
if topic not in messagesDataTopic:
messagesDataTopic[topic] = [0] * 30
messagesDataTopic[topic][id] += length
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']
if __name__ == "__main__":
print("not executable")