File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change 10
10
import copy
11
11
import pprint
12
12
from StringIO import StringIO
13
- import pathlib2 as pathlib
13
+ try :
14
+ # python 3
15
+ import pathlib
16
+ except :
17
+ # python 2
18
+ import pathlib2 as pathlib
14
19
15
20
from . import validate
16
21
from .aslist import aslist
@@ -110,7 +115,7 @@ def fetch_text(self, url):
110
115
return resp .text
111
116
elif scheme == 'file' :
112
117
try :
113
- with open (urllib .url2pathname (urlparse .urlparse (url ).path )) as fp :
118
+ with open (urllib .url2pathname (str ( urlparse .urlparse (url ).path ) )) as fp :
114
119
read = fp .read ()
115
120
if hasattr (read , "decode" ):
116
121
return read .decode ("utf-8" )
@@ -139,7 +144,7 @@ def check_exists(self, url): # type: (unicode) -> bool
139
144
return False
140
145
return True
141
146
elif scheme == 'file' :
142
- return os .path .exists (urllib .url2pathname (urlparse .urlparse (url ).path ))
147
+ return os .path .exists (urllib .url2pathname (str ( urlparse .urlparse (url ).path ) ))
143
148
else :
144
149
raise ValueError ('Unsupported scheme in url: %s' % url )
145
150
You can’t perform that action at this time.
0 commit comments