Skip to content

Commit

Permalink
use AssetResolver internally
Browse files Browse the repository at this point in the history
  • Loading branch information
mmerickel committed Feb 7, 2024
1 parent 151ebdc commit 9026c4c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
8 changes: 2 additions & 6 deletions src/pyramid/asset.py
Original file line number Diff line number Diff line change
@@ -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__'):
Expand Down Expand Up @@ -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()
8 changes: 4 additions & 4 deletions src/pyramid/static.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 9026c4c

Please sign in to comment.