summaryrefslogtreecommitdiff
path: root/coverage/codeunit.py
diff options
context:
space:
mode:
Diffstat (limited to 'coverage/codeunit.py')
-rw-r--r--coverage/codeunit.py22
1 files changed, 13 insertions, 9 deletions
diff --git a/coverage/codeunit.py b/coverage/codeunit.py
index 35167a72..3ec9c390 100644
--- a/coverage/codeunit.py
+++ b/coverage/codeunit.py
@@ -10,14 +10,16 @@ from coverage.phystokens import source_token_lines, source_encoding
from coverage.django import DjangoTracer
-def code_unit_factory(morfs, file_locator, get_ext=None):
+def code_unit_factory(morfs, file_locator, get_plugin=None):
"""Construct a list of CodeUnits from polymorphic inputs.
`morfs` is a module or a filename, or a list of same.
`file_locator` is a FileLocator that can help resolve filenames.
- `get_ext` TODO
+ `get_plugin` is a function taking a filename, and returning a plugin
+ responsible for the file. It can also return None if there is no plugin
+ claiming the file.
Returns a list of CodeUnit objects.
@@ -26,15 +28,14 @@ def code_unit_factory(morfs, file_locator, get_ext=None):
if not isinstance(morfs, (list, tuple)):
morfs = [morfs]
- django_tracer = DjangoTracer()
-
code_units = []
for morf in morfs:
- ext = None
- if isinstance(morf, string_class) and get_ext:
- ext = get_ext(morf)
- if ext:
- klass = DjangoTracer # NOT REALLY! TODO
+ plugin = None
+ if isinstance(morf, string_class) and get_plugin:
+ plugin = get_plugin(morf)
+ if plugin:
+ klass = plugin.code_unit_class(morf)
+ #klass = DjangoTracer # NOT REALLY! TODO
# Hacked-in Mako support. Define COVERAGE_MAKO_PATH as a fragment of
# the path that indicates the Python file is actually a compiled Mako
# template. THIS IS TEMPORARY!
@@ -162,6 +163,9 @@ class CodeUnit(object):
"""
return False
+ def get_parser(self, exclude=None):
+ raise NotImplementedError
+
class PythonCodeUnit(CodeUnit):
"""Represents a Python file."""