only check for .wakatime.conf if api_key setting not set

This commit is contained in:
Alan Hamlett 2013-08-04 22:15:47 -07:00
parent fc2776a125
commit a389c456ad

View File

@ -36,20 +36,21 @@ def convert_config_to_sublime_settings():
# To be backwards compatible, rename config file # To be backwards compatible, rename config file
settings = sublime.load_settings(SETTINGS) settings = sublime.load_settings(SETTINGS)
api_key = settings.get('api_key', '') api_key = settings.get('api_key', '')
if not api_key:
try: try:
with open(join(expanduser('~'), '.wakatime.conf')) as old_file: with open(join(expanduser('~'), '.wakatime.conf')) as old_file:
for line in old_file: for line in old_file:
line = line.split('=', 1) line = line.split('=', 1)
if line[0] == 'api_key': if line[0] == 'api_key':
api_key = line[1].strip() api_key = line[1].strip()
except IOError:
pass
settings.set('api_key', api_key)
sublime.save_settings(SETTINGS)
try: try:
os.remove(join(expanduser('~'), '.wakatime.conf')) os.remove(join(expanduser('~'), '.wakatime.conf'))
except: except:
pass pass
except IOError:
pass
settings.set('api_key', api_key)
sublime.save_settings(SETTINGS)
convert_config_to_sublime_settings() convert_config_to_sublime_settings()