json load
authorVu Nhat Minh <vunhat_minh@dwango.co.jp>
Wed, 2 Jul 2014 07:11:50 +0000 (16:11 +0900)
committerVu Nhat Minh <vunhat_minh@dwango.co.jp>
Wed, 2 Jul 2014 07:11:50 +0000 (16:11 +0900)
rainbowstream/colorset/__init__.py [deleted file]
rainbowstream/colorset/default.json [new file with mode: 0644]
rainbowstream/colorset/default.py
rainbowstream/config.py

diff --git a/rainbowstream/colorset/__init__.py b/rainbowstream/colorset/__init__.py
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/rainbowstream/colorset/default.json b/rainbowstream/colorset/default.json
new file mode 100644 (file)
index 0000000..4e3e36a
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+Default color config for rainbowstream
+Following 16 basic colors is supported:
+  default
+  black
+  red
+  green
+  yellow
+  blue
+  magenta
+  cyan
+  grey
+  light_red
+  light_green
+  light_yellow
+  light_blue
+  light_magenta
+  light_cyan
+  white
+*/
+
+{
+    "TWEET" : {
+        "nick"      : "grey",
+        "clock"     : "grey",
+        "id"        : "grey",
+        "favourite" : "light_green",
+        "rt"        : "grey",
+        "link"      : "light_cyan",
+        "keyword"   : "on_light_yellow",
+    },
+
+    "MESSAGE" : {
+        "sender"    : "grey",
+        "recipient" : "grey",
+        "to"        : "light_magenta",
+        "clock"     : "grey",
+        "id"        : "grey",
+    },
+
+    "PROFILE" : {
+        "statuses_count"    : "light_green",
+        "friends_count"     : "light_green",
+        "followers_count"   : "light_green",
+        "nick"              : "grey",
+        "profile_image_url" : "light_cyan",
+        "description"       : "light_yellow",
+        "location"          : "light_magenta",
+        "url"               : "light_cyan",
+        "clock"             : "white",
+    },
+
+    "TREND" : {
+        "url": "light_cyan",
+    }
+
+}
\ No newline at end of file
index e6a7adc766e601364ab09aacebdd85dc3adf4f1a..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,53 +0,0 @@
-########## Default color config for rainbowstream ##########
-
-# Following 16 basic colors is supported:
-#   default
-#   black
-#   red
-#   green
-#   yellow
-#   blue
-#   magenta
-#   cyan
-#   grey
-#   light_red
-#   light_green
-#   light_yellow
-#   light_blue
-#   light_magenta
-#   light_cyan
-#   white
-
-TWEET = {
-    'nick'      : grey,
-    'clock'     : grey,
-    'id'        : grey,
-    'favourite' : light_green,
-    'rt'        : grey,
-    'link'      : light_cyan,
-    'keyword'   : on_light_yellow,
-}
-
-MESSAGE = {
-    'sender'    : grey,
-    'recipient' : grey,
-    'to'        : light_magenta,
-    'clock'     : grey,
-    'id'        : grey,
-}
-
-PROFILE = {
-    'statuses_count'    : light_green,
-    'friends_count'     : light_green,
-    'followers_count'   : light_green,
-    'nick'              : grey,
-    'profile_image_url' : light_cyan,
-    'description'       : light_yellow,
-    'location'          : light_magenta,
-    'url'               : light_cyan,
-    'clock'             : white,
-}
-
-TREND = {
-    'url': light_cyan,
-}
index 837aec0d4c19a59076ff3b0ff3947aeaff29c1eb..67dfc91fc6a6f9f0071594882cd527796b645476 100644 (file)
@@ -30,18 +30,22 @@ IMAGE_SHIFT = 10
 IMAGE_MAX_HEIGHT = 40
 
 # Load colorset
-COLOR_SET = ['colorset.default']
-modules = map(__import__, COLOR_SET)
+default_colorset = 'colorset/default.json'
+try:
+    if os.path.exists(default_colorset):
+        data = json.load(open(default_colorset))
+        for d in data:
+            locals()[d] = local()[data[d]]
+except:
+    pass
 
 # Load json config
-rainbow_config = os.environ.get(
-    'HOME', os.environ.get('USERPROFILE',''))
-    + os.sep + '.rainbow_config.json'
+rainbow_config = os.environ.get('HOME', os.environ.get('USERPROFILE','')) + os.sep + '.rainbow_config.json'
 try:
     if os.path.exists(rainbow_config):
         data = json.load(open(rainbow_config))
         for d in data:
-            locals()[d] = data[d]
+            locals()[d] = local()[data[d]]
 except:
     pass