Coverage for src/lightmlboard/static/__init__.py: 93%
14 statements
« prev ^ index » next coverage.py v6.4.1, created at 2022-06-05 11:12 +0200
« prev ^ index » next coverage.py v6.4.1, created at 2022-06-05 11:12 +0200
1"""
2@file
3@brief Helpers around static files.
4"""
5import os
6import shutil
9def copy_static(dest):
10 """
11 Copy static files into *dest/static*.
12 """
13 dst = os.path.join(dest, "static")
14 if not os.path.exists(dst):
15 os.mkdir(dst)
16 this = os.path.dirname(__file__)
17 copied = 0
18 for name in os.listdir(this):
19 if os.path.splitext(name)[-1] in {'.png', '.ico', '.css', '.js'}:
20 shutil.copy(os.path.join(this, name), dst)
21 copied += 1
22 if copied == 0:
23 raise ValueError("No file found in '{0}'.".format(this))