How to use the pipenv.vendor.vistir.compat.to_native_string function in pipenv

To help you get started, we’ve selected a few pipenv 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 pypa / pipenv / pipenv / vendor / vistir / termcolors.py View on Github external
colored('Hello, World!', 'red', 'on_grey', ['blue', 'blink'])
        colored('Hello, World!', 'green')
    """
    if os.getenv('ANSI_COLORS_DISABLED') is None:
        style = "NORMAL"
        if 'bold' in attrs:
            style = "BRIGHT"
            attrs.remove('bold')
        if color is not None:
            color = color.upper()
            text = to_native_string("%s%s%s%s%s") % (
                to_native_string(getattr(colorama.Fore, color)),
                to_native_string(getattr(colorama.Style, style)),
                to_native_string(text),
                to_native_string(colorama.Fore.RESET),
                to_native_string(colorama.Style.NORMAL),
            )

        if on_color is not None:
            on_color = on_color.upper()
            text = to_native_string("%s%s%s%s") % (
                to_native_string(getattr(colorama.Back, on_color)),
                to_native_string(text),
                to_native_string(colorama.Back.RESET),
                to_native_string(colorama.Style.NORMAL),
            )

        if attrs is not None:
            fmt_str = to_native_string("%s[%%dm%%s%s[9m") % (
                chr(27),
                chr(27)
            )
github pypa / pipenv / pipenv / vendor / vistir / termcolors.py View on Github external
Available attributes:
        bold, dark, underline, blink, reverse, concealed.

    Example:
        colored('Hello, World!', 'red', 'on_grey', ['blue', 'blink'])
        colored('Hello, World!', 'green')
    """
    if os.getenv('ANSI_COLORS_DISABLED') is None:
        style = "NORMAL"
        if 'bold' in attrs:
            style = "BRIGHT"
            attrs.remove('bold')
        if color is not None:
            color = color.upper()
            text = to_native_string("%s%s%s%s%s") % (
                to_native_string(getattr(colorama.Fore, color)),
                to_native_string(getattr(colorama.Style, style)),
                to_native_string(text),
                to_native_string(colorama.Fore.RESET),
                to_native_string(colorama.Style.NORMAL),
            )

        if on_color is not None:
            on_color = on_color.upper()
            text = to_native_string("%s%s%s%s") % (
                to_native_string(getattr(colorama.Back, on_color)),
                to_native_string(text),
                to_native_string(colorama.Back.RESET),
                to_native_string(colorama.Style.NORMAL),
            )
github pypa / pipenv / pipenv / vendor / vistir / termcolors.py View on Github external
Example:
        colored('Hello, World!', 'red', 'on_grey', ['blue', 'blink'])
        colored('Hello, World!', 'green')
    """
    if os.getenv('ANSI_COLORS_DISABLED') is None:
        style = "NORMAL"
        if 'bold' in attrs:
            style = "BRIGHT"
            attrs.remove('bold')
        if color is not None:
            color = color.upper()
            text = to_native_string("%s%s%s%s%s") % (
                to_native_string(getattr(colorama.Fore, color)),
                to_native_string(getattr(colorama.Style, style)),
                to_native_string(text),
                to_native_string(colorama.Fore.RESET),
                to_native_string(colorama.Style.NORMAL),
            )

        if on_color is not None:
            on_color = on_color.upper()
            text = to_native_string("%s%s%s%s") % (
                to_native_string(getattr(colorama.Back, on_color)),
                to_native_string(text),
                to_native_string(colorama.Back.RESET),
                to_native_string(colorama.Style.NORMAL),
            )

        if attrs is not None:
            fmt_str = to_native_string("%s[%%dm%%s%s[9m") % (
                chr(27),
github pypa / pipenv / pipenv / vendor / vistir / termcolors.py View on Github external
if 'bold' in attrs:
            style = "BRIGHT"
            attrs.remove('bold')
        if color is not None:
            color = color.upper()
            text = to_native_string("%s%s%s%s%s") % (
                to_native_string(getattr(colorama.Fore, color)),
                to_native_string(getattr(colorama.Style, style)),
                to_native_string(text),
                to_native_string(colorama.Fore.RESET),
                to_native_string(colorama.Style.NORMAL),
            )

        if on_color is not None:
            on_color = on_color.upper()
            text = to_native_string("%s%s%s%s") % (
                to_native_string(getattr(colorama.Back, on_color)),
                to_native_string(text),
                to_native_string(colorama.Back.RESET),
                to_native_string(colorama.Style.NORMAL),
            )

        if attrs is not None:
            fmt_str = to_native_string("%s[%%dm%%s%s[9m") % (
                chr(27),
                chr(27)
            )
            for attr in attrs:
                text = fmt_str % (ATTRIBUTES[attr], text)

        text += RESET
    return text
github pypa / pipenv / pipenv / vendor / vistir / spin.py View on Github external
def write_err(self, text):
        """Write error text in the terminal without breaking the spinner."""
        from .misc import to_text

        self.stderr.write("\r")
        self.stderr.write(CLEAR_LINE)
        if text is None:
            text = ""
        text = to_native_string("{0}\n".format(text))
        self.stderr.write(text)
        self.out_buff.write(to_text(text))
github pypa / pipenv / pipenv / vendor / vistir / spin.py View on Github external
def write(self, text):
        from .misc import to_text
        sys.stdout.write("\r")
        self.stdout.write(CLEAR_LINE)
        if text is None:
            text = ""
        text = to_native_string("{0}\n".format(text))
        sys.stdout.write(text)
        self.out_buff.write(to_text(text))
github pypa / pipenv / pipenv / vendor / vistir / spin.py View on Github external
def _compose_out(self, frame, mode=None):
        # Ensure Unicode input

        frame = to_native_string(frame)
        if self._text is None:
            self._text = ""
        text = to_native_string(self._text)
        if self._color_func is not None:
            frame = self._color_func(frame)
        if self._side == "right":
            frame, text = text, frame
        # Mode
        if not mode:
            out = to_native_string("\r{0} {1}".format(frame, text))
        else:
            out = to_native_string("{0} {1}\n".format(frame, text))
        return out
github pypa / pipenv / pipenv / vendor / vistir / termcolors.py View on Github external
Example:
        colored('Hello, World!', 'red', 'on_grey', ['blue', 'blink'])
        colored('Hello, World!', 'green')
    """
    if os.getenv('ANSI_COLORS_DISABLED') is None:
        style = "NORMAL"
        if 'bold' in attrs:
            style = "BRIGHT"
            attrs.remove('bold')
        if color is not None:
            color = color.upper()
            text = to_native_string("%s%s%s%s%s") % (
                to_native_string(getattr(colorama.Fore, color)),
                to_native_string(getattr(colorama.Style, style)),
                to_native_string(text),
                to_native_string(colorama.Fore.RESET),
                to_native_string(colorama.Style.NORMAL),
            )

        if on_color is not None:
            on_color = on_color.upper()
            text = to_native_string("%s%s%s%s") % (
                to_native_string(getattr(colorama.Back, on_color)),
                to_native_string(text),
                to_native_string(colorama.Back.RESET),
                to_native_string(colorama.Style.NORMAL),
            )

        if attrs is not None:
            fmt_str = to_native_string("%s[%%dm%%s%s[9m") % (
                chr(27),
                chr(27)
github pypa / pipenv / pipenv / vendor / vistir / spin.py View on Github external
def _freeze(self, final_text):
        """Stop spinner, compose last frame and 'freeze' it."""
        if not final_text:
            final_text = ""
        text = to_native_string(final_text)
        self._last_frame = self._compose_out(text, mode="last")

        # Should be stopped here, otherwise prints after
        # self._freeze call will mess up the spinner
        self.stop()
        self.stdout.write(self._last_frame)