Provide a supported API for access to raw data
[From Russ Magee:]
After our conversation on Twitter yesterday about Duvet, I took a look a look at making better use of coverage.py's internals. The result wasn't that bad:
You suggested that you were would be interested in feedback on what needs to be formalised to make this sort of thing easier -- here's my 2c/wishlist:
- Make coverage.load() raise an exception if the coverage file doesn't exist. At present it's a silent failure, covered by a catch-all exception. I've worked around this by checking if coverage.data.measured_files() is empty, but it really should be an exception IMHO.
- Provide formal access to the list of files/modules that the coverage data spans. This could be done by either formalising the coverage.data class, or adding an entry point to coverage.data.measured_files(). Looking at the internals, however, it looks like coverage.data has some other potentially useful API endpoints, so formalizing might be the better approach.
- Provide access to the individual file coverage/branch coverage percentage, and the overall project coverage percentage. As it stands I need to invoke coverage._analyze() and handle the resultant Numbers instances, rather than coverage.analysis()/analysis2().