diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2009-05-05 07:14:36 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2009-05-05 07:14:36 -0400 |
commit | 2b98aec2bebc201981f017d055a32475c4490a4f (patch) | |
tree | 3c7654466b38645c01539acf33c236bbe130aa9a | |
parent | 8ec865c5f8d850e0649b55e866216a29836287dd (diff) | |
download | python-coveragepy-git-2b98aec2bebc201981f017d055a32475c4490a4f.tar.gz |
Even simpler: get rid of the lambdas for the singleton methods.
-rw-r--r-- | coverage/__init__.py | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/coverage/__init__.py b/coverage/__init__.py index 2b67438f..c1b95874 100644 --- a/coverage/__init__.py +++ b/coverage/__init__.py @@ -22,22 +22,24 @@ from coverage.misc import CoverageException # created as needed when one of the module-level functions is called. _the_coverage = None -def _call_singleton_method(name, args, kwargs): - global _the_coverage - if not _the_coverage: - _the_coverage = coverage() - return getattr(_the_coverage, name)(*args, **kwargs) +def _singleton_method(name): + def func(*args, **kwargs): + global _the_coverage + if not _the_coverage: + _the_coverage = coverage() + return getattr(_the_coverage, name)(*args, **kwargs) + return func # Define the module-level functions. -use_cache = lambda *a, **kw: _call_singleton_method('use_cache', a, kw) -start = lambda *a, **kw: _call_singleton_method('start', a, kw) -stop = lambda *a, **kw: _call_singleton_method('stop', a, kw) -erase = lambda *a, **kw: _call_singleton_method('erase', a, kw) -exclude = lambda *a, **kw: _call_singleton_method('exclude', a, kw) -analysis = lambda *a, **kw: _call_singleton_method('analysis', a, kw) -analysis2 = lambda *a, **kw: _call_singleton_method('analysis2', a, kw) -report = lambda *a, **kw: _call_singleton_method('report', a, kw) -annotate = lambda *a, **kw: _call_singleton_method('annotate', a, kw) +use_cache = _singleton_method('use_cache') +start = _singleton_method('start') +stop = _singleton_method('stop') +erase = _singleton_method('erase') +exclude = _singleton_method('exclude') +analysis = _singleton_method('analysis') +analysis2 = _singleton_method('analysis2') +report = _singleton_method('report') +annotate = _singleton_method('annotate') # COPYRIGHT AND LICENSE |