From a389c456adc17355e3f8ae0d00087f6f3778c7aa Mon Sep 17 00:00:00 2001 From: Alan Hamlett Date: Sun, 4 Aug 2013 22:15:47 -0700 Subject: [PATCH] only check for .wakatime.conf if api_key setting not set --- sublime-wakatime.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/sublime-wakatime.py b/sublime-wakatime.py index a249683..76d0585 100644 --- a/sublime-wakatime.py +++ b/sublime-wakatime.py @@ -36,20 +36,21 @@ def convert_config_to_sublime_settings(): # To be backwards compatible, rename config file settings = sublime.load_settings(SETTINGS) api_key = settings.get('api_key', '') - try: - with open(join(expanduser('~'), '.wakatime.conf')) as old_file: - for line in old_file: - line = line.split('=', 1) - if line[0] == 'api_key': - api_key = line[1].strip() - except IOError: - pass + if not api_key: + try: + with open(join(expanduser('~'), '.wakatime.conf')) as old_file: + for line in old_file: + line = line.split('=', 1) + if line[0] == 'api_key': + api_key = line[1].strip() + try: + os.remove(join(expanduser('~'), '.wakatime.conf')) + except: + pass + except IOError: + pass settings.set('api_key', api_key) sublime.save_settings(SETTINGS) - try: - os.remove(join(expanduser('~'), '.wakatime.conf')) - except: - pass convert_config_to_sublime_settings()