projects
/
rainbowstream.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
theme chosen
[rainbowstream.git]
/
rainbowstream
/
config.py
diff --git
a/rainbowstream/config.py
b/rainbowstream/config.py
index 3f61553d393eea03d72f757fdffaa88e09ca17bf..a5e542d5afcd492338ae2ea7f568b5ff2c4d5c2e 100644
(file)
--- a/
rainbowstream/config.py
+++ b/
rainbowstream/config.py
@@
-3,26
+3,25
@@
import re
import os
import os.path
import os
import os.path
+
# Regular expression for comments
comment_re = re.compile(
'(^)?[^\S\n]*/(?:\*(.*?)\*/[^\S\n]*|/[^\n]*)($)?',
re.DOTALL | re.MULTILINE
)
# Regular expression for comments
comment_re = re.compile(
'(^)?[^\S\n]*/(?:\*(.*?)\*/[^\S\n]*|/[^\n]*)($)?',
re.DOTALL | re.MULTILINE
)
+
def load_config(filepath):
"""
Load config from filepath
"""
def load_config(filepath):
"""
Load config from filepath
"""
- try:
- with open(filepath) as f:
- content = ''.join(f.readlines())
+ with open(filepath) as f:
+ content = ''.join(f.readlines())
+ match = comment_re.search(content)
+ while match:
+ content = content[:match.start()] + content[match.end():]
match = comment_re.search(content)
match = comment_re.search(content)
- while match:
- content = content[:match.start()] + content[match.end():]
- match = comment_re.search(content)
- return json.loads(content)
- except:
- pass
+ return json.loads(content)
# Load default colorset
c = {}
# Load default colorset
c = {}
@@
-30,8
+29,17
@@
default_config = 'rainbowstream/colorset/default.json'
data = load_config(default_config)
for d in data:
c[d] = data[d]
data = load_config(default_config)
for d in data:
c[d] = data[d]
+c['theme'] = 'default'
# Load user's colorset
# Load user's colorset
-rainbow_config = os.environ.get('HOME', os.environ.get('USERPROFILE','')) + os.sep + '.rainbow_config.json'
-data = load_config(rainbow_config)
-for d in data:
- c[d] = data[d]
+rainbow_config = os.environ.get(
+ 'HOME',
+ os.environ.get(
+ 'USERPROFILE',
+ '')) + os.sep + '.rainbow_config.json'
+try:
+ data = load_config(rainbow_config)
+ for d in data:
+ c[d] = data[d]
+ c['theme'] = 'custom'
+except:
+ pass