b17a0e2f46734a9a91cb28c2d1d580bffcfe2de1
6 # Regular expression for comments
7 comment_re
= re
.compile(
8 '(^)?[^\S\n]*/(?:\*(.*?)\*/[^\S\n]*|/[^\n]*)($)?',
9 re
.DOTALL | re
.MULTILINE
13 def load_config(filepath
):
15 Load config from filepath
17 with
open(filepath
) as f
:
18 content
= ''.join(f
.readlines())
19 match
= comment_re
.search(content
)
21 content
= content
[:match
.start()] + content
[match
.end():]
22 match
= comment_re
.search(content
)
23 return json
.loads(content
)
28 default_config
= os
.path
.dirname(__file__
) + '/colorset/default.json'
29 data
= load_config(default_config
)
32 c
['theme'] = 'default'
35 path
= os
.path
.dirname(__file__
) + '/colorset/init'
39 raise Exception('More than 1 default theme')
40 theme_name
= lines
[0].strip()
41 default_config
= os
.path
.dirname(
42 __file__
) + '/colorset/' + theme_name
+ '.json'
43 data
= load_config(default_config
)
46 c
['theme'] = theme_name
50 # Load user's colorset
51 rainbow_config
= os
.environ
.get(
55 '')) + os
.sep
+ '.rainbow_config.json'
57 data
= load_config(rainbow_config
)