Skip to content

Commit

Permalink
vis: switch from pkg_resource to importlib_resources
Browse files Browse the repository at this point in the history
  • Loading branch information
stewartboogert committed Oct 2, 2024
1 parent d2f54c4 commit c52f2ab
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 c52f2ab

Please sign in to comment.