示例#1
0
def get_graph(*, _limit=(), _print=()):
    return bonobo.Graph(
        bonobo.FileReader('datasets/passwd.txt'),
        skip_comments,
        *_limit,
        lambda s: s.split(':')[0],
        *_print,
        bonobo.FileWriter('usernames.txt', fs='fs.output'),
    )
示例#2
0
def get_graph(*, _limit=(), _print=()):
    return bonobo.Graph(
        bonobo.FileReader("passwd.txt", fs="fs.static"),
        skip_comments,
        *_limit,
        lambda s: s.split(":")[0],
        *_print,
        bonobo.FileWriter("usernames.txt", fs="fs.output"),
    )
示例#3
0
def get_cs_graph(**options):
    """
    This function builds the graph that needs to be executed.

    :return: bonobo.Graph

    """
    graph = bonobo.Graph()

    split_employees = bonobo.noop

    graph.add_chain(bonobo.FileReader(path='HrExport.txt',
                                      fs='centerstone',
                                      encoding='latin-1',
                                      eol="\r\n"),
                    split_tabs,
                    prefix_desk_ids,
                    join_wpr,
                    mismatch,
                    split_employees,
                    _name="main")

    # Process regular employees
    if options['dry_run']:
        update = ()
    else:
        update = (update_employee_record, )

    graph.add_chain(bonobo.PrettyPrinter(),
                    *update,
                    bonobo.PrettyPrinter(),
                    _input=split_employees)

    # Dump out outlier employees
    #graph.add_chain(
    #    bonobo.Filter(filter=odd_employee),
    #    bonobo.UnpackItems(0),
    #    bonobo.PrettyPrinter(),
    #    _input=split_employees)
    #
    return graph
示例#4
0
import bonobo


def split_one(line):
    return line.split(', ', 1)


graph = bonobo.Graph(
    bonobo.FileReader('coffeeshops.txt'),
    split_one,
    bonobo.JsonWriter('coffeeshops.json'),
)

if __name__ == '__main__':
    bonobo.run(graph, services={'fs': bonobo.open_examples_fs('datasets')})
示例#5
0
import bonobo
from bonobo.commands.run import get_default_services


def skip_comments(line):
    if not line.startswith('#'):
        yield line


graph = bonobo.Graph(
    bonobo.FileReader('datasets/passwd.txt'),
    skip_comments,
    lambda s: s.split(':'),
    lambda l: l[0],
    print,
)

if __name__ == '__main__':
    bonobo.run(graph, services=get_default_services(__file__))
示例#6
0
import os
import pathlib

import bonobo

workdir = pathlib.Path(os.path.dirname(__file__))

graph = bonobo.Graph(
    bonobo.FileReader(path=workdir.joinpath('datasets/coffeeshops.txt')),
    print,
)

if __name__ == '__main__':
    bonobo.run(graph)