tessl install tessl/pypi-w3lib@2.3.0Library of web-related functions for HTML manipulation, HTTP processing, URL handling, and encoding detection
Agent Success
Agent success rate when using this tile
84%
Improvement
Agent success rate improvement when using this tile compared to baseline
0.91x
Baseline
Agent success rate without this tile
92%
Build a utility that converts between filesystem paths and file URIs, with intelligent detection of input format.
/home/user/documents/file.txt, convert it to a file URI file:///home/user/documents/file.txt @testC:\Users\Documents\file.txt, convert it to a file URI with proper encoding @testfile:///home/user/documents/file.txt, convert it back to the filesystem path /home/user/documents/file.txt @testfile:///home/user/my%20document.txt, convert it to the decoded path /home/user/my document.txt @test/home/user/file.txt, detect it's a path and convert to file URI @testfile:///home/user/file.txt, detect it's already a URI and return the corresponding path @testhttp://example.com/file, detect it's not a file path or file URI and raise an appropriate error @test@generates
def path_to_file_uri(path: str) -> str:
"""
Convert a filesystem path to a file:// URI.
Args:
path: The filesystem path to convert
Returns:
A file:// URI string
"""
pass
def file_uri_to_path(uri: str) -> str:
"""
Convert a file:// URI to a filesystem path.
Args:
uri: The file:// URI to convert
Returns:
A filesystem path string
"""
pass
def smart_convert(uri_or_path: str) -> str:
"""
Intelligently detect whether input is a path or URI and convert appropriately.
If input is a path, convert to URI. If input is a file URI, convert to path.
Args:
uri_or_path: Either a filesystem path or a file:// URI
Returns:
The converted string (URI if given path, path if given URI)
Raises:
ValueError: If input is not a filesystem path or file:// URI
"""
passProvides web-related utility functions for URL and path handling.
@satisfied-by