Skip to content

Commit aa08ce0

Browse files
committed
MOAR refactor
1 parent ece3617 commit aa08ce0

4 files changed

Lines changed: 6 additions & 5 deletions

File tree

File renamed without changes.
File renamed without changes.

Lib/profiling/sampling/flamegraph_template.html renamed to Lib/profiling/sampling/_flamegraph_assets/flamegraph_template.html

File renamed without changes.

Lib/profiling/sampling/stack_collector.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -332,19 +332,20 @@ def _create_flamegraph_html(self, data):
332332
"""
333333
data_json = json.dumps(data)
334334
template_dir = importlib.resources.files(__package__)
335+
flamegraph_assets_dir = template_dir / "_flamegraph_assets"
335336

336337
# Load base template and assets
337-
html_template = (template_dir / "flamegraph_template.html").read_text(encoding="utf-8")
338-
html_template = self._inline_first_party_assets(html_template, template_dir)
338+
html_template = (flamegraph_assets_dir / "flamegraph_template.html").read_text(encoding="utf-8")
339+
html_template = self._inline_first_party_assets(html_template, flamegraph_assets_dir)
339340
html_template = self._inline_vendor_assets(html_template, template_dir)
340341
html_template = self._inline_logo(html_template, template_dir)
341342

342343
# Replace data placeholder
343344
return html_template.replace("{{FLAMEGRAPH_DATA}}", data_json)
344345

345-
def _inline_first_party_assets(self, html_template, template_dir):
346-
css_content = (template_dir / "flamegraph.css").read_text(encoding="utf-8")
347-
js_content = (template_dir / "flamegraph.js").read_text(encoding="utf-8")
346+
def _inline_first_party_assets(self, html_template, flamegraph_assets_dir):
347+
css_content = (flamegraph_assets_dir / "flamegraph.css").read_text(encoding="utf-8")
348+
js_content = (flamegraph_assets_dir / "flamegraph.js").read_text(encoding="utf-8")
348349

349350
html_template = html_template.replace(
350351
"<!-- INLINE_CSS -->", f"<style>\n{css_content}\n</style>"

0 commit comments

Comments
 (0)