@@ -152,11 +152,16 @@ def resolve_alias(cloudpath:str) -> Tuple[Optional[str],str]:
152
152
## Other Path Library Functions
153
153
154
154
def normalize (path ):
155
- proto = get_protocol (path )
155
+ fmt , proto , endpoint , cloudpath , alias = extract_format_protocol (
156
+ path , allow_defaults = False
157
+ )
158
+
156
159
if proto is None :
157
160
proto = "file"
158
- path = toabs (path )
159
- return f"file://{ path } "
161
+ cloudpath = toabs (cloudpath )
162
+ fmt = f"{ fmt } ://" if fmt else ""
163
+ path = f"{ fmt } { proto } ://{ cloudpath } "
164
+
160
165
return path
161
166
162
167
def dirname (path ):
@@ -269,7 +274,7 @@ def pop_protocol(cloudpath):
269
274
270
275
return (protocol , cloudpath )
271
276
272
- def extract_format_protocol (cloudpath :str ) -> tuple :
277
+ def extract_format_protocol (cloudpath :str , allow_defaults = True ) -> tuple :
273
278
error = UnsupportedProtocolError (cloudpath_error (cloudpath ))
274
279
275
280
alias , cloudpath = resolve_alias (cloudpath )
@@ -281,7 +286,9 @@ def extract_format_protocol(cloudpath:str) -> tuple:
281
286
groups = m .groups ()
282
287
cloudpath = re .sub (CLOUDPATH_REGEXP , '' , cloudpath , count = 1 )
283
288
284
- fmt = m .group ('fmt' ) or 'precomputed'
289
+ fmt = m .group ('fmt' )
290
+ if not fmt and allow_defaults :
291
+ fmt = 'precomputed'
285
292
proto = m .group ('proto' )
286
293
endpoint = None
287
294
0 commit comments