Commit | Line | Data |
---|---|---|
44d70096 | 1 | import json |
72c02928 | 2 | import re |
44d70096 VNM |
3 | import os |
4 | import os.path | |
72c02928 | 5 | from twitter.util import printNicely |
6fa09c14 | 6 | |
0a0ee6db VNM |
7 | # Regular expression for comments |
8 | comment_re = re.compile( | |
9 | '(^)?[^\S\n]*/(?:\*(.*?)\*/[^\S\n]*|/[^\n]*)($)?', | |
10 | re.DOTALL | re.MULTILINE | |
11 | ) | |
12 | ||
13 | def 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 |
27 | DOMAIN = USER_DOMAIN |
28 | ||
29 | # Image config | |
30 | IMAGE_SHIFT = 10 | |
31 | IMAGE_MAX_HEIGHT = 40 | |
32 | ||
0a0ee6db VNM |
33 | # Load colorset |
34 | default_config = 'rainbowstream/colorset/default.json' | |
2e73187a | 35 | rainbow_config = os.environ.get('HOME', os.environ.get('USERPROFILE','')) + os.sep + '.rainbow_config.json' |
0a0ee6db VNM |
36 | load_config(default_config) |
37 | load_config(rainbow_config) |