Skip to content

Commit

Permalink
Merge branch 'fix_hook_files#231'
Browse files Browse the repository at this point in the history
  • Loading branch information
DamnWidget committed Dec 11, 2014
2 parents 41b4b14 + 1caf934 commit 01e707b
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions anaconda_lib/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import functools
import traceback
import subprocess
from collections import defaultdict

import sublime

Expand All @@ -29,6 +30,8 @@
NOT_SCRATCH = 0x02
LINTING_ENABLED = 0x04

ENVIRON_HOOK_INVALID = defaultdict(lambda: False)


def is_code(view, lang='python', ignore_comments=False, ignore_repl=False):
"""Determine if the given view location is `lang` code
Expand Down Expand Up @@ -132,12 +135,15 @@ def get_settings(view, name, default=None):
"""Get settings
"""

global ENVIRON_HOOK_INVALID

if view is None:
return default

plugin_settings = sublime.load_settings('Anaconda.sublime-settings')

if name in ('python_interpreter', 'extra_paths'):
if (name in ('python_interpreter', 'extra_paths')
and not ENVIRON_HOOK_INVALID[view.id()]):
if view.window() is not None and view.window().folders():
dirname = view.window().folders()[0]
while True:
Expand All @@ -148,7 +154,18 @@ def get_settings(view, name, default=None):
try:
data = json.loads(jsonfile.read())
except Exception as error:
print(error)
sublime.error_message(
"Anaconda Message:\n"
"I found an .anaconda environment file in {} "
"path but it doesn't seems to be a valid JSON "
"file.\n\nThat means that your .anaconda "
"hook file is being ignored.".format(
environfile
)
)
logging.error(error)
ENVIRON_HOOK_INVALID[view.id()] = True
break # stop loop
else:
return data.get(
name,
Expand Down

0 comments on commit 01e707b

Please sign in to comment.