예제 #1
0
 def make_uri(self, path):
     drive = path.drive
     if len(drive) == 2 and drive[1] == ':':
         rest = path.as_posix()[2:].lstrip('/')
         return 'file:///%s/%s' % (
             drive, urlquote_from_bytes(rest.encode('utf-8')))
     else:
         return 'file:' + urlquote_from_bytes(
             path.as_posix().encode('utf-8'))
예제 #2
0
 def make_uri(self, path):
     # Under Windows, file URIs use the UTF-8 encoding.
     drive = path.drive
     if len(drive) == 2 and drive[1] == ":":
         # It's a path on a local drive => 'file:///c:/a/b'
         rest = path.as_posix()[2:].lstrip("/")
         return "file:///%s/%s" % (drive, urlquote_from_bytes(rest.encode("utf-8")))
     else:
         # It's a path on a network drive => 'file://host/share/a/b'
         return "file:" + urlquote_from_bytes(path.as_posix().encode("utf-8"))
예제 #3
0
 def make_uri(self, path):
     # Under Windows, file URIs use the UTF-8 encoding.
     drive = path.drive
     if len(drive) == 2 and drive[1] == ':':
         # It's a path on a local drive => 'file:///c:/a/b'
         rest = path.as_posix()[2:].lstrip('/')
         return 'file:///%s/%s' % (
             drive, urlquote_from_bytes(rest.encode('utf-8')))
     else:
         # It's a path on a network drive => 'file://host/share/a/b'
         return 'file:' + urlquote_from_bytes(path.as_posix().encode('utf-8'))
예제 #4
0
    def make_uri(self, path):
        """Return a file URI for the given path"""

        # Under Windows, file URIs use the UTF-8 encoding.
        # original version, not faked
        # todo: make this part dependent on drive support, add encoding as property
        drive = path.drive
        if len(drive) == 2 and drive[1] == ':':
            # It's a path on a local drive => 'file:///c:/a/b'
            rest = path.as_posix()[2:].lstrip('/')
            return 'file:///%s/%s' % (
                drive, urlquote_from_bytes(rest.encode('utf-8')))
        else:
            # It's a path on a network drive => 'file://host/share/a/b'
            return 'file:' + urlquote_from_bytes(path.as_posix().encode('utf-8'))
예제 #5
0
    def make_uri(self, path):
        """Return a file URI for the given path"""

        # Under Windows, file URIs use the UTF-8 encoding.
        # original version, not faked
        drive = path.drive
        if len(drive) == 2 and drive[1] == ':':
            # It's a path on a local drive => 'file:///c:/a/b'
            rest = path.as_posix()[2:].lstrip('/')
            return 'file:///%s/%s' % (
                drive, urlquote_from_bytes(rest.encode('utf-8')))
        else:
            # It's a path on a network drive => 'file://host/share/a/b'
            return ('file:' +
                    urlquote_from_bytes(path.as_posix().encode('utf-8')))
예제 #6
0
 def make_uri(self, path):
     # We represent the path using the local filesystem encoding,
     # for portability to other applications.
     bpath = bytes(path)
     return 'file://' + urlquote_from_bytes(bpath)
예제 #7
0
파일: pathlib.py 프로젝트: python/cpython
 def make_uri(self, path):
     # We represent the path using the local filesystem encoding,
     # for portability to other applications.
     bpath = bytes(path)
     return 'file://' + urlquote_from_bytes(bpath)
예제 #8
0
 def make_uri(self, path: "S3Path"):
     path_noschema: str = str(path)[len("s3://"):]  # Need to chop-off s3://
     bpath: bytes = path_noschema.encode("utf-8")
     return "s3://" + urlquote_from_bytes(bpath)  # type: ignore
예제 #9
0
 def make_uri(self, path):
     bpath = bytes(path)
     return 'file://' + urlquote_from_bytes(bpath)