diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2014-09-14 16:44:21 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2014-09-14 16:44:21 -0400 |
commit | 941eeb588459098a85266b4c5d176d6deed2eb53 (patch) | |
tree | 49d410b2b46d5d7a56faee81e6ed4a8fdcdd47e3 /coverage/codeunit.py | |
parent | 0891e02eb490494ee40a7f840e4ab9fd6b3d2d7b (diff) | |
download | python-coveragepy-git-941eeb588459098a85266b4c5d176d6deed2eb53.tar.gz |
Progress on plugins
Diffstat (limited to 'coverage/codeunit.py')
-rw-r--r-- | coverage/codeunit.py | 22 |
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.""" |