stream config
[rainbowstream.git] / rainbowstream / config.py
CommitLineData
44d70096 1import json
72c02928 2import re
44d70096
VNM
3import os
4import os.path
72c02928 5from twitter.util import printNicely
6fa09c14 6
0a0ee6db
VNM
7# Regular expression for comments
8comment_re = re.compile(
9 '(^)?[^\S\n]*/(?:\*(.*?)\*/[^\S\n]*|/[^\n]*)($)?',
10 re.DOTALL | re.MULTILINE
11)
12
13def load_config(filepath):
14 try:
15 with open(filepath) as f:
16 content = ''.join(f.readlines())
17 match = comment_re.search(content)
18 while match:
19 content = content[:match.start()] + content[match.end():]
20 match = comment_re.search(content)
21 data = json.loads(content)
2e73187a 22 for d in data:
0a0ee6db
VNM
23 globals()[d] = data[d]
24 except:
25 pass
6fa09c14 26
72c02928
VNM
27DOMAIN = USER_DOMAIN
28
29# Image config
30IMAGE_SHIFT = 10
31IMAGE_MAX_HEIGHT = 40
32
0a0ee6db
VNM
33# Load colorset
34default_config = 'rainbowstream/colorset/default.json'
2e73187a 35rainbow_config = os.environ.get('HOME', os.environ.get('USERPROFILE','')) + os.sep + '.rainbow_config.json'
0a0ee6db
VNM
36load_config(default_config)
37load_config(rainbow_config)