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 c079d87b85e38d4526aa45488227402c8305cb91..183bfe35e84c2b9a604c5847fc2ca81b22b24505 100644
(file)
--- a/
rainbowstream/config.py
+++ b/
rainbowstream/config.py
@@
-2,7
+2,10
@@
import json
import re
import os
import os.path
import re
import os
import os.path
-from twitter.util import printNicely
+
+from .db import *
+
+db = RainbowDB()
# Regular expression for comments
comment_re = re.compile(
# Regular expression for comments
comment_re = re.compile(
@@
-10,26
+13,36
@@
comment_re = re.compile(
re.DOTALL | re.MULTILINE
)
re.DOTALL | re.MULTILINE
)
+
def load_config(filepath):
def load_config(filepath):
- try:
- with open(filepath) as f:
- content = ''.join(f.readlines())
+ """
+ Load config from filepath
+ """
+ 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)
- data = json.loads(content)
- for d in data:
- globals()[d] = data[d]
- except:
- pass
-
-# Image config
-IMAGE_SHIFT = 10
-IMAGE_MAX_HEIGHT = 40
+ return json.loads(content)
-# Load colorset
+# Load default colorset
+c = {}
default_config = 'rainbowstream/colorset/default.json'
default_config = 'rainbowstream/colorset/default.json'
-rainbow_config = os.environ.get('HOME', os.environ.get('USERPROFILE','')) + os.sep + '.rainbow_config.json'
-load_config(default_config)
-load_config(rainbow_config)
+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'
+try:
+ data = load_config(rainbow_config)
+ for d in data:
+ c[d] = data[d]
+ c['theme'] = 'custom'
+except:
+ pass