10 # Regular expression for comments
11 comment_re
= re
.compile(
12 '(^)?[^\S\n]*/(?:\*(.*?)\*/[^\S\n]*|/[^\n]*)($)?',
13 re
.DOTALL | re
.MULTILINE
17 def load_config(filepath
):
19 Load config from filepath
21 with
open(filepath
) as f
:
22 content
= ''.join(f
.readlines())
23 match
= comment_re
.search(content
)
25 content
= content
[:match
.start()] + content
[match
.end():]
26 match
= comment_re
.search(content
)
27 return json
.loads(content
)
29 # Load default colorset
31 default_config
= 'rainbowstream/colorset/default.json'
32 data
= load_config(default_config
)
35 c
['theme'] = 'default'
36 # Load user's colorset
37 rainbow_config
= os
.environ
.get(
41 '')) + os
.sep
+ '.rainbow_config.json'
43 data
= load_config(rainbow_config
)