27
27
def url_join (path , path2 ):
28
28
result = urlparse (path )
29
29
if result .scheme and path .endswith (result .scheme ):
30
- return path + to_unicode ( "!/" ) + path2
30
+ return f" { path } !/ { path2 } "
31
31
else :
32
- return path + to_unicode ( "/" ) + path2
32
+ return f" { path } / { path2 } "
33
33
34
34
35
35
def log_fs_failure (function_in_this_module ):
@@ -53,7 +53,6 @@ def wrapper(*args, **kwds):
53
53
@log_fs_failure
54
54
@contextmanager
55
55
def open_fs (path ):
56
- path = to_unicode (path )
57
56
if is_zip_alike_url (path ):
58
57
zip_file , folder = url_split (path )
59
58
the_fs = fs .open_fs (zip_file )
@@ -68,7 +67,6 @@ def open_fs(path):
68
67
@log_fs_failure
69
68
@contextmanager
70
69
def open_file (path ):
71
- path = to_unicode (path )
72
70
if is_zip_alike_url (path ):
73
71
zip_file , folder = url_split (path )
74
72
the_fs = fs .open_fs (zip_file )
@@ -88,7 +86,6 @@ def open_file(path):
88
86
@log_fs_failure
89
87
@contextmanager
90
88
def open_binary_file (path ):
91
- path = to_unicode (path )
92
89
if is_zip_alike_url (path ):
93
90
zip_file , folder = url_split (path )
94
91
the_fs = fs .open_fs (zip_file )
@@ -123,7 +120,6 @@ def read_bytes(path):
123
120
124
121
@log_fs_failure
125
122
def write_bytes (filename , bytes_content ):
126
- filename = to_unicode (filename )
127
123
if "://" in filename :
128
124
zip_file , folder = url_split (filename )
129
125
with fs .open_fs (zip_file , create = True ) as the_fs :
@@ -150,8 +146,6 @@ def is_file(path):
150
146
151
147
152
148
def exists (path ):
153
- path = to_unicode (path )
154
-
155
149
if is_zip_alike_url (path ):
156
150
zip_file , folder = url_split (path )
157
151
try :
@@ -179,7 +173,6 @@ def exists(path):
179
173
180
174
@log_fs_failure
181
175
def list_dir (path ):
182
- path = to_unicode (path )
183
176
folder_or_file , path = _path_split (path )
184
177
with fs .open_fs (folder_or_file ) as the_fs :
185
178
for file_name in the_fs .listdir (path ):
@@ -188,31 +181,26 @@ def list_dir(path):
188
181
189
182
@log_fs_failure
190
183
def abspath (path ):
191
- path = to_unicode (path )
192
184
folder_or_file , path = _path_split (path )
193
185
with fs .open_fs (folder_or_file ) as the_fs :
194
186
return the_fs .getsyspath (path )
195
187
196
188
197
189
@log_fs_failure
198
190
def fs_url (path ):
199
- path = to_unicode (path )
200
191
folder_or_file , path = _path_split (path )
201
192
with fs .open_fs (folder_or_file ) as the_fs :
202
193
return the_fs .geturl (path , purpose = "fs" )
203
194
204
195
205
196
@log_fs_failure
206
197
def system_path (path ):
207
- path = to_unicode (path )
208
198
folder_or_file , path = _path_split (path )
209
199
with fs .open_fs (folder_or_file ) as the_fs :
210
200
return the_fs .getsyspath (path )
211
201
212
202
213
203
def to_unicode (path ):
214
- if PY2 and path .__class__ .__name__ != "unicode" :
215
- return u"" .__class__ (path )
216
204
return path
217
205
218
206
@@ -258,7 +246,6 @@ def url_split(url):
258
246
259
247
260
248
def _path_split (url_or_path ):
261
- url_or_path = to_unicode (url_or_path )
262
249
if is_zip_alike_url (url_or_path ):
263
250
return url_split (url_or_path )
264
251
else :
0 commit comments