def resolve_uri(uri): from pyramid.path import PkgResourcesAssetDescriptor pkg_name, path = uri.split(":", 1) a = PkgResourcesAssetDescriptor(pkg_name, path) absolute = a.abspath() # this is sometimes not absolute :-/ absolute = os.path.abspath(absolute) # so we make it absolute return absolute
def resole_uri(uri): from pyramid.path import PkgResourcesAssetDescriptor pkg_name,path=uri.split(":",1) a = PkgResourcesAssetDescriptor(pkg_name,path) absolute = a.abspath() #this is sometimes not absolute :-/ absolute = os.path.abspath(absolute) #so we make it absolute return absolute
def _hash_asset(self, asset: AssetDescriptor) -> str: hash_ = sha256() with cast(BinaryIO, asset.stream()) as stream: for block in iter(lambda: stream.read(4096), b""): hash_.update(block) return hash_.hexdigest()