From 16d122b82d25378bd9ab096dbce91d7ab5449e5c Mon Sep 17 00:00:00 2001 From: Emil 'Skeen' Madsen Date: Sun, 12 Mar 2017 20:47:18 +0100 Subject: [PATCH 1/4] Initial attempt at finding unexecuted files --- django_coverage_plugin/plugin.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/django_coverage_plugin/plugin.py b/django_coverage_plugin/plugin.py index 4e424f5..acb3588 100644 --- a/django_coverage_plugin/plugin.py +++ b/django_coverage_plugin/plugin.py @@ -6,6 +6,7 @@ from __future__ import print_function import os.path +import re from six.moves import range @@ -162,6 +163,15 @@ def file_tracer(self, filename): def file_reporter(self, filename): return FileReporter(filename) + def find_unexecuted_files(self, src_dir): + res = [] + for i, (dirpath, dirnames, filenames) in enumerate(os.walk(src_dir)): + for filename in filenames: + if re.match(r"^[^.#~!$@%^&*()+=,]+\.html?$", filename): + filepath = os.path.join(dirpath, filename) + res.append(filepath) + return res + # --- FileTracer methods def has_dynamic_source_filename(self): From 3fab4d8e780867361c165a497659750ebce0445b Mon Sep 17 00:00:00 2001 From: Emil Madsen Date: Mon, 13 Mar 2017 08:56:37 +0100 Subject: [PATCH 2/4] Rename hook, use generator and splitext instead of regex --- django_coverage_plugin/plugin.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/django_coverage_plugin/plugin.py b/django_coverage_plugin/plugin.py index acb3588..204abdd 100644 --- a/django_coverage_plugin/plugin.py +++ b/django_coverage_plugin/plugin.py @@ -163,14 +163,12 @@ def file_tracer(self, filename): def file_reporter(self, filename): return FileReporter(filename) - def find_unexecuted_files(self, src_dir): - res = [] + def find_executable_files(self, src_dir): for i, (dirpath, dirnames, filenames) in enumerate(os.walk(src_dir)): for filename in filenames: - if re.match(r"^[^.#~!$@%^&*()+=,]+\.html?$", filename): - filepath = os.path.join(dirpath, filename) - res.append(filepath) - return res + ignored, ext = os.path.splitext(filename) + if ext in (".htm", ".html"): + yield os.path.join(dirpath, filename) # --- FileTracer methods From d9f5e1b1baa9fd3c65f25ea5c114b09feeb16d42 Mon Sep 17 00:00:00 2001 From: Emil Madsen Date: Mon, 13 Mar 2017 14:18:22 +0100 Subject: [PATCH 3/4] Removed enumerate for os.walk, added regex again. --- django_coverage_plugin/plugin.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/django_coverage_plugin/plugin.py b/django_coverage_plugin/plugin.py index 204abdd..661f4ac 100644 --- a/django_coverage_plugin/plugin.py +++ b/django_coverage_plugin/plugin.py @@ -164,10 +164,12 @@ def file_reporter(self, filename): return FileReporter(filename) def find_executable_files(self, src_dir): - for i, (dirpath, dirnames, filenames) in enumerate(os.walk(src_dir)): + for (dirpath, dirnames, filenames) in os.walk(src_dir): for filename in filenames: - ignored, ext = os.path.splitext(filename) - if ext in (".htm", ".html"): + # We're only interested in files that look like reasonable HTML + # files: Must end with .htm or .html, and must not have certain + # funny characters that probably mean they are editor junk. + if re.match(r"^[^.#~!$@%^&*()+=,]+\.html?$", filename): yield os.path.join(dirpath, filename) # --- FileTracer methods From a9d274bb09149c1e74032c4bfb616944362a731c Mon Sep 17 00:00:00 2001 From: Emil Madsen Date: Fri, 7 Apr 2017 14:43:55 +0200 Subject: [PATCH 4/4] Added myself to AUTHORS.txt --- AUTHORS.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.txt b/AUTHORS.txt index 8a697a9..c1bf993 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -4,3 +4,4 @@ contributions by: Jessamyn Smith Simon Charette Pamela McA'Nulty +Emil Madsen