From: Vu Nhat Minh Date: Thu, 3 Jul 2014 04:34:49 +0000 (+0900) Subject: check if None X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=a5301bc04171f5a7cb1a928ced38e912628cfa85;p=rainbowstream.git check if None --- 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(