Python six.moves.urllib.request.url2pathname() Examples
The following are 6
code examples of six.moves.urllib.request.url2pathname().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
six.moves.urllib.request
, or try the search function
.
Example #1
Source File: path.py From pipenv with MIT License | 5 votes |
def url_to_path(url): # type: (str) -> str """Convert a valid file url to a local filesystem path. Follows logic taken from pip's equivalent function """ assert is_file_url(url), "Only file: urls can be converted to local paths" _, netloc, path, _, _ = urllib_parse.urlsplit(url) # Netlocs are UNC paths if netloc: netloc = "\\\\" + netloc path = urllib_request.url2pathname(netloc + path) return urllib_parse.unquote(path)
Example #2
Source File: commoncrawl.py From CommonCrawlJob with Apache License 2.0 | 5 votes |
def mapper(self, key, line): for record in self.read_warc(line.strip()): payload = self.get_payload(record) for value in self.process_record(payload): yield ((url2pathname(record.url), value), 1)
Example #3
Source File: url.py From learn_python3_spider with MIT License | 5 votes |
def file_uri_to_path(uri): """Convert File URI to local filesystem path according to: http://en.wikipedia.org/wiki/File_URI_scheme """ uri_path = urlparse(uri).path return url2pathname(uri_path)
Example #4
Source File: path.py From vistir with ISC License | 5 votes |
def url_to_path(url): # type: (str) -> str """Convert a valid file url to a local filesystem path. Follows logic taken from pip's equivalent function """ assert is_file_url(url), "Only file: urls can be converted to local paths" _, netloc, path, _, _ = urllib_parse.urlsplit(url) # Netlocs are UNC paths if netloc: netloc = "\\\\" + netloc path = urllib_request.url2pathname(netloc + path) return urllib_parse.unquote(path)
Example #5
Source File: url.py From Cloudmare with GNU General Public License v3.0 | 5 votes |
def file_uri_to_path(uri): """Convert File URI to local filesystem path according to: http://en.wikipedia.org/wiki/File_URI_scheme """ uri_path = urlparse(uri).path return url2pathname(uri_path)
Example #6
Source File: test_cli.py From mlflow with Apache License 2.0 | 5 votes |
def _create_run_in_store(store): config = { 'experiment_id': '0', 'user_id': 'Anderson', 'start_time': int(time.time()), 'tags': {} } run = store.create_run(**config) artifact_path = url2pathname(unquote(urlparse(run.info.artifact_uri).path)) if not os.path.exists(artifact_path): os.makedirs(artifact_path) return run