Mercurial > p > roundup > code
diff scripts/import_sf.py @ 5402:88dbacd11cd1
Python 3 preparation: update urllib / urllib2 / urlparse imports.
The existing roundup/anypy/urllib_.py is extended to cover more
imports and used in more places. Manual patch.
| author | Joseph Myers <jsm@polyomino.org.uk> |
|---|---|
| date | Tue, 24 Jul 2018 23:48:30 +0000 |
| parents | 0942fe89e82e |
| children | f004824563a3 |
line wrap: on
line diff
--- a/scripts/import_sf.py Tue Jul 24 23:47:10 2018 +0000 +++ b/scripts/import_sf.py Tue Jul 24 23:48:30 2018 +0000 @@ -21,7 +21,7 @@ And you're done! """ -import sys, os, csv, time, urllib2, httplib, mimetypes, urlparse +import sys, os, csv, time, httplib, mimetypes try: import cElementTree as ElementTree @@ -29,6 +29,7 @@ from elementtree import ElementTree from roundup import instance, hyperdb, date, support, password +from roundup.anypy import urllib_ today = date.Date('.') @@ -46,7 +47,7 @@ # magic "group_id" and "atid" values in it that we need assert response.status == 302, 'response code was %s'%response.status location = response.getheader('location') - query = urlparse.urlparse(response.getheader('location'))[-2] + query = urllib_.urlparse(response.getheader('location'))[-2] info = dict([param.split('=') for param in query.split('&')]) return DL_URL%info @@ -91,7 +92,7 @@ f.write('%s %s\n'%(aid, urls[aid])) f.close() url = urls[aid] + '&file_id=' + fid - f = urllib2.urlopen(url) + f = urllib_.urlopen(url) data = f.read() n = open(os.path.join(file_dir, fid), 'w') n.write(data)
