diff --git a/Lib/fontbakery/checks/fontval.py b/Lib/fontbakery/checks/fontval.py index 58c452ce94..b00562c428 100644 --- a/Lib/fontbakery/checks/fontval.py +++ b/Lib/fontbakery/checks/fontval.py @@ -22,7 +22,7 @@ def com_google_fonts_check_fontvalidator(font, config): try: import lxml.etree except ImportError: - exit_with_install_instructions() + exit_with_install_instructions("fontval") check_config = config.get("com.google.fonts/check/fontvalidator", {}) enabled_checks = check_config.get("enabled_checks") diff --git a/Lib/fontbakery/checks/googlefonts/__init__.py b/Lib/fontbakery/checks/googlefonts/__init__.py index 550d00404e..5b7738ad57 100644 --- a/Lib/fontbakery/checks/googlefonts/__init__.py +++ b/Lib/fontbakery/checks/googlefonts/__init__.py @@ -30,7 +30,7 @@ def com_google_fonts_check_canonical_filename(ttFont): try: import axisregistry except ImportError: - exit_with_install_instructions() + exit_with_install_instructions("googlefonts") current_filename = os.path.basename(ttFont.reader.file.name) expected_filename = axisregistry.build_filename(ttFont) diff --git a/Lib/fontbakery/checks/googlefonts/conditions.py b/Lib/fontbakery/checks/googlefonts/conditions.py index 49791fa737..5726931f75 100644 --- a/Lib/fontbakery/checks/googlefonts/conditions.py +++ b/Lib/fontbakery/checks/googlefonts/conditions.py @@ -157,7 +157,7 @@ def family_metadata(font): try: from google.protobuf import text_format except ImportError: - exit_with_install_instructions() + exit_with_install_instructions("googlefonts") from fontbakery.utils import get_FamilyProto_Message diff --git a/Lib/fontbakery/checks/googlefonts/description.py b/Lib/fontbakery/checks/googlefonts/description.py index 1169718647..b2e894c2d2 100644 --- a/Lib/fontbakery/checks/googlefonts/description.py +++ b/Lib/fontbakery/checks/googlefonts/description.py @@ -20,7 +20,7 @@ def description_html(font): try: from lxml import etree except ImportError: - exit_with_install_instructions() + exit_with_install_instructions("googlefonts") if not font.description: return @@ -295,7 +295,7 @@ def com_google_fonts_check_description_valid_html(descfile, description): try: from lxml import html except ImportError: - exit_with_install_instructions() + exit_with_install_instructions("googlefonts") passed = True if "" in description or "" in description: diff --git a/Lib/fontbakery/checks/googlefonts/glyphset.py b/Lib/fontbakery/checks/googlefonts/glyphset.py index 4b779d13dc..05a959ac70 100644 --- a/Lib/fontbakery/checks/googlefonts/glyphset.py +++ b/Lib/fontbakery/checks/googlefonts/glyphset.py @@ -353,7 +353,7 @@ def can_shape(ttFont, text, parameters=None): try: from vharfbuzz import Vharfbuzz except ImportError: - exit_with_install_instructions() + exit_with_install_instructions("googlefonts") filename = ttFont.reader.file.name vharfbuzz = Vharfbuzz(filename) diff --git a/Lib/fontbakery/checks/googlefonts/metadata.py b/Lib/fontbakery/checks/googlefonts/metadata.py index 70c58da250..3979d787f1 100644 --- a/Lib/fontbakery/checks/googlefonts/metadata.py +++ b/Lib/fontbakery/checks/googlefonts/metadata.py @@ -22,7 +22,7 @@ def com_google_fonts_check_metadata_parses(family_directory): from google.protobuf import text_format from fontbakery.utils import get_FamilyProto_Message except ImportError: - exit_with_install_instructions() + exit_with_install_instructions("googlefonts") try: pb_file = os.path.join(family_directory, "METADATA.pb") @@ -1683,7 +1683,7 @@ def com_google_fonts_check_metadata_can_render_samples(ttFont, family_metadata): try: from gflanguages import LoadLanguages except ImportError: - exit_with_install_instructions() + exit_with_install_instructions("googlefonts") passed = True languages = LoadLanguages() diff --git a/Lib/fontbakery/checks/googlefonts/os2.py b/Lib/fontbakery/checks/googlefonts/os2.py index cc55a534b6..677b1af85d 100644 --- a/Lib/fontbakery/checks/googlefonts/os2.py +++ b/Lib/fontbakery/checks/googlefonts/os2.py @@ -14,7 +14,7 @@ def registered_vendor_ids(): try: from bs4 import BeautifulSoup, NavigableString except ImportError: - exit_with_install_instructions() + exit_with_install_instructions("googlefonts") registered_vendor_ids = {} CACHED = resource_filename( diff --git a/Lib/fontbakery/checks/googlefonts/subsets.py b/Lib/fontbakery/checks/googlefonts/subsets.py index 4055da2789..7977ff3823 100644 --- a/Lib/fontbakery/checks/googlefonts/subsets.py +++ b/Lib/fontbakery/checks/googlefonts/subsets.py @@ -24,7 +24,7 @@ def com_google_fonts_check_metadata_unsupported_subsets( try: from gfsubsets import CodepointsInSubset, ListSubsets except ImportError: - exit_with_install_instructions() + exit_with_install_instructions("googlefonts") passed = True for subset in family_metadata.subsets: @@ -78,7 +78,7 @@ def com_google_fonts_check_metadata_unreachable_subsetting(font, config): import unicodedata2 from gfsubsets import CodepointsInSubset, ListSubsets, SubsetsInFont except ImportError: - exit_with_install_instructions() + exit_with_install_instructions("googlefonts") from fontbakery.utils import pretty_print_list diff --git a/Lib/fontbakery/checks/googlefonts/varfont.py b/Lib/fontbakery/checks/googlefonts/varfont.py index f6089c6b26..76ae45568a 100644 --- a/Lib/fontbakery/checks/googlefonts/varfont.py +++ b/Lib/fontbakery/checks/googlefonts/varfont.py @@ -610,7 +610,7 @@ def uharfbuzz_blob(font): try: import uharfbuzz as hb except ImportError: - exit_with_install_instructions() + exit_with_install_instructions("googlefonts") return hb.Blob.from_file_path(font.file) @@ -635,7 +635,7 @@ def com_google_fonts_check_slant_direction(ttFont, uharfbuzz_blob): try: import uharfbuzz as hb except ImportError: - exit_with_install_instructions() + exit_with_install_instructions("googlefonts") from fontbakery.utils import PointsPen, axis diff --git a/Lib/fontbakery/checks/iso15008.py b/Lib/fontbakery/checks/iso15008.py index 2023560c52..75d89f9e0c 100644 --- a/Lib/fontbakery/checks/iso15008.py +++ b/Lib/fontbakery/checks/iso15008.py @@ -53,7 +53,7 @@ def pair_kerning(font, left, right): try: import uharfbuzz as hb except ImportError: - exit_with_install_instructions() + exit_with_install_instructions("iso15008") with open(font.file, "rb") as fontfile: fontdata = fontfile.read() diff --git a/Lib/fontbakery/checks/shaping.py b/Lib/fontbakery/checks/shaping.py index 1da2c9b0e8..e6f2677655 100644 --- a/Lib/fontbakery/checks/shaping.py +++ b/Lib/fontbakery/checks/shaping.py @@ -117,7 +117,7 @@ def run_a_set_of_shaping_tests( filename = Path(ttFont.reader.file.name) vharfbuzz = Vharfbuzz(filename) except ImportError: - exit_with_install_instructions() + exit_with_install_instructions("shaping") shaping_file_found = False ran_a_test = False @@ -368,7 +368,7 @@ def setup_glyph_collides(ttFont, configuration): try: from collidoscope import Collidoscope except ImportError: - exit_with_install_instructions() + exit_with_install_instructions("shaping") filename = Path(ttFont.reader.file.name) collidoscope_configuration = configuration.get("collidoscope") @@ -393,7 +393,7 @@ def run_collides_glyph_test( try: from stringbrewer import StringBrewer except ImportError: - exit_with_install_instructions() + exit_with_install_instructions("shaping") col = extra_data["collidoscope"] is_stringbrewer = ( @@ -448,7 +448,7 @@ def is_complex_shaper_font(ttFont): try: from ufo2ft.constants import INDIC_SCRIPTS, USE_SCRIPTS except ImportError: - exit_with_install_instructions() + exit_with_install_instructions("shaping") for table in ["GSUB", "GPOS"]: if table not in ttFont: @@ -576,7 +576,7 @@ def com_google_fonts_check_soft_dotted(ttFont): try: from vharfbuzz import Vharfbuzz except ImportError: - exit_with_install_instructions() + exit_with_install_instructions("shaping") import itertools from beziers.path import BezierPath diff --git a/Lib/fontbakery/checks/typenetwork.py b/Lib/fontbakery/checks/typenetwork.py index 89da4be796..f7a9576fce 100644 --- a/Lib/fontbakery/checks/typenetwork.py +++ b/Lib/fontbakery/checks/typenetwork.py @@ -33,7 +33,7 @@ def com_typenetwork_glyph_coverage(ttFont, font_codepoints, config): try: import unicodedata2 except ImportError: - exit_with_install_instructions() + exit_with_install_instructions("typenetwork") TN_latin_set = { 0x0020: (" ", "SPACE"), diff --git a/Lib/fontbakery/checks/ufo.py b/Lib/fontbakery/checks/ufo.py index f23530b22a..03659fec19 100644 --- a/Lib/fontbakery/checks/ufo.py +++ b/Lib/fontbakery/checks/ufo.py @@ -20,7 +20,7 @@ def ufo_font(ufo): from fontTools.ufoLib.errors import UFOLibError import defcon except ImportError: - exit_with_install_instructions() + exit_with_install_instructions("ufo-sources") try: return defcon.Font(ufo.file) @@ -40,7 +40,7 @@ def designSpace(designspace): from fontTools.designspaceLib import DesignSpaceDocument import defcon except ImportError: - exit_with_install_instructions() + exit_with_install_instructions("ufo-sources") if designspace: DS = DesignSpaceDocument.fromfile(designspace.file) @@ -57,7 +57,7 @@ def designspace_sources(designspace): try: import defcon except ImportError: - exit_with_install_instructions() + exit_with_install_instructions("ufo-sources") if designspace.designSpace: return designspace.designSpace.loadSourceFonts(defcon.Font) diff --git a/Lib/fontbakery/utils.py b/Lib/fontbakery/utils.py index 2dcea3fe68..d59917178e 100644 --- a/Lib/fontbakery/utils.py +++ b/Lib/fontbakery/utils.py @@ -24,15 +24,8 @@ from fontbakery.constants import NO_COLORS_THEME, DARK_THEME, LIGHT_THEME -profile_name = None - -def set_profile_name(name): - global profile_name # pylint:disable=W0603 (global-statement) - profile_name = name - - -def exit_with_install_instructions(): +def exit_with_install_instructions(profile_name): sys.exit( f"\nTo run the {profile_name} profile, one needs to install\n" f"fontbakery with the '{profile_name}' extra, like this:\n\n" @@ -311,7 +304,7 @@ def get_Protobuf_Message(klass, path): try: from google.protobuf import text_format except ImportError: - exit_with_install_instructions() + exit_with_install_instructions("googlefonts") message = klass() text_data = open(path, "rb").read() @@ -323,7 +316,7 @@ def get_FamilyProto_Message(path): try: from fontbakery.fonts_public_pb2 import FamilyProto except ImportError: - exit_with_install_instructions() + exit_with_install_instructions("googlefonts") return get_Protobuf_Message(FamilyProto, path) @@ -333,7 +326,7 @@ def get_DesignerInfoProto_Message(text_data): from fontbakery.designers_pb2 import DesignerInfoProto from google.protobuf import text_format except ImportError: - exit_with_install_instructions() + exit_with_install_instructions("googlefonts") message = DesignerInfoProto() text_format.Merge(text_data, message) diff --git a/tests/test_utils.py b/tests/test_utils.py index 3b6030f950..e7cb1e0af6 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -23,12 +23,9 @@ def test_exit_with_install_instructions(): - from fontbakery.utils import set_profile_name - profile_name = "test-profile" - set_profile_name(profile_name) with patch("sys.exit") as mock_exit: - exit_with_install_instructions() + exit_with_install_instructions(profile_name) mock_exit.assert_called_with( f"\nTo run the {profile_name} profile, one needs to install\n" f"fontbakery with the '{profile_name}' extra, like this:\n\n"