From a5301bc04171f5a7cb1a928ced38e912628cfa85 Mon Sep 17 00:00:00 2001 From: Vu Nhat Minh Date: Thu, 3 Jul 2014 13:34:49 +0900 Subject: [PATCH] check if None --- rainbowstream/config.py | 12 +++++++----- rainbowstream/draw.py | 5 +++-- rainbowstream/rainbow.py | 5 +++-- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/rainbowstream/config.py b/rainbowstream/config.py index 4b4aef6..828a517 100644 --- a/rainbowstream/config.py +++ b/rainbowstream/config.py @@ -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] diff --git a/rainbowstream/draw.py b/rainbowstream/draw.py index 5063df4..ab50d01 100644 --- a/rainbowstream/draw.py +++ b/rainbowstream/draw.py @@ -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): diff --git a/rainbowstream/rainbow.py b/rainbowstream/rainbow.py index 00e01eb..7195744 100644 --- a/rainbowstream/rainbow.py +++ b/rainbowstream/rainbow.py @@ -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( -- 2.25.1