From 832cae47693b4c07a1fa826dce13b9af7a91ebaf Mon Sep 17 00:00:00 2001 From: Theron Luhn Date: Sun, 24 Aug 2025 21:35:04 -0700 Subject: Add `get_spec` to asset sources. --- src/pyramid/config/assets.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/pyramid/config/assets.py b/src/pyramid/config/assets.py index 6f2ddbe4a..2838db1e5 100644 --- a/src/pyramid/config/assets.py +++ b/src/pyramid/config/assets.py @@ -223,6 +223,11 @@ class PackageAssetSource: def get_path(self, resource_name): return f'{self.prefix}{resource_name}' + def get_spec(self, resource_name): + path = self.get_path(resource_name) + if pkg_resources.resource_exists(self.pkg_name, path): + return f'{self.pkg_name}:{path}' + def get_filename(self, resource_name): path = self.get_path(resource_name) if pkg_resources.resource_exists(self.pkg_name, path): @@ -270,6 +275,9 @@ class FSAssetSource: path = self.prefix return path + def get_spec(self, resource_name): + return self.get_filename(resource_name) + def get_filename(self, resource_name): path = self.get_path(resource_name) if os.path.exists(path): -- cgit v1.2.3