How to use the tsrc.ui._Characters function in tsrc

To help you get started, we’ve selected a few tsrc 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 TankerHQ / tsrc / tsrc / ui.py View on Github external
fuscia = fuchsia

# Other nice-to-have characters:
class _Characters:
    def __init__(self, color, as_unicode, as_ascii):
        if os.name == "nt":
            self.as_string = as_ascii
        else:
            self.as_string = as_unicode
        self.color = color

    def tuple(self):
        return (reset, self.color, self.as_string, reset)


ellipsis = _Characters(reset, "…", "...")
check    = _Characters(green, "✓", "ok")
cross    = _Characters(red,   "❌","ko")

def configure_logging(args):
    verbose = os.environ.get("VERBOSE", False)
    if not verbose:
        verbose = args.verbose
    CONFIG["color"] = args.color
    CONFIG["title"] = args.title
    CONFIG["verbose"] = verbose
    CONFIG["quiet"] = args.quiet


def using_colorama():
    if os.name == "nt":
        if "TERM" not in os.environ:
github TankerHQ / tsrc / tsrc / ui.py View on Github external
# Other nice-to-have characters:
class _Characters:
    def __init__(self, color, as_unicode, as_ascii):
        if os.name == "nt":
            self.as_string = as_ascii
        else:
            self.as_string = as_unicode
        self.color = color

    def tuple(self):
        return (reset, self.color, self.as_string, reset)


ellipsis = _Characters(reset, "…", "...")
check    = _Characters(green, "✓", "ok")
cross    = _Characters(red,   "❌","ko")

def configure_logging(args):
    verbose = os.environ.get("VERBOSE", False)
    if not verbose:
        verbose = args.verbose
    CONFIG["color"] = args.color
    CONFIG["title"] = args.title
    CONFIG["verbose"] = verbose
    CONFIG["quiet"] = args.quiet


def using_colorama():
    if os.name == "nt":
        if "TERM" not in os.environ:
            return True
github TankerHQ / tsrc / tsrc / ui.py View on Github external
# Other nice-to-have characters:
class _Characters:
    def __init__(self, color, as_unicode, as_ascii):
        if os.name == "nt":
            self.as_string = as_ascii
        else:
            self.as_string = as_unicode
        self.color = color

    def tuple(self):
        return (reset, self.color, self.as_string, reset)


ellipsis = _Characters(reset, "…", "...")
check    = _Characters(green, "✓", "ok")
cross    = _Characters(red,   "❌","ko")

def configure_logging(args):
    verbose = os.environ.get("VERBOSE", False)
    if not verbose:
        verbose = args.verbose
    CONFIG["color"] = args.color
    CONFIG["title"] = args.title
    CONFIG["verbose"] = verbose
    CONFIG["quiet"] = args.quiet


def using_colorama():
    if os.name == "nt":
        if "TERM" not in os.environ:
            return True
        if os.environ["TERM"] == "cygwin":
github TankerHQ / tsrc / tsrc / ui.py View on Github external
def process_tokens(tokens, *, end="\n", sep=" "):
    """ Returns two strings from a list of tokens.
    One containing ASCII escape codes, the other
    only the 'normal' characters

    """
    # Flatten the list of tokens in case some of them are of class _Characters
    flat_tokens = list()
    for token in tokens:
        if isinstance(token, _Characters):
            flat_tokens.extend(token.tuple())
        else:
            flat_tokens.append(token)

    with_color = _process_tokens(flat_tokens, end=end, sep=sep, color=True)
    without_color = _process_tokens(flat_tokens, end=end, sep=sep, color=False)
    return (with_color, without_color)