def check(view=None):
    """Perform a linter check on the view
        """
    if view is None:
        view = get_current_active_view()

    if not get_setting('python_linting', view, True):
        return

    filename = file_or_buffer_name(view)
    proxy = proxy_for(view)
    if not proxy:
        return

    lint_settings = {
        'pep8':
        get_setting('pep8', view, default_value=True),
        'pep8_ignore':
        get_setting('pep8_ignore', view, default_value=[]),
        'pep8_max_line_length':
        get_setting('pep8_max_line_length', view, default_value=None),
        'pyflakes_ignore':
        get_setting('pyflakes_ignore', view, default_value=[]),
    }

    code = view.substr(sublime.Region(0, view.size()))
    encoding = view.encoding()
    if encoding.lower() == "undefined":
        encoding = "utf-8"
    errors = proxy.check_syntax(code, encoding, lint_settings, filename)
    try:
        errors = pickle.loads(errors.data)

        vid = view.id()
        lines = set()

        # leave this here for compatibility with original plugin
        error_underlines[vid] = []
        error_messages[vid] = {}
        violation_underlines[vid] = []
        violation_messages[vid] = {}
        warning_underlines[vid] = []
        warning_messages[vid] = {}

        parse_errors(view, errors, lines, vid)

        # the result can be a list of errors, or single syntax exception
        try:
            _update_lint_marks(view, lines)
        except Exception as e:
            print('SublimePythonIDE: Add lint marks failed\n{0}'.format(e))

        update_statusbar(view)
    except Exception as error:
        print("SublimePythonIDE: No server respose\n{0}".format(error))
def check(view=None):
    """Perform a linter check on the view
    """
    if view is None:
        view = get_current_active_view()

    if not get_setting('python_linting', view, True):
        return

    filename = file_or_buffer_name(view)
    proxy = proxy_for(view)
    if not proxy:
        return

    lint_settings = {
        'pep8': get_setting('pep8', view, default_value=True),
        'pep8_ignore': get_setting('pep8_ignore', view, default_value=[]),
        'pep8_max_line_length': get_setting(
            'pep8_max_line_length', view, default_value=None),
        'pyflakes_ignore': get_setting(
            'pyflakes_ignore', view, default_value=[]),
    }

    code = view.substr(sublime.Region(0, view.size()))
    encoding = view.encoding()
    if encoding.lower() == "undefined":
        encoding = "utf-8"
    errors = proxy.check_syntax(code, encoding, lint_settings, filename)
    try:
        errors = pickle.loads(errors.data)

        vid = view.id()
        lines = set()

        # leave this here for compatibility with original plugin
        error_underlines[vid] = []
        error_messages[vid] = {}
        violation_underlines[vid] = []
        violation_messages[vid] = {}
        warning_underlines[vid] = []
        warning_messages[vid] = {}

        parse_errors(view, errors, lines, vid)

        # the result can be a list of errors, or single syntax exception
        try:
            _update_lint_marks(view, lines)
        except Exception as e:
            print('SublimePythonIDE: Add lint marks failed\n{0}'.format(e))

        update_statusbar(view)
    except Exception as error:
        print("SublimePythonIDE: No server respose\n{0}".format(error))
 def run(self, *args):
     view = get_current_active_view()
     override_view_setting('pep8', True, view)
     check(view)
 def run(self, *args):
     view = get_current_active_view()
     override_view_setting('pep8', True, view)
     check(view)