本文整理汇总了Python中six.moves.urllib.request.url2pathname方法的典型用法代码示例。如果您正苦于以下问题:Python request.url2pathname方法的具体用法?Python request.url2pathname怎么用?Python request.url2pathname使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类six.moves.urllib.request
的用法示例。
在下文中一共展示了request.url2pathname方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: url_to_path
# 需要导入模块: from six.moves.urllib import request [as 别名]
# 或者: from six.moves.urllib.request import url2pathname [as 别名]
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)
示例2: mapper
# 需要导入模块: from six.moves.urllib import request [as 别名]
# 或者: from six.moves.urllib.request import url2pathname [as 别名]
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)
示例3: file_uri_to_path
# 需要导入模块: from six.moves.urllib import request [as 别名]
# 或者: from six.moves.urllib.request import url2pathname [as 别名]
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)
示例4: _create_run_in_store
# 需要导入模块: from six.moves.urllib import request [as 别名]
# 或者: from six.moves.urllib.request import url2pathname [as 别名]
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