Skip to content

Commit

Permalink
Merge pull request #186 from stewartboogert/importlib_resources
Browse files Browse the repository at this point in the history
vis: switch from pkg_resource to importlib_resources
  • Loading branch information
stewartboogert authored Oct 2, 2024
2 parents c746f0d + 4a3783d commit da16f92
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/pyg4ometry/visualisation/ViewerBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,8 @@ def exportThreeJSScene(self, fileNameBase="test", lightBoxHDR="concrete_tunnel_0
open test.html
"""

import pkg_resources
import importlib_resources

from jinja2 import Template

gltfFileName = fileNameBase + ".gltf"
Expand All @@ -613,8 +614,12 @@ def exportThreeJSScene(self, fileNameBase="test", lightBoxHDR="concrete_tunnel_0
"css_file": cssFileName,
}

threeHTMLTemplate = pkg_resources.resource_filename(__name__, "threejs.html")
threeCSSTemplate = pkg_resources.resource_filename(__name__, "threejs.css")
threeHTMLTemplate = importlib_resources.as_file(
importlib_resources.files(__name__) / "threejs.html"
)
threeCSSTemplate = importlib_resources.as_file(
importlib_resources.files(__name__) / "threejs.css"
)

with open(threeHTMLTemplate) as file:
template = Template(file.read())
Expand Down

0 comments on commit da16f92

Please sign in to comment.