How to use the plumbum.colors function in plumbum

To help you get started, we’ve selected a few plumbum 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 tomerfiliba / plumbum / tests / test_factories.py View on Github external
def testRepresentations(self):
        colors1 = colors.full(87)
        assert colors1 == colors.DarkSlateGray2
        assert colors1.basic == colors.DarkSlateGray2
        assert str(colors1.basic) == str(colors.LightGray)

        colors2 = colors.rgb(1,45,214)
        assert str(colors2.full) == str(colors.Blue3A)
github tomerfiliba / plumbum / tests / test_factories.py View on Github external
def testLoadColorByName(self):
        assert colors['LightBlue'] == colors.fg['LightBlue']
        assert colors.bg['light_green'] == colors.bg['LightGreen']
        assert colors['DeepSkyBlue1'] == colors['#00afff']
        assert colors['DeepSkyBlue1'] == colors.hex('#00afff')

        assert colors['DeepSkyBlue1'] == colors[39]
        assert colors.DeepSkyBlue1 == colors[39]
        assert colors.deepskyblue1 == colors[39]
        assert colors.Deep_Sky_Blue1 == colors[39]
        assert colors.RED == colors.red

        with pytest.raises(AttributeError):
            colors.Notacolorsatall
github tomerfiliba / plumbum / tests / test_factories.py View on Github external
def testLoadNumericalColor(self):
        assert colors.full(2) == colors[2]
        assert colors.simple(2) == colors(2)
        assert colors(54) == colors[54]
        assert colors(1,30,77) == colors.rgb(1,30,77)
        assert colors[1,30,77] == colors.rgb(1,30,77)
github tomerfiliba / plumbum / tests / test_factories.py View on Github external
def testRepresentations(self):
        colors1 = colors.full(87)
        assert colors1 == colors.DarkSlateGray2
        assert colors1.basic == colors.DarkSlateGray2
        assert str(colors1.basic) == str(colors.LightGray)

        colors2 = colors.rgb(1,45,214)
        assert str(colors2.full) == str(colors.Blue3A)
github tomerfiliba / plumbum / tests / test_factories.py View on Github external
def testLoadColorByName(self):
        assert colors['LightBlue'] == colors.fg['LightBlue']
        assert colors.bg['light_green'] == colors.bg['LightGreen']
        assert colors['DeepSkyBlue1'] == colors['#00afff']
        assert colors['DeepSkyBlue1'] == colors.hex('#00afff')

        assert colors['DeepSkyBlue1'] == colors[39]
        assert colors.DeepSkyBlue1 == colors[39]
        assert colors.deepskyblue1 == colors[39]
        assert colors.Deep_Sky_Blue1 == colors[39]
        assert colors.RED == colors.red

        with pytest.raises(AttributeError):
            colors.Notacolorsatall
github tomerfiliba / plumbum / tests / test_factories.py View on Github external
def testLoadColorByName(self):
        assert colors['LightBlue'] == colors.fg['LightBlue']
        assert colors.bg['light_green'] == colors.bg['LightGreen']
        assert colors['DeepSkyBlue1'] == colors['#00afff']
        assert colors['DeepSkyBlue1'] == colors.hex('#00afff')

        assert colors['DeepSkyBlue1'] == colors[39]
        assert colors.DeepSkyBlue1 == colors[39]
        assert colors.deepskyblue1 == colors[39]
        assert colors.Deep_Sky_Blue1 == colors[39]
        assert colors.RED == colors.red

        with pytest.raises(AttributeError):
            colors.Notacolorsatall
github tomerfiliba / plumbum / tests / test_factories.py View on Github external
def testUndoColor(self):
        assert '\033[39m' == ~colors.fg
        assert '\033[49m' == ~colors.bg
        assert '\033[22m' == ~colors.bold
        assert '\033[22m' == ~colors.dim
        for i in range(7):
            assert '\033[39m' == ~colors(i)
            assert '\033[49m' == ~colors.bg(i)
            assert '\033[39m' == ~colors.fg(i)
            assert '\033[49m' == ~colors.bg(i)
        for i in range(256):
            assert '\033[39m' == ~colors.fg[i]
            assert '\033[49m' == ~colors.bg[i]
        assert '\033[0m' == ~colors.reset
        assert colors.do_nothing == ~colors.do_nothing

        assert colors.bold.reset == ~colors.bold
github tomerfiliba / plumbum / tests / test_factories.py View on Github external
def testEmptyStyle(self):
        assert str(colors()) == ''
        assert str(colors('')) == ''
        assert str(colors(None)) == ''
github tomerfiliba / plumbum / tests / test_visual_color.py View on Github external
def testToggleColors(self):
        print()
        print(colors.fg.red["This is in red"], "but this is not")
        print(colors.fg.green + "Hi, " + colors.bg[23]
              + "This is on a BG" + ~colors.bg + " and this is not but is still green.")
        colors.yellow.print("This is printed from color.")
        colors.reset()

        for attr in colors._style.attribute_names:
            print("This is", attr | getattr(colors, attr), "and this is not.")
            colors.reset()
github tomerfiliba / plumbum / plumbum / cli / application.py View on Github external
msg = indentation.join(
                        wrapper.wrap(" ".join(
                            l.strip() for l in help.splitlines())))

                    if len(name) + wrapper.width >= cols:
                        padding = indentation
                    else:
                        padding = " " * max(
                            cols - wrapper.width - len(name) - 4, 1)
                    if colors.contains_colors(subcls.name):
                        bodycolor = colors.extract(subcls.name)
                    else:
                        bodycolor = gc

                    print(description_indent.format(
                        subcls.name, padding, bodycolor | colors.filter(msg)))