summaryrefslogtreecommitdiff
path: root/coverage/codeunit.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2012-04-18 07:28:37 -0400
committerNed Batchelder <ned@nedbatchelder.com>2012-04-18 07:28:37 -0400
commitb5b0316a0625b3e3b1fe258375c7d37a0bd0072c (patch)
tree35b76edd1bdde3dfebbc25a338f227c529e232ad /coverage/codeunit.py
parentf99806b7b414cc5aea3e8b0a016f2dad68e6539d (diff)
parent42f5efa9bc9e5ec2fd02f9cf6b95541a93fca632 (diff)
downloadpython-coveragepy-b5b0316a0625b3e3b1fe258375c7d37a0bd0072c.tar.gz
Automated merge with ssh://bitbucket.org/ned/coveragepy
Diffstat (limited to 'coverage/codeunit.py')
-rw-r--r--coverage/codeunit.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/coverage/codeunit.py b/coverage/codeunit.py
index 55f44a2..1999c50 100644
--- a/coverage/codeunit.py
+++ b/coverage/codeunit.py
@@ -115,3 +115,23 @@ class CodeUnit(object):
raise CoverageException(
"No source for code %r." % self.filename
)
+
+ def should_be_python(self):
+ """Does it seem like this file should contain Python?
+
+ This is used to decide if a file reported as part of the exection of
+ a program was really likely to have contained Python in the first
+ place.
+
+ """
+ # Get the file extension.
+ _, ext = os.path.splitext(self.filename)
+
+ # Anything named *.py* should be Python.
+ if ext.startswith('.py'):
+ return True
+ # A file with no extension should be Python.
+ if not ext:
+ return True
+ # Everything else is probably not Python.
+ return False