def __init__(self, module_or_profile, check_id): self.profile = module_or_profile \ if isinstance(module_or_profile, Profile) \ else get_module_profile(module_or_profile) self.check_id = check_id self.check_identity = None self.check_section = None self.check = None self.check_iterargs = None self._args = None
def get_profile(): """ Prefetch the profile module, to fill some holes in the help text. """ argument_parser, _ = ArgumentParser(Profile(), profile_arg=True) # monkey patching will do here def error(message): raise ArgumentParserError(message) argument_parser.error = error try: args, _ = argument_parser.parse_known_args() except ArgumentParserError: # silently fails, the main parser will show usage string. return Profile() imported = get_module(args.profile) profile = get_module_profile(imported) if not profile: raise Exception(f"Can't get a profile from {imported}.") return profile
def __init__(self, profile): super().__init__() imported = import_module("fontbakery.profiles."+profile) profile = get_module_profile(imported) self.setMaxVisibleItems(10) self.setStyleSheet("combobox-popup: 0;") self.profile = profile for _, section in profile._sections.items(): self.addItem(section.name) item = self.model().item(self.count()-1,0) font = QFont() font.setBold(True) item.setFont(font) item.setFlags(item.flags() & ~Qt.ItemIsSelectable) item.setCheckState(Qt.Unchecked) for check in section._checks: self.addItem(check.description,userData = check.id) item = self.model().item(self.count()-1,0) item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled) item.setCheckState(Qt.Checked)
def get_profile_from_module_locator(module_locator): module = _get_module_from_locator(module_locator) return get_module_profile(module)