check if None
authorVu Nhat Minh <vunhat_minh@dwango.co.jp>
Thu, 3 Jul 2014 04:34:49 +0000 (13:34 +0900)
committerVu Nhat Minh <vunhat_minh@dwango.co.jp>
Thu, 3 Jul 2014 04:34:49 +0000 (13:34 +0900)
rainbowstream/config.py
rainbowstream/draw.py
rainbowstream/rainbow.py

index 4b4aef6fbc44bd15dc587067d9c584361b13c71e..828a51710a6cbfccd740274e88f9969ba7b0fee4 100644 (file)
@@ -29,14 +29,15 @@ def load_config(filepath):
         return json.loads(content)
     except IOError:
         db.theme_store('default')
-        pass
+        return None
 
 # Load default colorset
 c = {}
 default_config = 'rainbowstream/colorset/default.json'
 data = load_config(default_config)
-for d in data:
-    c[d] = data[d]
+if data:
+    for d in data:
+        c[d] = data[d]
 # Load user's colorset
 rainbow_config = os.environ.get(
     'HOME',
@@ -44,5 +45,6 @@ rainbow_config = os.environ.get(
         'USERPROFILE',
         '')) + os.sep + '.rainbow_config.json'
 data = load_config(rainbow_config)
-for d in data:
-    c[d] = data[d]
+if data:
+    for d in data:
+        c[d] = data[d]
index 5063df4ed73b6422705a39609568014410f6d865..ab50d01b3dfb0069e75260f93fa9a479f23fe8dc 100644 (file)
@@ -35,8 +35,9 @@ def check_theme():
             config = 'rainbowstream/colorset/'+cur_theme+'.json'
         # Load new config
         data = load_config(config)
-        for d in data:
-            c[d] = data[d]
+        if data:
+            for d in data:
+                c[d] = data[d]
 
 
 def color_func(func_name):
index 00e01eb9e6079175e5ba9c1ba7b315b3e2ee3109..71957448716fe6bcd05f3207d215125dd49de888 100644 (file)
@@ -789,8 +789,9 @@ def theme():
             # Load new config
             new_config = 'rainbowstream/colorset/' + g['stuff'] + '.json'
             new_config = load_config(new_config)
-            for nc in new_config:
-                c[nc] = new_config[nc]
+            if new_config
+                for nc in new_config:
+                    c[nc] = new_config[nc]
             # Update db
             theme_update(g['stuff'])
             g['decorated_name'] = color_func(