eric7/DebugClients/Python/coverage/config.py

branch
eric7
changeset 8527
2bd1325d727e
parent 8312
800c432b34c8
child 8775
0802ae193343
equal deleted inserted replaced
8526:587202572b10 8527:2bd1325d727e
61 def options(self, section): 61 def options(self, section):
62 for section_prefix in self.section_prefixes: 62 for section_prefix in self.section_prefixes:
63 real_section = section_prefix + section 63 real_section = section_prefix + section
64 if configparser.RawConfigParser.has_section(self, real_section): 64 if configparser.RawConfigParser.has_section(self, real_section):
65 return configparser.RawConfigParser.options(self, real_section) 65 return configparser.RawConfigParser.options(self, real_section)
66 raise configparser.NoSectionError 66 raise configparser.NoSectionError(section)
67 67
68 def get_section(self, section): 68 def get_section(self, section):
69 """Get the contents of a section, as a dictionary.""" 69 """Get the contents of a section, as a dictionary."""
70 d = {} 70 d = {}
71 for opt in self.options(section): 71 for opt in self.options(section):
85 for section_prefix in self.section_prefixes: 85 for section_prefix in self.section_prefixes:
86 real_section = section_prefix + section 86 real_section = section_prefix + section
87 if configparser.RawConfigParser.has_option(self, real_section, option): 87 if configparser.RawConfigParser.has_option(self, real_section, option):
88 break 88 break
89 else: 89 else:
90 raise configparser.NoOptionError 90 raise configparser.NoOptionError(option, section)
91 91
92 v = configparser.RawConfigParser.get(self, real_section, option, *args, **kwargs) 92 v = configparser.RawConfigParser.get(self, real_section, option, *args, **kwargs)
93 v = substitute_variables(v, os.environ) 93 v = substitute_variables(v, os.environ)
94 return v 94 return v
95 95
215 self.sort = None 215 self.sort = None
216 216
217 # Defaults for [html] 217 # Defaults for [html]
218 self.extra_css = None 218 self.extra_css = None
219 self.html_dir = "htmlcov" 219 self.html_dir = "htmlcov"
220 self.html_skip_covered = None
221 self.html_skip_empty = None
220 self.html_title = "Coverage report" 222 self.html_title = "Coverage report"
221 self.show_contexts = False 223 self.show_contexts = False
222 224
223 # Defaults for [xml] 225 # Defaults for [xml]
224 self.xml_output = "coverage.xml" 226 self.xml_output = "coverage.xml"
382 ('sort', 'report:sort'), 384 ('sort', 'report:sort'),
383 385
384 # [html] 386 # [html]
385 ('extra_css', 'html:extra_css'), 387 ('extra_css', 'html:extra_css'),
386 ('html_dir', 'html:directory'), 388 ('html_dir', 'html:directory'),
389 ('html_skip_covered', 'html:skip_covered', 'boolean'),
390 ('html_skip_empty', 'html:skip_empty', 'boolean'),
387 ('html_title', 'html:title'), 391 ('html_title', 'html:title'),
388 ('show_contexts', 'html:show_contexts', 'boolean'), 392 ('show_contexts', 'html:show_contexts', 'boolean'),
389 393
390 # [xml] 394 # [xml]
391 ('xml_output', 'xml:output'), 395 ('xml_output', 'xml:output'),
470 if key and plugin_name in self.plugins: 474 if key and plugin_name in self.plugins:
471 return self.plugin_options.get(plugin_name, {}).get(key) 475 return self.plugin_options.get(plugin_name, {}).get(key)
472 476
473 # If we get here, we didn't find the option. 477 # If we get here, we didn't find the option.
474 raise CoverageException("No such option: %r" % option_name) 478 raise CoverageException("No such option: %r" % option_name)
479
480 def post_process_file(self, path):
481 """Make final adjustments to a file path to make it usable."""
482 return os.path.expanduser(path)
483
484 def post_process(self):
485 """Make final adjustments to settings to make them usable."""
486 self.data_file = self.post_process_file(self.data_file)
487 self.html_dir = self.post_process_file(self.html_dir)
488 self.xml_output = self.post_process_file(self.xml_output)
489 self.paths = collections.OrderedDict(
490 (k, [self.post_process_file(f) for f in v])
491 for k, v in self.paths.items()
492 )
475 493
476 494
477 def config_files_to_try(config_file): 495 def config_files_to_try(config_file):
478 """What config files should we try to read? 496 """What config files should we try to read?
479 497
545 # 4) from constructor arguments: 563 # 4) from constructor arguments:
546 config.from_args(**kwargs) 564 config.from_args(**kwargs)
547 565
548 # Once all the config has been collected, there's a little post-processing 566 # Once all the config has been collected, there's a little post-processing
549 # to do. 567 # to do.
550 config.data_file = os.path.expanduser(config.data_file) 568 config.post_process()
551 config.html_dir = os.path.expanduser(config.html_dir)
552 config.xml_output = os.path.expanduser(config.xml_output)
553 config.paths = collections.OrderedDict(
554 (k, [os.path.expanduser(f) for f in v])
555 for k, v in config.paths.items()
556 )
557 569
558 return config 570 return config

eric ide

mercurial