88import requests
99from datetime import datetime
1010import re
11- try :
12- from urllib .parse import urlparse
13- except ImportError :
14- from urlparse import urlparse
11+ from urllib .parse import urlparse
1512
1613from ckanapi .errors import (NotFound , NotAuthorized , ValidationError ,
1714 SearchIndexError )
1815from ckanapi .cli import workers
1916from ckanapi .cli .utils import completion_stats , compact_json , quiet_int_pipe
2017
21- try :
22- unicode
23- except NameError :
24- unicode = str
25-
2618
2719def load_things (ckan , thing , arguments ,
2820 worker_pool = None , stdin = None , stdout = None , stderr = None ):
@@ -167,7 +159,7 @@ def reply(action, error, response):
167159 obj = json .loads (line .decode ('utf-8' ))
168160 except UnicodeDecodeError as e :
169161 obj = None
170- reply ('read' , 'UnicodeDecodeError' , unicode (e ))
162+ reply ('read' , 'UnicodeDecodeError' , str (e ))
171163 continue
172164
173165 requests_kwargs = None
@@ -191,7 +183,7 @@ def reply(action, error, response):
191183 except NotFound :
192184 pass
193185 except NotAuthorized as e :
194- reply ('show' , 'NotAuthorized' , unicode (e ))
186+ reply ('show' , 'NotAuthorized' , str (e ))
195187 continue
196188 name = obj .get ('name' )
197189 if not existing and name :
@@ -201,7 +193,7 @@ def reply(action, error, response):
201193 except NotFound :
202194 pass
203195 except NotAuthorized as e :
204- reply ('show' , 'NotAuthorized' , unicode (e ))
196+ reply ('show' , 'NotAuthorized' , str (e ))
205197 continue
206198
207199 if existing :
@@ -233,9 +225,9 @@ def reply(action, error, response):
233225 except ValidationError as e :
234226 reply (act , 'ValidationError' , e .error_dict )
235227 except SearchIndexError as e :
236- reply (act , 'SearchIndexError' , unicode (e ))
228+ reply (act , 'SearchIndexError' , str (e ))
237229 except NotAuthorized as e :
238- reply (act , 'NotAuthorized' , unicode (e ))
230+ reply (act , 'NotAuthorized' , str (e ))
239231 except NotFound :
240232 reply (act , 'NotFound' , obj )
241233 else :
0 commit comments