|
23 | 23 | os = isolate_module(os)
|
24 | 24 |
|
25 | 25 |
|
26 |
| -# Static files are looked for in a list of places. |
27 |
| -STATIC_PATH = [ |
28 |
| - # The place Debian puts system Javascript libraries. |
29 |
| - "/usr/share/javascript", |
30 |
| - |
31 |
| - # Our htmlfiles directory. |
32 |
| - os.path.join(os.path.dirname(__file__), "htmlfiles"), |
33 |
| -] |
34 |
| - |
35 |
| - |
36 |
| -def data_filename(fname, pkgdir=""): |
37 |
| - """Return the path to a data file of ours. |
38 |
| -
|
39 |
| - The file is searched for on `STATIC_PATH`, and the first place it's found, |
40 |
| - is returned. |
41 |
| -
|
42 |
| - Each directory in `STATIC_PATH` is searched as-is, and also, if `pkgdir` |
43 |
| - is provided, at that sub-directory. |
44 |
| -
|
| 26 | +def data_filename(fname): |
| 27 | + """Return the path to an "htmlfiles" data file of ours. |
45 | 28 | """
|
46 |
| - tried = [] |
47 |
| - for static_dir in STATIC_PATH: |
48 |
| - static_filename = os.path.join(static_dir, fname) |
49 |
| - if os.path.exists(static_filename): |
50 |
| - return static_filename |
51 |
| - else: |
52 |
| - tried.append(static_filename) |
53 |
| - if pkgdir: |
54 |
| - static_filename = os.path.join(static_dir, pkgdir, fname) |
55 |
| - if os.path.exists(static_filename): |
56 |
| - return static_filename |
57 |
| - else: |
58 |
| - tried.append(static_filename) |
59 |
| - raise CoverageException( |
60 |
| - f"Couldn't find static file {fname!r} from {os.getcwd()!r}, tried: {tried!r}" |
61 |
| - ) |
| 29 | + static_dir = os.path.join(os.path.dirname(__file__), "htmlfiles") |
| 30 | + static_filename = os.path.join(static_dir, fname) |
| 31 | + return static_filename |
62 | 32 |
|
63 | 33 |
|
64 | 34 | def read_data(fname):
|
@@ -158,11 +128,11 @@ class HtmlReporter:
|
158 | 128 | # These files will be copied from the htmlfiles directory to the output
|
159 | 129 | # directory.
|
160 | 130 | STATIC_FILES = [
|
161 |
| - ("style.css", ""), |
162 |
| - ("coverage_html.js", ""), |
163 |
| - ("keybd_closed.png", ""), |
164 |
| - ("keybd_open.png", ""), |
165 |
| - ("favicon_32.png", ""), |
| 131 | + "style.css", |
| 132 | + "coverage_html.js", |
| 133 | + "keybd_closed.png", |
| 134 | + "keybd_open.png", |
| 135 | + "favicon_32.png", |
166 | 136 | ]
|
167 | 137 |
|
168 | 138 | def __init__(self, cov):
|
@@ -251,18 +221,12 @@ def report(self, morfs):
|
251 | 221 | def make_local_static_report_files(self):
|
252 | 222 | """Make local instances of static files for HTML report."""
|
253 | 223 | # The files we provide must always be copied.
|
254 |
| - for static, pkgdir in self.STATIC_FILES: |
255 |
| - shutil.copyfile( |
256 |
| - data_filename(static, pkgdir), |
257 |
| - os.path.join(self.directory, static) |
258 |
| - ) |
| 224 | + for static in self.STATIC_FILES: |
| 225 | + shutil.copyfile(data_filename(static), os.path.join(self.directory, static)) |
259 | 226 |
|
260 | 227 | # The user may have extra CSS they want copied.
|
261 | 228 | if self.extra_css:
|
262 |
| - shutil.copyfile( |
263 |
| - self.config.extra_css, |
264 |
| - os.path.join(self.directory, self.extra_css) |
265 |
| - ) |
| 229 | + shutil.copyfile(self.config.extra_css, os.path.join(self.directory, self.extra_css)) |
266 | 230 |
|
267 | 231 | def html_file(self, fr, analysis):
|
268 | 232 | """Generate an HTML file for one source file."""
|
|
0 commit comments