Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API use of pkg_resources is deprecated #83

Closed
philippkraft opened this issue Jun 19, 2024 · 0 comments
Closed

API use of pkg_resources is deprecated #83

philippkraft opened this issue Jun 19, 2024 · 0 comments

Comments

@philippkraft
Copy link

philippkraft commented Jun 19, 2024

The PackageLoader uses pkg_resources from setuptools, which is deprecated since last year. Is there another way to get the templates from a package? I do not use the package loader, so it is difficult for me to help here. Or are .eggs deprecated at all and support can be dropped?

import pkg_resources

kajiki/kajiki/loader.py

Lines 119 to 136 in bb2c7c1

class PackageLoader(FileLoader):
def __init__(self, reload=True, force_mode=None):
super().__init__(None, reload, force_mode)
def _filename(self, name):
package, module = name.rsplit(".", 1)
found = dict()
for fn in pkg_resources.resource_listdir(package, "."):
if fn == name:
return pkg_resources.resource_filename(package, fn)
root, ext = os.path.splitext(fn)
if root == module:
found[ext] = fn
for ext in (".xml", ".html", ".html5", ".txt"):
if ext in found:
return pkg_resources.resource_filename(package, found[ext])
else:
raise IOError("Unknown template %r" % name)

BTW: Thank you for kajiki, I was nearly starting to rewrite all my templates from Genshi to jinja2 - but then I discovered kajiki and days of work were saved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant