Skip to content

Commit

Permalink
Update to latest API
Browse files Browse the repository at this point in the history
  • Loading branch information
simoncozens committed Feb 14, 2024
1 parent d48e258 commit 7d78062
Showing 1 changed file with 5 additions and 60 deletions.
65 changes: 5 additions & 60 deletions fbwebapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import unicodedata
import json


sys.modules["unicodedata2"] = sys.modules["unicodedata"]
for notreal in [
"cmarkgfm",
Expand All @@ -27,16 +28,13 @@

import glyphsets

import argparse
from fontbakery.commands.check_profile import get_module, log_levels
from fontbakery.fonts_profile import profile_factory, setup_context
from fontbakery.reporters.serialize import SerializeReporter
from fontbakery.checkrunner import (
CheckRunner,
)
import fontbakery
import pkgutil
from importlib import import_module
import re


class ProgressReporter(SerializeReporter):
Expand Down Expand Up @@ -73,24 +71,11 @@ def run_fontbakery(
full_lists=False,
):
loglevels = [log_levels[loglevels]]
profile = import_module("fontbakery.profiles." + profilename).profile
argument_parser = argparse.ArgumentParser()
# Hack
argument_parser.add_argument(
"--list-checks",
default=False,
action="store_true",
help="List the checks available in the selected profile.",
)
values_keys = profile.setup_argparse(argument_parser)
args = argument_parser.parse_args(paths)
values = {}
for key in values_keys:
if hasattr(args, key):
values[key] = getattr(args, key)
profile = profile_factory(import_module("fontbakery.profiles." + profilename))
context = setup_context(paths)
runner = CheckRunner(
profile,
values=values,
context,
config={
"custom_order": None,
"explicit_checks": checks,
Expand All @@ -102,43 +87,3 @@ def run_fontbakery(
prog.runner = runner
reporters = [prog]
runner.run(reporters)


def dump_all_the_checks():
checks = {}
profiles_modules = [
x.name
for x in pkgutil.walk_packages(fontbakery.__path__, "fontbakery.")
if x.name.startswith("fontbakery.profiles")
]
for profile_name in profiles_modules:
try:
imported = import_module(profile_name, package=None)
profile = imported.profile
except BaseException:
continue
if not profile:
continue
profile_name = profile_name[20:]
for section in profile._sections.values():
for check in section._checks:
if check.id not in checks:
checks[check.id] = {
"sections": set(),
"profiles": set(),
}
checks[check.id]["sections"].add(section.name)
checks[check.id]["profiles"].add(profile_name)
for attr in ["proposal", "rationale", "severity", "description"]:
if getattr(check, attr):
md = getattr(check, attr)
if attr == "rationale":
md = re.sub(r"(?m)^\s+", "", md)
checks[check.id][attr] = md
else:
checks[check.id][attr] = md

for ck in checks.values():
ck["sections"] = list(ck["sections"])
ck["profiles"] = list(ck["profiles"])
return checks

0 comments on commit 7d78062

Please sign in to comment.