Return a plausible module name for the path.
(path)
| 122 | return filename |
| 123 | |
| 124 | def _fullmodname(path): |
| 125 | """Return a plausible module name for the path.""" |
| 126 | |
| 127 | # If the file 'path' is part of a package, then the filename isn't |
| 128 | # enough to uniquely identify it. Try to do the right thing by |
| 129 | # looking in sys.path for the longest matching prefix. We'll |
| 130 | # assume that the rest is the package name. |
| 131 | |
| 132 | comparepath = os.path.normcase(path) |
| 133 | longest = "" |
| 134 | for dir in sys.path: |
| 135 | dir = os.path.normcase(dir) |
| 136 | if comparepath.startswith(dir) and comparepath[len(dir)] == os.sep: |
| 137 | if len(dir) > len(longest): |
| 138 | longest = dir |
| 139 | |
| 140 | if longest: |
| 141 | base = path[len(longest) + 1:] |
| 142 | else: |
| 143 | base = path |
| 144 | # the drive letter is never part of the module name |
| 145 | drive, base = os.path.splitdrive(base) |
| 146 | base = base.replace(os.sep, ".") |
| 147 | if os.altsep: |
| 148 | base = base.replace(os.altsep, ".") |
| 149 | filename, ext = os.path.splitext(base) |
| 150 | return filename.lstrip(".") |
| 151 | |
| 152 | class CoverageResults: |
| 153 | def __init__(self, counts=None, calledfuncs=None, infile=None, |
no test coverage detected
searching dependent graphs…