From 9026c4c42a1fc0f4ec376add6af2a7c05ec126e9 Mon Sep 17 00:00:00 2001 From: Michael Merickel Date: Tue, 6 Feb 2024 22:16:11 -0700 Subject: [PATCH] use AssetResolver internally --- src/pyramid/asset.py | 8 ++------ src/pyramid/static.py | 8 ++++---- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/pyramid/asset.py b/src/pyramid/asset.py index bdf90ef5e..cba6e5b9a 100644 --- a/src/pyramid/asset.py +++ b/src/pyramid/asset.py @@ -1,7 +1,6 @@ import os -import pkg_resources -from pyramid.path import package_name, package_path +from pyramid.path import AssetResolver, package_name, package_path def resolve_asset_spec(spec, pname='__main__'): @@ -37,7 +36,4 @@ def asset_spec_from_abspath(abspath, package): def abspath_from_asset_spec(spec, pname='__main__'): if pname is None: return spec - pname, filename = resolve_asset_spec(spec, pname) - if pname is None: - return filename - return pkg_resources.resource_filename(pname, filename) + return AssetResolver(pname).resolve(spec).abspath() diff --git a/src/pyramid/static.py b/src/pyramid/static.py index 100d17676..403143aa8 100644 --- a/src/pyramid/static.py +++ b/src/pyramid/static.py @@ -5,9 +5,9 @@ from os.path import exists, getmtime, getsize, isdir, join, normcase, normpath from pkg_resources import resource_exists, resource_filename, resource_isdir -from pyramid.asset import abspath_from_asset_spec, resolve_asset_spec +from pyramid.asset import resolve_asset_spec from pyramid.httpexceptions import HTTPMovedPermanently, HTTPNotFound -from pyramid.path import caller_package +from pyramid.path import AssetResolver, caller_package from pyramid.response import FileResponse, _guess_type from pyramid.traversal import traversal_path_info @@ -381,8 +381,8 @@ class ManifestCacheBuster: def __init__(self, manifest_spec, reload=False): package_name = caller_package().__name__ - self.manifest_path = abspath_from_asset_spec( - manifest_spec, package_name + self.manifest_path = ( + AssetResolver(package_name).resolve(manifest_spec).abspath() ) self.reload = reload