diff options
| author | Ned Batchelder <ned@nedbatchelder.com> | 2015-08-09 09:48:51 -0400 |
|---|---|---|
| committer | Ned Batchelder <ned@nedbatchelder.com> | 2015-08-09 09:48:51 -0400 |
| commit | d7f2c64b7071d20378d6864cc4ec1c1c83b09175 (patch) | |
| tree | 4b8733ebe02d867252b097ea443ebdce7eb26215 /coverage/files.py | |
| parent | 3cc5b11a413426b07a51e86eab20a7e9ebab4f2d (diff) | |
| download | python-coveragepy-git-d7f2c64b7071d20378d6864cc4ec1c1c83b09175.tar.gz | |
Move flat_rootname from FileReporter to a utility function.
Diffstat (limited to 'coverage/files.py')
| -rw-r--r-- | coverage/files.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/coverage/files.py b/coverage/files.py index e3ebd6ce..d2742a39 100644 --- a/coverage/files.py +++ b/coverage/files.py @@ -67,6 +67,20 @@ def canonical_filename(filename): return CANONICAL_FILENAME_CACHE[filename] +def flat_rootname(filename): + """A base for a flat filename to correspond to this file. + + 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' + + """ + name = os.path.splitdrive(filename)[1] + return re.sub(r"[\\/.:]", "_", name) + + if env.WINDOWS: _ACTUAL_PATH_CACHE = {} |
