コード例 #1
0
ファイル: logger.py プロジェクト: duckzland/jxmonitor
    def processText(self, text):

        if self.type == 'serverlog':
            text = text.splitlines()

        if not isinstance(text, list):
            return False

        try:
            total = len(text);
            if total < 11:
                for i in range(11 - total):
                    text.append("\n")

            for i, t in enumerate(text):

                t = re.sub(r'\[\d+\-\d+\-\d+ \d+:\d+:\d+\]', '-', t)
                t = t.strip()

                # Ethminer special text
                t = re.sub(r'(?:  m | cu )', '+', t)
                t = re.sub(r'\d+:\d+:\d+\|\w+\|  ', '', t)

                # Convert VT100 to Urwid color
                t = parse_input(t, False, True)[0]
                t = self.printText(t)

                t.append('\n')
                text[i] = t

        except Exception as e:
            print e

        return text
コード例 #2
0
ファイル: test_parse.py プロジェクト: t-brull/colorclass
def test_parse_input_keep_tags(disable, in_, expected_colors, expected_no_colors):
    """Test function with keep_tags=True.

    :param bool disable: Disable colors?
    :param str in_: Input string to pass to function.
    :param str expected_colors: Expected first item of return value.
    :param str expected_no_colors: Expected second item of return value.
    """
    actual_colors, actual_no_colors = parse_input(in_, disable, True)
    if disable:
        assert actual_colors == expected_no_colors
    else:
        assert actual_colors == expected_colors
    assert actual_no_colors == expected_no_colors
コード例 #3
0
ファイル: core.py プロジェクト: BillWang139967/linux_terminal
    def __new__(cls, *args, **kwargs):
        """Parse color markup and instantiate."""
        keep_tags = kwargs.pop('keep_tags', False)

        # Parse string.
        value_markup = args[0] if args else PARENT_CLASS()  # e.g. '{red}test{/red}'
        value_colors, value_no_colors = parse_input(value_markup, ANSICodeMapping.DISABLE_COLORS, keep_tags)
        color_index = build_color_index(value_colors)

        # Instantiate.
        color_args = [cls, value_colors] + list(args[1:])
        instance = PARENT_CLASS.__new__(*color_args, **kwargs)

        # Add additional attributes and return.
        instance.value_colors = value_colors
        instance.value_no_colors = value_no_colors
        instance.has_colors = value_colors != value_no_colors
        instance.color_index = color_index
        return instance
コード例 #4
0
    def __new__(cls, *args, **kwargs):
        """Parse color markup and instantiate."""
        keep_tags = kwargs.pop('keep_tags', False)

        # Parse string.
        value_markup = args[0] if args else PARENT_CLASS(
        )  # e.g. '{red}test{/red}'
        value_colors, value_no_colors = parse_input(
            value_markup, ANSICodeMapping.DISABLE_COLORS, keep_tags)
        color_index = build_color_index(value_colors)

        # Instantiate.
        color_args = [cls, value_colors] + list(args[1:])
        instance = PARENT_CLASS.__new__(*color_args, **kwargs)

        # Add additional attributes and return.
        instance.value_colors = value_colors
        instance.value_no_colors = value_no_colors
        instance.has_colors = value_colors != value_no_colors
        instance.color_index = color_index
        return instance