Skip to content

Commit 145dc9b

Browse files
committed
Get replicate script working on Python 3
1 parent a6834bf commit 145dc9b

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

couchdb/tools/replicate.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import optparse
2222
import sys
2323
import time
24-
import urlparse
2524
import fnmatch
2625

2726
def findpath(parser, s):
@@ -32,7 +31,7 @@ def findpath(parser, s):
3231
if not s.startswith('http'):
3332
return client.DEFAULT_BASE_URL, s
3433

35-
bits = urlparse.urlparse(s)
34+
bits = util.urlparse(s)
3635
res = http.Resource('%s://%s/' % (bits.scheme, bits.netloc), None)
3736
parts = bits.path.split('/')[1:]
3837
if parts and not parts[-1]:
@@ -98,25 +97,25 @@ def main():
9897
for sdb, tdb in databases:
9998

10099
start = time.time()
101-
print sdb, '->', tdb,
100+
print(sdb, '->', tdb)
102101
sys.stdout.flush()
103102

104103
if tdb not in target:
105104
target.create(tdb)
106-
print "created",
105+
sys.stdout.write("created")
107106
sys.stdout.flush()
108107

109108
sdb = '%s%s' % (sbase, util.urlquote(sdb, ''))
110109
if options.continuous:
111110
target.replicate(sdb, tdb, continuous=options.continuous)
112111
else:
113112
target.replicate(sdb, tdb)
114-
print '%.1fs' % (time.time() - start)
113+
print('%.1fs' % (time.time() - start))
115114
sys.stdout.flush()
116115

117116
if options.compact:
118117
for (sdb, tdb) in databases:
119-
print 'compact', tdb
118+
print('compact', tdb)
120119
target[tdb].compact()
121120

122121
if __name__ == '__main__':

couchdb/util2.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
__all__ = [
33
'StringIO', 'urlsplit', 'urlunsplit', 'urlquote', 'urlunquote',
44
'urlencode', 'utype', 'ltype', 'pyexec', 'strbase', 'funcode',
5+
'urlparse',
56
]
67

78
utype = unicode
89
ltype = long
910
strbase = str, bytes, unicode
1011

1112
from io import BytesIO as StringIO
12-
from urlparse import urlsplit, urlunsplit
13+
from urlparse import urlparse, urlsplit, urlunsplit
1314
from urllib import quote as urlquote
1415
from urllib import unquote as urlunquote
1516
from urllib import urlencode

couchdb/util3.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
__all__ = [
33
'StringIO', 'urlsplit', 'urlunsplit', 'urlquote', 'urlunquote',
44
'urlencode', 'utype', 'ltype', 'pyexec', 'strbase', 'funcode',
5+
'urlparse',
56
]
67

78
utype = str
89
ltype = int
910
strbase = str, bytes
1011

1112
from io import BytesIO as StringIO
12-
from urllib.parse import urlsplit, urlunsplit, urlencode
13+
from urllib.parse import urlsplit, urlunsplit, urlencode, urlparse
1314
from urllib.parse import quote as urlquote
1415
from urllib.parse import unquote as urlunquote
1516

0 commit comments

Comments
 (0)