In WeasyPrint’s public API I accept filenames (among other types) for the HTML inputs. Any filename that works with the built-in open() should work, but I need
open()
Credit to comment from @danodonovan above.
@danodonovan
For Python3, the following code will work:
from urllib.parse import urljoin from urllib.request import pathname2url def path2url(path): return urljoin('file:', pathname2url(path))