MCPcopy Index your code
hub / github.com/ray-project/ray / _unwrap_protocol

Function _unwrap_protocol

python/ray/data/datasource/path_util.py:435–466  ·  view source on GitHub ↗

Slice off any protocol prefixes on path.

(path)

Source from the content-addressed store, hash-verified

433
434
435def _unwrap_protocol(path):
436 """
437 Slice off any protocol prefixes on path.
438 """
439 if sys.platform == "win32" and _is_local_windows_path(path):
440 # Represent as posix path such that downstream functions properly handle it.
441 # This is executed when 'file://' is NOT included in the path.
442 return pathlib.Path(path).as_posix()
443
444 parsed = urlparse(path, allow_fragments=False) # support '#' in path
445 params = ";" + parsed.params if parsed.params else "" # support ';' in path
446 query = "?" + parsed.query if parsed.query else "" # support '?' in path
447 netloc = parsed.netloc
448 if parsed.scheme == "s3" and "@" in parsed.netloc:
449 # If the path contains an @, it is assumed to be an anonymous
450 # credentialed path, and we need to strip off the credentials.
451 netloc = parsed.netloc.split("@")[-1]
452
453 parsed_path = parsed.path
454 # urlparse prepends the path with a '/'. This does not work on Windows
455 # so if this is the case strip the leading slash.
456 if (
457 sys.platform == "win32"
458 and not netloc
459 and len(parsed_path) >= 3
460 and parsed_path[0] == "/" # The problematic leading slash
461 and parsed_path[1].isalpha() # Ensure it is a drive letter.
462 and parsed_path[2:4] in (":", ":/")
463 ):
464 parsed_path = parsed_path[1:]
465
466 return netloc + parsed_path + params + query
467
468
469def _is_http_url(path) -> bool:

Calls 2

_is_local_windows_pathFunction · 0.85
splitMethod · 0.45

Used in the wild real call sites across dependent graphs

searching dependent graphs…