code: def path_to_URL(path, escape=True):
      
      # We do not use urllib's builtin pathname2url() function since:
      #  - it has been commented with 'not recommended for general use'
      #  - it does not seem to work the same on Windows and non-Windows platforms
      #    (result starts with /// on Windows but does not on others)
      #  - urllib implementation prior to Python 2.5 used to quote ':' characters
      #    as '|' which would confuse pip on Windows.
      url = os.path.abspath(path)
      for sep in (os.sep, os.altsep):
          if sep and sep != "/":
              url = url.replace(sep, "/")
      if escape:
          # Must not escape ':' or '/' or Python will not recognize those URLs
          # correctly. Detected on Windows 7 SP1 x64 with Python 3.4.0, but doing
          # this always does not hurt since both are valid ASCII characters.
          no_protocol_URL = url_quote(url, safe=":/")
      else:
          no_protocol_URL = url
      return "file:///%s" % (no_protocol_URL,)
docs: Convert a local file path to a absolute path file protocol URL.