projects
/
rainbowstream.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix sqlalchemy bug
[rainbowstream.git]
/
rainbowstream
/
config.py
diff --git
a/rainbowstream/config.py
b/rainbowstream/config.py
index 418afbb0a03411a1a563cdb5d479c4c5c43c4215..a5e542d5afcd492338ae2ea7f568b5ff2c4d5c2e 100644
(file)
--- a/
rainbowstream/config.py
+++ b/
rainbowstream/config.py
@@
-3,6
+3,7
@@
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]*)($)?',
# Regular expression for comments
comment_re = re.compile(
'(^)?[^\S\n]*/(?:\*(.*?)\*/[^\S\n]*|/[^\n]*)($)?',
@@
-14,16
+15,13
@@
def load_config(filepath):
"""
Load config from 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 = {}
@@
-31,12
+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
rainbow_config = os.environ.get(
'HOME',
os.environ.get(
'USERPROFILE',
'')) + os.sep + '.rainbow_config.json'
# 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]
+try:
+ data = load_config(rainbow_config)
+ for d in data:
+ c[d] = data[d]
+ c['theme'] = 'custom'
+except:
+ pass