eric7/DebugClients/Python/coverage/cmdline.py

branch
eric7
changeset 9099
0e511e0e94a3
parent 8991
2fc945191992
equal deleted inserted replaced
9098:fb9351497cea 9099:0e511e0e94a3
230 Defaults are initialized for all options. 230 Defaults are initialized for all options.
231 231
232 """ 232 """
233 233
234 def __init__(self, *args, **kwargs): 234 def __init__(self, *args, **kwargs):
235 super().__init__( 235 super().__init__(add_help_option=False, *args, **kwargs)
236 add_help_option=False, *args, **kwargs
237 )
238 self.set_defaults( 236 self.set_defaults(
239 # Keep these arguments alphabetized by their names. 237 # Keep these arguments alphabetized by their names.
240 action=None, 238 action=None,
241 append=None, 239 append=None,
242 branch=None, 240 branch=None,
265 sort=None, 263 sort=None,
266 source=None, 264 source=None,
267 timid=None, 265 timid=None,
268 title=None, 266 title=None,
269 version=None, 267 version=None,
270 ) 268 )
271 269
272 self.disable_interspersed_args() 270 self.disable_interspersed_args()
273 271
274 class OptionParserError(Exception): 272 class OptionParserError(Exception):
275 """Used to stop the optparse error handler ending the process.""" 273 """Used to stop the optparse error handler ending the process."""
350 348
351 GLOBAL_ARGS = [ 349 GLOBAL_ARGS = [
352 Opts.debug, 350 Opts.debug,
353 Opts.help, 351 Opts.help,
354 Opts.rcfile, 352 Opts.rcfile,
355 ] 353 ]
356 354
357 COMMANDS = { 355 COMMANDS = {
358 'annotate': CmdOptionParser( 356 'annotate': CmdOptionParser(
359 "annotate", 357 "annotate",
360 [ 358 [
471 Opts.ignore_errors, 469 Opts.ignore_errors,
472 Opts.include, 470 Opts.include,
473 Opts.output_lcov, 471 Opts.output_lcov,
474 Opts.omit, 472 Opts.omit,
475 Opts.quiet, 473 Opts.quiet,
476 ] + GLOBAL_ARGS, 474 ] + GLOBAL_ARGS,
477 usage="[options] [modules]", 475 usage="[options] [modules]",
478 description="Generate an LCOV report of coverage results.", 476 description="Generate an LCOV report of coverage results.",
479 ), 477 ),
480 478
481 'report': CmdOptionParser( 479 'report': CmdOptionParser(
646 debug=debug, 644 debug=debug,
647 concurrency=concurrency, 645 concurrency=concurrency,
648 check_preimported=True, 646 check_preimported=True,
649 context=options.context, 647 context=options.context,
650 messages=not options.quiet, 648 messages=not options.quiet,
651 ) 649 )
652 650
653 if options.action == "debug": 651 if options.action == "debug":
654 return self.do_debug(args) 652 return self.do_debug(args)
655 653
656 elif options.action == "erase": 654 elif options.action == "erase":
673 morfs=unglob_args(args), 671 morfs=unglob_args(args),
674 ignore_errors=options.ignore_errors, 672 ignore_errors=options.ignore_errors,
675 omit=omit, 673 omit=omit,
676 include=include, 674 include=include,
677 contexts=contexts, 675 contexts=contexts,
678 ) 676 )
679 677
680 # We need to be able to import from the current directory, because 678 # We need to be able to import from the current directory, because
681 # plugins may try to, for example, to read Django settings. 679 # plugins may try to, for example, to read Django settings.
682 sys.path.insert(0, '') 680 sys.path.insert(0, '')
683 681
690 show_missing=options.show_missing, 688 show_missing=options.show_missing,
691 skip_covered=options.skip_covered, 689 skip_covered=options.skip_covered,
692 skip_empty=options.skip_empty, 690 skip_empty=options.skip_empty,
693 sort=options.sort, 691 sort=options.sort,
694 **report_args 692 **report_args
695 ) 693 )
696 elif options.action == "annotate": 694 elif options.action == "annotate":
697 self.coverage.annotate(directory=options.directory, **report_args) 695 self.coverage.annotate(directory=options.directory, **report_args)
698 elif options.action == "html": 696 elif options.action == "html":
699 total = self.coverage.html_report( 697 total = self.coverage.html_report(
700 directory=options.directory, 698 directory=options.directory,
702 skip_covered=options.skip_covered, 700 skip_covered=options.skip_covered,
703 skip_empty=options.skip_empty, 701 skip_empty=options.skip_empty,
704 show_contexts=options.show_contexts, 702 show_contexts=options.show_contexts,
705 title=options.title, 703 title=options.title,
706 **report_args 704 **report_args
707 ) 705 )
708 elif options.action == "xml": 706 elif options.action == "xml":
709 total = self.coverage.xml_report( 707 total = self.coverage.xml_report(
710 outfile=options.outfile, 708 outfile=options.outfile,
711 skip_empty=options.skip_empty, 709 skip_empty=options.skip_empty,
712 **report_args 710 **report_args
713 ) 711 )
714 elif options.action == "json": 712 elif options.action == "json":
715 total = self.coverage.json_report( 713 total = self.coverage.json_report(
716 outfile=options.outfile, 714 outfile=options.outfile,
717 pretty_print=options.pretty_print, 715 pretty_print=options.pretty_print,
718 show_contexts=options.show_contexts, 716 show_contexts=options.show_contexts,
719 **report_args 717 **report_args
720 ) 718 )
721 elif options.action == "lcov": 719 elif options.action == "lcov":
722 total = self.coverage.lcov_report( 720 total = self.coverage.lcov_report(
723 outfile=options.outfile, 721 outfile=options.outfile,
724 **report_args 722 **report_args
725 ) 723 )
726 else: 724 else:
727 # There are no other possible actions. 725 # There are no other possible actions.
728 raise AssertionError 726 raise AssertionError
729 727
730 if total is not None: 728 if total is not None:

eric ide

mercurial