Esempio n. 1
0
    def test_append_custom_entries_color(self, _, __):
        """Check that `Output` honor `ANSI_COLOR` as required"""
        output = Output()
        output.append("key", "value")

        self.assertListEqual(
            output._results,  # pylint: disable=protected-access
            [f"\x1b[5;31;47mkey:{Colors.CLEAR} value"])
Esempio n. 2
0
    def test_append_regular(self, _, __):
        """Test the `append` method, for new entries"""
        output = Output()
        output.append('KEY', 'VALUE')

        self.assertListEqual(
            output._results,  # pylint: disable=protected-access
            ['COLOR_0KEY:{clear} VALUE'.format(clear=Colors.CLEAR)])
Esempio n. 3
0
    def test_append(self):
        """Test the `append` method, for new entries"""
        output = Output()

        # Let's manually set the distribution for the test case...
        output.distribution = Distributions.DEBIAN

        output.append('KEY', 'VALUE')

        self.assertEqual(output.results, ['COLOR_1KEY:CLEAR VALUE'])
Esempio n. 4
0
def main():
    """Simple entry point"""

    # `Processes` is a singleton, let's populate the internal list here.
    Processes()

    # `Configuration` is a singleton, let's populate the internal object here.
    configuration = Configuration()

    output = Output()
    for entry in Entries:
        if configuration.get('entries', {}).get(entry.name, True):
            output.append(entry.name, entry.value().value)

    output.output()
Esempio n. 5
0
    def test_append_ansi_color(self, _, __):
        """Check that `Output` honor `ANSI_COLOR` as required"""
        output = Output()
        output.append("key", "value")

        # Slackware logo got three colors, so let's check they have been correctly replaced.
        self.assertTrue(
            all('ANSI_COLOR' in str(color) for color in output._colors)  # pylint: disable=protected-access
        )
        self.assertEqual(
            len(output._colors),  # pylint: disable=protected-access
            3  # Slackware's logo got 3 defined colors.
        )
        self.assertListEqual(
            output._results,  # pylint: disable=protected-access
            [f"\x1b[ANSI_COLORmkey:{Colors.CLEAR} value"])
Esempio n. 6
0
    def test_append_no_ansi_color(self, _, __):
        """Check that `Output` DOES NOT honor `ANSI_COLOR` when specified"""
        output = Output()
        output.append("key", "value")

        # Check that NO colors have been replaced (actually, that the list is the same as before).
        self.assertFalse(
            any('ANSI_COLOR' in str(color) for color in output._colors)  # pylint: disable=protected-access
        )
        self.assertListEqual(
            output._colors,  # pylint: disable=protected-access
            [  # Windows' colors palettes, unmodified.
                Colors.BLUE_BRIGHT, Colors.RED_BRIGHT, Colors.GREEN_BRIGHT,
                Colors.YELLOW_NORMAL
            ])
        self.assertListEqual(
            output._results,  # pylint: disable=protected-access
            [f"{Colors.BLUE_BRIGHT}key:{Colors.CLEAR} value"])
Esempio n. 7
0
def main():
    """Simple entry point"""
    parser = argparse.ArgumentParser(prog='archey')
    parser.add_argument('-v',
                        '--version',
                        action='version',
                        version=__version__)
    parser.parse_args()

    # `Processes` is a singleton, let's populate the internal list here.
    Processes()

    # `Configuration` is a singleton, let's populate the internal object here.
    configuration = Configuration()

    output = Output()
    for entry in Entries:
        if configuration.get('entries', {}).get(entry.name, True):
            output.append(entry.name, entry.value().value)

    output.output()