Using importlib.resources Package and importlib.readers MultiplexedPath (Traverable) with FileSystemLoader #2002
Unanswered
lfvjimisola
asked this question in
Q&A
Replies: 1 comment
-
It think that this works but it's not nice looking nor pythonic: |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I seem to recall that I saw this issue mentioned somewhere and that there was a neat solution for it, but I've spent half a day googling, checking commits, PRs etc without finding it.
We are upgrading from Python 3.10 to 3.12 and there seems to be an issue now (or perhaps it was triggered by something else).
We used
files(somemodule).joinpath("")
before I think but joinpath with empty string does not work now.FileSystemLoader's searchpath (
searchpath: str | PathLike[str] | Sequence[str | PathLike[str]]
) can't be a MultiplexedPath as it not a str or PathLike.str(MultiplexedPath)
does not return a path as string (as str(Path) does). So, what is best practise here?I could use as_file and with but that it's really bad. I don't think using PackageLoader is an option in a case since we have multiple directories with templates among other things.
Code is something like this:
Beta Was this translation helpful? Give feedback.
All reactions