本文整理汇总了Python中w3lib.url.path_to_file_uri函数的典型用法代码示例。如果您正苦于以下问题:Python path_to_file_uri函数的具体用法?Python path_to_file_uri怎么用?Python path_to_file_uri使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了path_to_file_uri函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_path_to_file_uri
def test_path_to_file_uri(self):
if os.name == 'nt':
self.assertEqual(path_to_file_uri("C:\\windows\clock.avi"),
"file:///C:/windows/clock.avi")
else:
self.assertEqual(path_to_file_uri("/some/path.txt"),
"file:///some/path.txt")
fn = "test.txt"
x = path_to_file_uri(fn)
self.assert_(x.startswith('file:///'))
self.assertEqual(file_uri_to_path(x).lower(), os.path.abspath(fn).lower())
开发者ID:codecov-test,项目名称:w3lib,代码行数:12,代码来源:test_url.py
示例2: test_download
def test_download(self):
def _test(response):
self.assertEquals(response.url, request.url)
self.assertEquals(response.status, 200)
self.assertEquals(response.body, "0123456789")
request = Request(path_to_file_uri(self.tmpname + "^"))
assert request.url.upper().endswith("%5E")
return self.download_request(request, Spider("foo")).addCallback(_test)
开发者ID:AugustLONG,项目名称:scrapy,代码行数:9,代码来源:test_downloader_handlers.py
示例3: test_download
def test_download(self):
def _test(response):
self.assertEqual(response.url, request.url)
self.assertEqual(response.status, 200)
self.assertEqual(response.body, b'0123456789')
request = Request(path_to_file_uri(self.tmpname + '^'))
assert request.url.upper().endswith('%5E')
return self.download_request(request, Spider('foo')).addCallback(_test)
开发者ID:elacuesta,项目名称:scrapy,代码行数:9,代码来源:test_downloader_handlers.py
示例4: test_file_uri_to_path
def test_file_uri_to_path(self):
if os.name == 'nt':
self.assertEqual(file_uri_to_path("file:///C:/windows/clock.avi"),
"C:\\windows\clock.avi")
uri = "file:///C:/windows/clock.avi"
uri2 = path_to_file_uri(file_uri_to_path(uri))
self.assertEqual(uri, uri2)
else:
self.assertEqual(file_uri_to_path("file:///path/to/test.txt"),
"/path/to/test.txt")
self.assertEqual(file_uri_to_path("/path/to/test.txt"),
"/path/to/test.txt")
uri = "file:///path/to/test.txt"
uri2 = path_to_file_uri(file_uri_to_path(uri))
self.assertEqual(uri, uri2)
self.assertEqual(file_uri_to_path("test.txt"),
"test.txt")
开发者ID:codecov-test,项目名称:w3lib,代码行数:18,代码来源:test_url.py
示例5: _get_feed_uri
def _get_feed_uri(self, message, ext):
url = urlparse(self.items_dir)
if url.scheme.lower() in ['', 'file']:
return path_to_file_uri(self._get_file(message, url.path, ext))
return urlunparse((url.scheme,
url.netloc,
'/'.join([url.path,
message['_project'],
message['_spider'],
'%s.%s' % (message['_job'], ext)]),
url.params,
url.query,
url.fragment))
开发者ID:mnjstwins,项目名称:scrapyd,代码行数:13,代码来源:environ.py
示例6: test_store_file_uri_makedirs
def test_store_file_uri_makedirs(self):
path = os.path.abspath(self.mktemp())
path = os.path.join(path, 'more', 'paths', 'file.txt')
uri = path_to_file_uri(path)
return self._assert_stores(FileFeedStorage(uri), path)
开发者ID:CPoirot3,项目名称:scrapy,代码行数:5,代码来源:test_feedexport.py
示例7: test_store_file_uri
def test_store_file_uri(self):
path = os.path.abspath(self.mktemp())
uri = path_to_file_uri(path)
return self._assert_stores(FileFeedStorage(uri), path)
开发者ID:CPoirot3,项目名称:scrapy,代码行数:4,代码来源:test_feedexport.py
注:本文中的w3lib.url.path_to_file_uri函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论