summaryrefslogtreecommitdiff
path: root/coverage/plugin.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2015-01-24 22:21:21 -0500
committerNed Batchelder <ned@nedbatchelder.com>2015-01-24 22:21:21 -0500
commit16682db69e225ab7d8c321fc2ae99ec690675dc6 (patch)
tree9322a0567b4f8edd476ea34ce3f8402bf5f5a952 /coverage/plugin.py
parent7d0d15ac432748c82e4de77ac36ccd711c608d46 (diff)
downloadpython-coveragepy-16682db69e225ab7d8c321fc2ae99ec690675dc6.tar.gz
Move flat_rootname to the base class
Diffstat (limited to 'coverage/plugin.py')
-rw-r--r--coverage/plugin.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/coverage/plugin.py b/coverage/plugin.py
index c80a1a2..32d654e 100644
--- a/coverage/plugin.py
+++ b/coverage/plugin.py
@@ -1,5 +1,7 @@
"""Plugin interfaces for coverage.py"""
+import re
+
from coverage.misc import _needs_to_implement
@@ -206,10 +208,14 @@ class FileReporter(object):
return False
def flat_rootname(self):
+ """A base for a flat filename to correspond to this code unit.
+
+ Useful for writing files about the code where you want all the files in
+ the same directory, but need to differentiate same-named files from
+ different directories.
+
+ For example, the file a/b/c.py will return 'a_b_c_py'
+
+ """
# TODO: a better generic implementation?
- return (
- self.filename
- .replace('\\', '_')
- .replace('/', '_')
- .replace('.', '_')
- )
+ return re.sub(r"[\/.:]", "_", self.name)