Skip to content

Commit 6fca75c

Browse files
authored
Merge pull request #126 from statisticsnorway/assets
added functionality for having local assets overwrite packageassets, …
2 parents ef9b9d9 + d8ea7bd commit 6fca75c

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "ssb-konjunk"
3-
version = "2.1.3"
3+
version = "2.1.4"
44
description = "SSB Konjunk 422"
55
authors = [
66
{name = "Johanne Saxegaard", email = "jox@ssb.no"},

src/ssb_konjunk/dash/utils.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
_config = None
66

77

8-
def setup(config):
8+
def setup(config) -> None:
99
global _config
1010
_config = config
1111

@@ -55,3 +55,27 @@ def dropdown_getter(file: str | None = None) -> list[dict[str, str]]:
5555
for item in sorted(datas.get_all_periods(), reverse=True)
5656
]
5757
return dropdown_data
58+
59+
60+
@cache
61+
def get_assets_folder() -> str:
62+
"""
63+
Lager en temp mappe som har assets fra pakken og assets lokalt.
64+
65+
lokale assets overskriver pakke assets.
66+
67+
Returns:
68+
str: path til temp mappe med assets.
69+
"""
70+
package_assets = Path(ssb_konjunk.__file__).parent / "dash" / "assets"
71+
local_assets = Path("dash/assets")
72+
73+
combined = Path(tempfile.mkdtemp(prefix="dash_assets_"))
74+
75+
if package_assets.exists():
76+
shutil.copytree(package_assets, combined, dirs_exist_ok=True)
77+
78+
if local_assets.exists():
79+
shutil.copytree(local_assets, combined, dirs_exist_ok=True)
80+
81+
return str(combined)

0 commit comments

Comments
 (0)