MCPcopy Index your code
hub / github.com/RustPython/RustPython / as_uri

Method as_uri

Lib/pathlib/__init__.py:528–551  ·  view source on GitHub ↗

Return the path as a URI.

(self)

Source from the content-addressed store, hash-verified

526 return False
527
528 def as_uri(self):
529 """Return the path as a URI."""
530 import warnings
531 msg = ("pathlib.PurePath.as_uri() is deprecated and scheduled "
532 "for removal in Python 3.19. Use pathlib.Path.as_uri().")
533 warnings._deprecated("pathlib.PurePath.as_uri", msg, remove=(3, 19))
534 if not self.is_absolute():
535 raise ValueError("relative path can't be expressed as a file URI")
536
537 drive = self.drive
538 if len(drive) == 2 and drive[1] == ':':
539 # It's a path on a local drive => 'file:///c:/a/b'
540 prefix = 'file:///' + drive
541 path = self.as_posix()[2:]
542 elif drive:
543 # It's a path on a network drive => 'file://host/share/a/b'
544 prefix = 'file:'
545 path = self.as_posix()
546 else:
547 # It's a posix path => 'file:///etc/hosts'
548 prefix = 'file://'
549 path = str(self)
550 from urllib.parse import quote_from_bytes
551 return prefix + quote_from_bytes(os.fsencode(path))
552
553 def full_match(self, pattern, *, case_sensitive=None):
554 """

Callers

nothing calls this directly

Calls 6

is_absoluteMethod · 0.95
as_posixMethod · 0.95
quote_from_bytesFunction · 0.90
lenFunction · 0.85
strFunction · 0.85
fsencodeMethod · 0.80

Tested by

no test coverage detected