How to use the radian.console.suppress_stderr function in radian

To help you get started, we’ve selected a few radian examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github randy3k / radian / radian / completion.py View on Github external
def get_r_builtin_completions(self, document, complete_event):
        text_before = document.current_line_before_cursor
        completion_requested = complete_event.completion_requested

        library_prefix = LIBRARY_PATTERN.match(text_before)
        if library_prefix:
            return

        # somehow completion while typing is very slow in "print("
        # so we manually disable it
        if not completion_requested and "print(" in text_before and \
                re.match(r".*print\([^\)]*$", remove_nested_paren(text_before)):
            token = rcompletion.assign_line_buffer(text_before)
            text_before = token

        with suppress_stderr():
            try:
                token = rcompletion.assign_line_buffer(text_before)
                # do not timeout package::func
                if "::" in token or completion_requested:
                    timeout = 0
                else:
                    timeout = self.timeout
                rcompletion.complete_token(timeout)
                completions = rcompletion.retrieve_completions()
            except Exception:
                completions = []

        for c in completions:
            if c.startswith(token) and c != token:
                if c.endswith("=") and settings.completion_adding_spaces_around_equals:
                    c = c[:-1] + " = "
github randy3k / radian / radian / rutils.py View on Github external
def prase_text_complete(text):
    status = ffi.new("ParseStatus[1]")
    s = rstring_p(text)
    orig_stderr = sys.stderr
    sys.stderr = None
    with protected(s), suppress_stderr():
        lib.R_ParseVector(s, -1, status, lib.R_NilValue)
        sys.stderr = orig_stderr
    return status[0] != 2
github randy3k / radian / radian / completion.py View on Github external
def get_r_completions(self, document, complete_event):
        text_before = document.current_line_before_cursor

        with suppress_stderr():
            try:
                token = rcompletion.assign_line_buffer(text_before)
                rcompletion.complete_token()
                completions = rcompletion.retrieve_completions()
            except Exception:
                completions = []

        for c in completions:
            if c.startswith(token) and c != token:
                if c.endswith("="):
                    c = c[:-1] + " = "
                if c.endswith("::"):
                    # let get_package_completions handles it
                    continue
                yield Completion(c, -len(token))