<commit_before>import sublime

from os.path import exists
from os.path import join
from os.path import realpath
from subprocess import check_output
from subprocess import PIPE

from Dart.lib.path import join_on_win

from subprocess import Popen
from subprocess import STDOUT
from subprocess import TimeoutExpired
import os
import re
import threading

from Dart import PluginLogger
from Dart.lib.error import ConfigError
from Dart.lib.error import FatalConfigError
from Dart.lib.filter import TextFilter
from Dart.lib.path import join_on_win
from Dart.lib.plat import is_windows
from Dart.lib.plat import supress_window
from Dart.lib.path import to_platform_path
from Dart.lib.io import AsyncStreamReader
from Dart.lib.text import decode_and_clean


_logger = PluginLogger(__name__)


class SDK(object):
    """Wraps the Dart SDK.
    """
    # TODO(guillermooo): make this class more test-friendly.
    def __init__(self):
        self.setts = sublime.load_settings('Dart - Plugin Settings.sublime-settings')

        p = os.path.expandvars(os.path.expanduser(self.setts.get('dart_sdk_path')))
        try:
            if not os.path.exists(
                os.path.join(p, 'bin', join_on_win('dart', '.exe'))):
                    msg = 'wrong path in dart_sdk_path: {}'.format(p)
                    raise FatalConfigError(msg)
            self._path = p

        except TypeError:
            msg = 'invalid value of dart_sdk_path: {}'.format(p)
            raise FatalConfigError(msg)

    @property
    def enable_experimental_features(self):
        return (self.setts.get('dart_enable_experimental_editor_features') is True)

    @property
    def path_to_analysis_snapshot(self):
        if not self.enable_experimental_features:
            return None
<commit_msg>Handle possible exceptions<commit_after>import sublime

from os.path import exists
from os.path import join
from os.path import realpath
from subprocess import check_output
from subprocess import PIPE

from Dart.lib.path import join_on_win

from subprocess import Popen
from subprocess import STDOUT
from subprocess import TimeoutExpired
import os
import re
import threading

from Dart import PluginLogger
from Dart.lib.error import ConfigError
from Dart.lib.error import FatalConfigError
from Dart.lib.filter import TextFilter
from Dart.lib.path import join_on_win
from Dart.lib.plat import is_windows
from Dart.lib.plat import supress_window
from Dart.lib.path import to_platform_path
from Dart.lib.io import AsyncStreamReader
from Dart.lib.text import decode_and_clean


_logger = PluginLogger(__name__)


class SDK(object):
    """Wraps the Dart SDK.
    """
    # TODO(guillermooo): make this class more test-friendly.
    def __init__(self):
        self.setts = sublime.load_settings('Dart - Plugin Settings.sublime-settings')

        try:
            p = os.path.expandvars(os.path.expanduser(self.setts.get('dart_sdk_path')))
            if not os.path.exists(
                os.path.join(p, 'bin', join_on_win('dart', '.exe'))):
                    msg = 'wrong path in dart_sdk_path: {}'.format(p)
                    raise FatalConfigError(msg)
            self._path = p

        except (TypeError, AttributeError):
            msg = 'invalid value of dart_sdk_path: {}'.format(p)
            raise FatalConfigError(msg)

    @property
    def enable_experimental_features(self):
        return (self.setts.get('dart_enable_experimental_editor_features') is True)

    @property
    def path_to_analysis_snapshot(self):
        if not self.enable_experimental_features:
            return None

{'fraction_non_alphanumeric': 0.07786770862405805, 'fraction_numerical': 0.0, 'mean_word_length': 3.287081339712919, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6379956', 'n_tokens_mistral': 1105, 'n_tokens_neox': 1036, 'n_words': 301}