8 import re |
8 import re |
9 |
9 |
10 from coverage import env |
10 from coverage import env |
11 from coverage.backward import configparser, path_types |
11 from coverage.backward import configparser, path_types |
12 from coverage.misc import CoverageException, substitute_variables |
12 from coverage.misc import CoverageException, substitute_variables |
|
13 |
|
14 # TOML support is an install-time extra option. |
|
15 try: |
|
16 import toml |
|
17 except ImportError: # pragma: not covered |
|
18 toml = None |
13 |
19 |
14 |
20 |
15 class TomlDecodeError(Exception): |
21 class TomlDecodeError(Exception): |
16 """An exception class that exists even when toml isn't installed.""" |
22 """An exception class that exists even when toml isn't installed.""" |
17 pass |
23 pass |
27 def __init__(self, our_file): |
33 def __init__(self, our_file): |
28 self.our_file = our_file |
34 self.our_file = our_file |
29 self.data = None |
35 self.data = None |
30 |
36 |
31 def read(self, filenames): |
37 def read(self, filenames): |
32 from coverage.optional import toml |
|
33 |
|
34 # RawConfigParser takes a filename or list of filenames, but we only |
38 # RawConfigParser takes a filename or list of filenames, but we only |
35 # ever call this with a single filename. |
39 # ever call this with a single filename. |
36 assert isinstance(filenames, path_types) |
40 assert isinstance(filenames, path_types) |
37 filename = filenames |
41 filename = filenames |
38 if env.PYVERSION >= (3, 6): |
42 if env.PYVERSION >= (3, 6): |