def start(self): profile = get_module_profile( get_module("fontbakery.profiles." + self.profilename)) print(self.checks) runner = CheckRunner(profile, values={"fonts": self.paths}, config={ "custom_order": None, "explicit_checks": self.checks, "exclude_checks": None }) print("Log levels: ", self.loglevels) hr = HTMLReporter(runner=runner, loglevels=self.loglevels) ghmd = GHMarkdownReporter(runner=runner, loglevels=self.loglevels) prog = ProgressReporter(self.progressStatus, runner=runner) reporters = [hr.receive, prog.receive, ghmd.receive] status_generator = runner.run() print("Starting distribute_generator") distribute_generator(status_generator, reporters) print("Done with distribute_generator") self.signalStatus.emit(hr.get_html(), ghmd.get_markdown())
def main(profile=None, values=None): # profile can be injected by e.g. check-googlefonts injects it's own profile add_profile_arg = False if profile is None: profile = get_profile() add_profile_arg = True argument_parser, values_keys = ArgumentParser(profile, profile_arg=add_profile_arg) args = argument_parser.parse_args() if args.list_checks: if args.loglevels == [PASS]: # if verbose: from fontbakery.constants import WHITE_STR, CYAN_STR, BLUE_STR for section in profile._sections.values(): print(WHITE_STR.format("\nSection:") + " " + section.name) for check in section._checks: print( CYAN_STR.format(check.id) + "\n" + BLUE_STR.format(f'"{check.description}"') + "\n") else: for section_name, section in profile._sections.items(): for check in section._checks: print(check.id) sys.exit() values_ = {} if values is not None: values_.update(values) # values_keys are returned by profile.setup_argparse # these are keys for custom arguments required by the profile. if values_keys: for key in values_keys: if hasattr(args, key): values_[key] = getattr(args, key) try: runner = CheckRunner(profile, values=values_, custom_order=args.order, explicit_checks=args.checkid, exclude_checks=args.exclude_checkid) except ValueValidationError as e: print(e) argument_parser.print_usage() sys.exit(1) # The default Windows Terminal just displays the escape codes. The argument # parser above therefore has these options disabled. if sys.platform == "win32": args.no_progress = True args.no_colors = True # the most verbose loglevel wins loglevel = min(args.loglevels) if args.loglevels else DEFAULT_LOG_LEVEL tr = TerminalReporter(runner=runner, is_async=False , print_progress=not args.no_progress , check_threshold=loglevel , log_threshold=args.loglevel_messages or loglevel , usecolor=not args.no_colors , collect_results_by=args.gather_by , skip_status_report=None if args.show_sections\ else (STARTSECTION, ENDSECTION) ) reporters = [tr.receive] if args.json: sr = SerializeReporter(runner=runner, collect_results_by=args.gather_by) reporters.append(sr.receive) if args.ghmarkdown: mdr = GHMarkdownReporter(loglevels=args.loglevels, runner=runner, collect_results_by=args.gather_by) reporters.append(mdr.receive) if args.html: hr = HTMLReporter(loglevels=args.loglevels, runner=runner, collect_results_by=args.gather_by) reporters.append(hr.receive) distribute_generator(runner.run(), reporters) if args.json: import json json.dump(sr.getdoc(), args.json, sort_keys=True, indent=4) print("A report in JSON format has been" " saved to '{}'".format(args.json.name)) if args.ghmarkdown: args.ghmarkdown.write(mdr.get_markdown()) print("A report in GitHub Markdown format which can be useful\n" " for posting issues on a GitHub issue tracker has been\n" " saved to '{}'".format(args.ghmarkdown.name)) if args.html: args.html.write(hr.get_html()) print(f"A report in HTML format has been saved to '{args.html.name}'") # Fail and error let the command fail return 1 if tr.worst_check_status in (ERROR, FAIL) else 0
def main(profile=None, values=None): # profile can be injected by e.g. check-googlefonts injects it's own profile add_profile_arg = False if profile is None: profile = get_profile() add_profile_arg = True argument_parser, values_keys = ArgumentParser(profile, profile_arg=add_profile_arg) args = argument_parser.parse_args() if args.list_checks: if args.loglevels == [PASS]: # if verbose: from fontbakery.constants import WHITE_STR, CYAN_STR, BLUE_STR for section in profile._sections.values(): print(WHITE_STR.format("\nSection:") + " " + section.name) for check in section._checks: print(CYAN_STR.format(check.id) + "\n" + BLUE_STR.format(f'"{check.description}"') + "\n") else: for section_name, section in profile._sections.items(): for check in section._checks: print(check.id) sys.exit() values_ = {} if values is not None: values_.update(values) # values_keys are returned by profile.setup_argparse # these are keys for custom arguments required by the profile. if values_keys: for key in values_keys: if hasattr(args, key): values_[key] = getattr(args, key) try: runner = CheckRunner(profile , values=values_ , custom_order=args.order , explicit_checks=args.checkid , exclude_checks=args.exclude_checkid ) except ValueValidationError as e: print(e) argument_parser.print_usage() sys.exit(1) # The default Windows Terminal just displays the escape codes. The argument # parser above therefore has these options disabled. if sys.platform == "win32": args.no_progress = True args.no_colors = True # the most verbose loglevel wins loglevel = min(args.loglevels) if args.loglevels else DEFAULT_LOG_LEVEL tr = TerminalReporter(runner=runner, is_async=False , print_progress=not args.no_progress , check_threshold=loglevel , log_threshold=args.loglevel_messages or loglevel , usecolor=not args.no_colors , collect_results_by=args.gather_by , skip_status_report=None if args.show_sections\ else (STARTSECTION, ENDSECTION) ) reporters = [tr.receive] if args.json: sr = SerializeReporter(runner=runner, collect_results_by=args.gather_by) reporters.append(sr.receive) if args.ghmarkdown: mdr = GHMarkdownReporter(loglevels=args.loglevels, runner=runner, collect_results_by=args.gather_by) reporters.append(mdr.receive) if args.html: hr = HTMLReporter(loglevels=args.loglevels, runner=runner, collect_results_by=args.gather_by) reporters.append(hr.receive) distribute_generator(runner.run(), reporters) if args.json: import json json.dump(sr.getdoc(), args.json, sort_keys=True, indent=4) print("A report in JSON format has been" " saved to '{}'".format(args.json.name)) if args.ghmarkdown: args.ghmarkdown.write(mdr.get_markdown()) print("A report in GitHub Markdown format which can be useful\n" " for posting issues on a GitHub issue tracker has been\n" " saved to '{}'".format(args.ghmarkdown.name)) if args.html: args.html.write(hr.get_html()) print(f"A report in HTML format has been saved to '{args.html.name}'") # Fail and error let the command fail return 1 if tr.worst_check_status in (ERROR, FAIL) else 0
def main(profile=None, values=None): # profile can be injected by e.g. check-googlefonts injects it's own profile add_profile_arg = False if profile is None: profile = get_profile() add_profile_arg = True argument_parser, values_keys = ArgumentParser(profile, profile_arg=add_profile_arg) args = argument_parser.parse_args() # The default Windows Terminal just displays the escape codes. The argument # parser above therefore has these options disabled. if sys.platform == "win32": args.no_progress = True args.no_colors = True from fontbakery.constants import NO_COLORS_THEME, DARK_THEME, LIGHT_THEME if args.no_colors: theme = NO_COLORS_THEME else: if args.light_theme: theme = LIGHT_THEME elif args.dark_theme: theme = DARK_THEME elif sys.platform == "darwin": # The vast majority of MacOS users seem to use a light-background on the text terminal theme = LIGHT_THEME else: # For orther systems like GNU+Linux and Windows, a dark terminal seems to be more common. theme = DARK_THEME if args.list_checks: if args.loglevels == [PASS]: # if verbose: for section in profile._sections.values(): print(theme["list-checks: section"]("\nSection:") + " " + section.name) for check in section._checks: print(theme["list-checks: check-id"](check.id) + "\n" + theme["list-checks: description"] (f'"{check.description}"') + "\n") else: for section_name, section in profile._sections.items(): for check in section._checks: print(check.id) sys.exit() values_ = {} if values is not None: values_.update(values) # values_keys are returned by profile.setup_argparse # these are keys for custom arguments required by the profile. if values_keys: for key in values_keys: if hasattr(args, key): values_[key] = getattr(args, key) runner_kwds = dict(values=values_, custom_order=args.order, explicit_checks=args.checkid, exclude_checks=args.exclude_checkid) try: runner = CheckRunner(profile, **runner_kwds) except ValueValidationError as e: print(e) argument_parser.print_usage() sys.exit(1) is_async = args.multiprocessing != 0 # the most verbose loglevel wins loglevel = min(args.loglevels) if args.loglevels else DEFAULT_LOG_LEVEL tr = TerminalReporter(runner=runner, is_async=is_async , print_progress=not args.no_progress , succinct=args.succinct , check_threshold=loglevel , log_threshold=args.loglevel_messages or loglevel , theme=theme , collect_results_by=args.gather_by , skip_status_report=None if args.show_sections \ else (SECTIONSUMMARY, ) ) reporters = [tr.receive] if args.json: sr = SerializeReporter(runner=runner, collect_results_by=args.gather_by) reporters.append(sr.receive) if args.ghmarkdown: mdr = GHMarkdownReporter(loglevels=args.loglevels, runner=runner, collect_results_by=args.gather_by) reporters.append(mdr.receive) if args.html: hr = HTMLReporter(loglevels=args.loglevels, runner=runner, collect_results_by=args.gather_by) reporters.append(hr.receive) if args.multiprocessing == 0: status_generator = runner.run() else: status_generator = multiprocessing_runner(args.multiprocessing, runner, runner_kwds) distribute_generator(status_generator, reporters) if args.json: import json json.dump(sr.getdoc(), args.json, sort_keys=True, indent=4) print(f'A report in JSON format has been' f' saved to "{args.json.name}"') if args.ghmarkdown: args.ghmarkdown.write(mdr.get_markdown()) print(f'A report in GitHub Markdown format which can be useful\n' f' for posting issues on a GitHub issue tracker has been\n' f' saved to "{args.ghmarkdown.name}"') if args.html: args.html.write(hr.get_html()) print(f'A report in HTML format has been saved to "{args.html.name}"') # Fail and error let the command fail return 1 if tr.worst_check_status in (ERROR, FAIL) else 0
def main(specification=None, values=None): # specification can be injected by e.g. check-googlefonts injects it's own spec add_spec_arg = False if specification is None: specification = get_spec() add_spec_arg = True argument_parser, values_keys = ArgumentParser(specification, spec_arg=add_spec_arg) args = argument_parser.parse_args() if args.list_checks: print('Available checks') for section_name, section in specification._sections.items(): checks = section.list_checks() message = "# {}:\n {}".format(section_name, "\n ".join(checks)) print(message) sys.exit() values_ = {} if values is not None: values_.update(values) # values_keys are returned by specification.setup_argparse # these are keys for custom arguments required by the spec. if values_keys: for key in values_keys: if hasattr(args, key): values_[key] = getattr(args, key) try: runner = runner_factory(specification, explicit_checks=args.checkid, exclude_checks=args.exclude_checkid, custom_order=args.order, values=values_) except ValueValidationError as e: print(e) argument_parser.print_usage() sys.exit(1) # The default Windows Terminal just displays the escape codes. The argument # parser above therefore has these options disabled. if sys.platform == "win32": args.no_progress = True args.no_colors = True # the most verbose loglevel wins loglevel = min(args.loglevels) if args.loglevels else DEFAULT_LOG_LEVEL tr = TerminalReporter(runner=runner, is_async=False , print_progress=not args.no_progress , check_threshold=loglevel , log_threshold=args.loglevel_messages or loglevel , usecolor=not args.no_colors , collect_results_by=args.gather_by , skip_status_report=None if args.show_sections\ else (STARTSECTION, ENDSECTION) ) reporters = [tr.receive] if args.json: sr = SerializeReporter(runner=runner, collect_results_by=args.gather_by) reporters.append(sr.receive) if args.ghmarkdown: mdr = GHMarkdownReporter(loglevels=args.loglevels, runner=runner, collect_results_by=args.gather_by) reporters.append(mdr.receive) distribute_generator(runner.run(), reporters) if args.json: import json json.dump(sr.getdoc(), args.json, sort_keys=True, indent=4) if args.ghmarkdown: args.ghmarkdown.write(mdr.get_markdown()) # Fail and error let the command fail return 1 if tr.worst_check_status in (ERROR, FAIL) else 0
def main(specification=None, values=None): # specification can be injected by e.g. check-googlefonts injects it's own spec add_spec_arg = False if specification is None: specification = get_spec() add_spec_arg = True argument_parser, values_keys = ArgumentParser(specification, spec_arg=add_spec_arg) args = argument_parser.parse_args() if args.list_checks: print('Available checks') for section_name, section in specification._sections.items(): checks = section.list_checks() message = "# {}:\n {}".format(section_name,"\n ".join(checks)) print(message) sys.exit() values_ = {} if values is not None: values_.update(values) # values_keys are returned by specification.setup_argparse # these are keys for custom arguments required by the spec. if values_keys: for key in values_keys: if hasattr(args, key): values_[key] = getattr(args, key) try: runner = runner_factory(specification , explicit_checks=args.checkid , custom_order=args.order , values=values_ ) except ValueValidationError as e: print(e) argument_parser.print_usage() sys.exit(1) # the most verbose loglevel wins loglevel = min(args.loglevels) if args.loglevels else DEFAULT_LOG_LEVEL tr = TerminalReporter(runner=runner, is_async=False , print_progress=not args.no_progress , check_threshold=loglevel , log_threshold=args.loglevel_messages or loglevel , usecolor=not args.no_colors , collect_results_by=args.gather_by , skip_status_report=None if args.show_sections\ else (STARTSECTION, ENDSECTION) ) reporters = [tr.receive] if args.json: sr = SerializeReporter(runner=runner, collect_results_by=args.gather_by) reporters.append(sr.receive) if args.ghmarkdown: mdr = GHMarkdownReporter(loglevels=args.loglevels, runner=runner, collect_results_by=args.gather_by) reporters.append(mdr.receive) distribute_generator(runner.run(), reporters) if args.json: import json json.dump(sr.getdoc(), args.json, sort_keys=True, indent=4) if args.ghmarkdown: args.ghmarkdown.write(mdr.get_markdown()) # Fail and error let the command fail return 1 if tr.worst_check_status in (ERROR, FAIL) else 0