6aad12c1a91785b994a24a447c56d5aaf8aae109
5 from collections
import OrderedDict
7 # Regular expression for comments
8 comment_re
= re
.compile(
9 '(^)?[^\S\n]*/(?:\*(.*?)\*/[^\S\n]*|/[^\n]*)($)?',
10 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
, object_pairs_hook
=OrderedDict
)
28 # Load the initial config
29 config
= os
.path
.dirname(
30 __file__
) + '/colorset/config'
32 data
= load_config(config
)
39 rainbow_config
= os
.environ
.get(
43 '')) + os
.sep
+ '.rainbow_config.json'
45 data
= load_config(rainbow_config
)
52 theme_file
= os
.path
.dirname(
53 __file__
) + '/colorset/' + c
['THEME'] + '.json'
55 data
= load_config(theme_file
)