Пример #1
0
def test_tee():
    inner = MagicMock(side_effect=bonobo.identity)
    tee = bonobo.Tee(inner)
    results = []
    for i in range(10):
        results.append(tee('foo'))

    assert results == [NOT_MODIFIED] * 10
    assert len(inner.mock_calls) == 10
Пример #2
0
                       (row.get('postal_code', None), row.get('city', None)))),
            row.get('county', None),
            row.get('country'),
        )))

    print('  - {}address{}: {address}'.format(Fore.BLUE,
                                              Style.RESET_ALL,
                                              address=', '.join(address)))
    print('  - {}links{}: {links}'.format(Fore.BLUE,
                                          Style.RESET_ALL,
                                          links=', '.join(row['links'])))
    print('  - {}geometry{}: {geometry}'.format(Fore.BLUE, Style.RESET_ALL,
                                                **row))
    print('  - {}source{}: {source}'.format(Fore.BLUE,
                                            Style.RESET_ALL,
                                            source='datanova/' + API_DATASET))


graph = bonobo.Graph(
    OpenDataSoftAPI(dataset=API_DATASET,
                    netloc=API_NETLOC,
                    timezone='Europe/Paris'),
    normalize,
    bonobo.Filter(filter=lambda row: row.get('country') == 'France'),
    bonobo.JsonWriter(path='fablabs.txt', ioformat='arg0'),
    bonobo.Tee(display),
)

if __name__ == '__main__':
    bonobo.run(graph, services=get_default_services(__file__))