diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2018-02-25 07:34:57 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2018-02-25 07:34:57 -0500 |
commit | bd613312d29b21b3bce5bb6f7c6561244a6c6830 (patch) | |
tree | bd454b35b06b432629e51267395d87a9b2adf300 /coverage/disposition.py | |
parent | ab1b883cb4ce7cc7a90c6e41545e0bfd1a8d7d05 (diff) | |
download | python-coveragepy-git-bd613312d29b21b3bce5bb6f7c6561244a6c6830.tar.gz |
Huge refactor of code out of control into inorout
--HG--
branch : inorout
Diffstat (limited to 'coverage/disposition.py')
-rw-r--r-- | coverage/disposition.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/coverage/disposition.py b/coverage/disposition.py new file mode 100644 index 00000000..e9b8ba65 --- /dev/null +++ b/coverage/disposition.py @@ -0,0 +1,37 @@ +# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 +# For details: https://bitbucket.org/ned/coveragepy/src/default/NOTICE.txt + +"""Simple value objects for tracking what to do with files.""" + + +class FileDisposition(object): + """A simple value type for recording what to do with a file.""" + pass + + +# FileDisposition "methods": FileDisposition is a pure value object, so it can +# be implemented in either C or Python. Acting on them is done with these +# functions. + +def disposition_init(cls, original_filename): + """Construct and initialize a new FileDisposition object.""" + disp = cls() + disp.original_filename = original_filename + disp.canonical_filename = original_filename + disp.source_filename = None + disp.trace = False + disp.reason = "" + disp.file_tracer = None + disp.has_dynamic_filename = False + return disp + + +def disposition_debug_msg(disp): + """Make a nice debug message of what the FileDisposition is doing.""" + if disp.trace: + msg = "Tracing %r" % (disp.original_filename,) + if disp.file_tracer: + msg += ": will be traced by %r" % disp.file_tracer + else: + msg = "Not tracing %r: %s" % (disp.original_filename, disp.reason) + return msg |