Skip to content

Commit 026d0d1

Browse files
committed
Support Python 3 in couchdb-dump script (fixes djc#296)
1 parent 65da210 commit 026d0d1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

couchdb/tools/dump.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
file.
1212
"""
1313

14+
from __future__ import print_function
1415
from base64 import b64decode
1516
from optparse import OptionParser
1617
import sys
@@ -25,7 +26,7 @@
2526
def dump_docs(envelope, db, docs):
2627
for doc in docs:
2728

28-
print >> sys.stderr, 'Dumping document %r' % doc.id
29+
print('Dumping document %r' % doc.id, file=sys.stderr)
2930
attachments = doc.pop('_attachments', {})
3031
jsondoc = json.encode(doc)
3132

@@ -57,7 +58,10 @@ def dump_docs(envelope, db, docs):
5758
})
5859

5960
def dump_db(dburl, username=None, password=None, boundary=None,
60-
output=sys.stdout, bulk_size=BULK_SIZE):
61+
output=None, bulk_size=BULK_SIZE):
62+
63+
if output is None:
64+
output = sys.stdout if sys.version_info[0] < 3 else sys.stdout.buffer
6165

6266
db = Database(dburl)
6367
if username is not None and password is not None:

0 commit comments

Comments
 (0)