src/eric7/DebugClients/Python/coverage/disposition.py

branch
eric7
changeset 9209
b99e7fd55fd3
parent 8991
2fc945191992
equal deleted inserted replaced
9208:3fc8dfeb6ebe 9209:b99e7fd55fd3
1 # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
2 # For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt
3
4 """Simple value objects for tracking what to do with files."""
5
6
7 class FileDisposition:
8 """A simple value type for recording what to do with a file."""
9
10 def __repr__(self):
11 return f"<FileDisposition {self.canonical_filename!r}: trace={self.trace}>"
12
13
14 # FileDisposition "methods": FileDisposition is a pure value object, so it can
15 # be implemented in either C or Python. Acting on them is done with these
16 # functions.
17
18 def disposition_init(cls, original_filename):
19 """Construct and initialize a new FileDisposition object."""
20 disp = cls()
21 disp.original_filename = original_filename
22 disp.canonical_filename = original_filename
23 disp.source_filename = None
24 disp.trace = False
25 disp.reason = ""
26 disp.file_tracer = None
27 disp.has_dynamic_filename = False
28 return disp
29
30
31 def disposition_debug_msg(disp):
32 """Make a nice debug message of what the FileDisposition is doing."""
33 if disp.trace:
34 msg = f"Tracing {disp.original_filename!r}"
35 if disp.original_filename != disp.source_filename:
36 msg += f" as {disp.source_filename!r}"
37 if disp.file_tracer:
38 msg += f": will be traced by {disp.file_tracer!r}"
39 else:
40 msg = f"Not tracing {disp.original_filename!r}: {disp.reason}"
41 return msg

eric ide

mercurial