Exemple #1
0
def _load_file(config_file):
    """Read configuration from a file.

    This reads `config_file`, yielding each non-empty line with
    whitespace and comments stripped off.
    """
    with open(config_file, 'rt', encoding='utf-8') as f:
        yield from transduce(CONFIG_FILE_PARSER, f)
Exemple #2
0
def _load_file(config_file):
    """Read configuration from a file.

    This reads `config_file`, yielding each non-empty line with
    whitespace and comments stripped off.
    """
    with open(config_file, 'rt', encoding='utf-8') as f:
        yield from transduce(CONFIG_FILE_PARSER, f)
Exemple #3
0
    def test_chained_transducers(self):
        result = transduce(transducer=compose(
                         mapping(lambda x: x*x),
                         filtering(lambda x: x % 5 != 0),
                         taking(6),
                         dropping_while(lambda x: x < 15),
                         distinct()),
                     iterable=range(20))

        expected = [16, 36, 49]
        for r, e in zip(result, expected):
            self.assertEqual(r, e)
    def test_chained_transducers(self):
        result = transduce(
            transducer=compose(
                mapping(lambda x: x * x),
                filtering(lambda x: x % 5 != 0),
                taking(6),
                dropping_while(lambda x: x < 15),
                distinct(),
            ),
            iterable=range(20),
        )

        expected = [16, 36, 49]
        for r, e in zip(result, expected):
            self.assertEqual(r, e)