From 9c5e98b18bdbec8443b325908cfaa4675d1d26b8 Mon Sep 17 00:00:00 2001 From: Peter Uebele Date: Sat, 28 Oct 2017 11:33:16 +0200 Subject: [PATCH] adapt tutorial "Working with files" to the latest develop version --- bonobo/examples/tutorials/tut02e02_write.py | 4 ++-- bonobo/examples/tutorials/tut02e03_writeasmap.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bonobo/examples/tutorials/tut02e02_write.py b/bonobo/examples/tutorials/tut02e02_write.py index e5a8445..c4b065d 100644 --- a/bonobo/examples/tutorials/tut02e02_write.py +++ b/bonobo/examples/tutorials/tut02e02_write.py @@ -2,14 +2,14 @@ import bonobo def split_one(line): - return line.split(', ', 1) + return dict(zip(("name", "address"), line.split(', ', 1))) graph = bonobo.Graph( bonobo.FileReader('coffeeshops.txt'), split_one, bonobo.JsonWriter( - 'coffeeshops.json', fs='fs.output', ioformat='arg0' + 'coffeeshops.json', fs='fs.output' ), ) diff --git a/bonobo/examples/tutorials/tut02e03_writeasmap.py b/bonobo/examples/tutorials/tut02e03_writeasmap.py index e234f22..c7c7711 100644 --- a/bonobo/examples/tutorials/tut02e03_writeasmap.py +++ b/bonobo/examples/tutorials/tut02e03_writeasmap.py @@ -11,7 +11,7 @@ def split_one_to_map(line): class MyJsonWriter(bonobo.JsonWriter): prefix, suffix = '{', '}' - def write(self, fs, file, lineno, row): + def write(self, fs, file, lineno, **row): return bonobo.FileWriter.write( self, fs, file, lineno, json.dumps(row)[1:-1] ) @@ -20,7 +20,7 @@ class MyJsonWriter(bonobo.JsonWriter): graph = bonobo.Graph( bonobo.FileReader('coffeeshops.txt'), split_one_to_map, - MyJsonWriter('coffeeshops.json', fs='fs.output', ioformat='arg0'), + MyJsonWriter('coffeeshops.json', fs='fs.output'), )