<commit_before>#!/usr/bin/env AFDKOPython
# encoding: UTF-8
from __future__ import division, absolute_import, print_function, unicode_literals

import os, subprocess
import defcon, mutatorMath.ufo.document
import hindkit as kit

class Family(object):

    def __init__(
        self,
        name = None,
        trademark = None,
        name_stem = None,
        script_name = None,
        append_script_name = False,
        client_name = None,
        variant_tag = None,
        initial_release_year = None,
    ):

        self.trademark = trademark
        self.name_stem = kit.fallback(name_stem, self.trademark)
        self.script = kit.constants.SCRIPT_NAMES_TO_SCRIPTS.get(script_name)
        if name:
            self.name = name
        else:
            self.name = self.name_stem
            if script_name and append_script_name:
                self.name += ' ' + script_name
        self.name_postscript = self.name.replace(' ', '')

        self.masters = None
        self.styles = None

        self.info = defcon.Font().info

        self.client_name = client_name
        self.variant_tag = variant_tag
        self.initial_release_year = initial_release_year

    def get_client_data(self):
        return kit.Client(self, self.client_name)

    def set_masters(self, value=None):
        scheme = kit.fallback(value, [('Light', 0), ('Bold',  100)])
        self.masters = [
            kit.Master(self, name, weight_location)
            for name, weight_location in scheme
        ]

    def set_styles(self, value=None):
        scheme = kit.fallback(value, self.get_client_data().style_scheme)
        self.styles = [
            kit.Style(self, name, weight_location, weight_class)
            for name, weight_location, weight_class in scheme
        ]
        if self.masters is None:
            self.set_masters((i.name, i.weight_location) for i in self.styles)
        for master in self.masters:
            for style in self.styles:
                if style.weight_location == master.weight_location:
                    style.master = master
                    break

    def _has_kerning(self):
        raise NotImplementedError()

    def _has_mark_positioning(self):
        raise NotImplementedError()

    def _has_mI_variants(self):
        raise NotImplementedError()

    def prepare_styles(self):

        p = self.project
        styles = [i.style for i in p.products if not i.incidental]
        for style in styles:
            style.temp = True
            kit.makedirs(style.directory)

        if p.options['run_makeinstances']:
            self.generate_styles()
        else:
            for style in styles:
                kit.copy(style.master.path, style.path)
                style.open().info.postscriptFontName = style.full_name_postscript
                style.dirty = True
                if style.file_format == "UFO":
                    style.open().info.postscriptFontName = style.full_name_postscript
                    style.dirty = True

        for style in styles:
            try:
                style.postprocess()
            except AttributeError:
                pass
            else:
                style.dirty = True
            style.save_temp()

    def generate_styles(self):

        p = self.project
        p.designspace.prepare()

        arguments = ['-d', p.designspace.path]
        if not p.options['run_checkoutlines']:
            arguments.append('-c')
        if not p.options['run_autohint']:
            arguments.append('-a')

        subprocess.call(['makeInstancesUFO'] + arguments)


class DesignSpace(kit.BaseFile):

    def __init__(self, project, name='font'):<commit_msg>Check override for styles<commit_after>#!/usr/bin/env AFDKOPython
# encoding: UTF-8
from __future__ import division, absolute_import, print_function, unicode_literals

import os, subprocess
import defcon, mutatorMath.ufo.document
import hindkit as kit

class Family(object):

    def __init__(
        self,
        name = None,
        trademark = None,
        name_stem = None,
        script_name = None,
        append_script_name = False,
        client_name = None,
        variant_tag = None,
        initial_release_year = None,
    ):

        self.trademark = trademark
        self.name_stem = kit.fallback(name_stem, self.trademark)
        self.script = kit.constants.SCRIPT_NAMES_TO_SCRIPTS.get(script_name)
        if name:
            self.name = name
        else:
            self.name = self.name_stem
            if script_name and append_script_name:
                self.name += ' ' + script_name
        self.name_postscript = self.name.replace(' ', '')

        self.masters = None
        self.styles = None

        self.info = defcon.Font().info

        self.client_name = client_name
        self.variant_tag = variant_tag
        self.initial_release_year = initial_release_year

    def get_client_data(self):
        return kit.Client(self, self.client_name)

    def set_masters(self, value=None):
        scheme = kit.fallback(value, [('Light', 0), ('Bold',  100)])
        self.masters = [
            kit.Master(self, name, weight_location)
            for name, weight_location in scheme
        ]

    def set_styles(self, value=None):
        scheme = kit.fallback(value, self.get_client_data().style_scheme)
        self.styles = [
            kit.Style(self, name, weight_location, weight_class)
            for name, weight_location, weight_class in scheme
        ]
        if self.masters is None:
            self.set_masters((i.name, i.weight_location) for i in self.styles)
        for master in self.masters:
            for style in self.styles:
                if style.weight_location == master.weight_location:
                    style.master = master
                    break

    def _has_kerning(self):
        raise NotImplementedError()

    def _has_mark_positioning(self):
        raise NotImplementedError()

    def _has_mI_variants(self):
        raise NotImplementedError()

    def prepare_styles(self):

        p = self.project
        styles = [i.style for i in p.products if not i.incidental]
        for style in styles:
            kit.makedirs(style.directory)

        if p.options['run_makeinstances']:
            for style in styles:
                style.temp = True
            self.generate_styles()
        else:
            for style in styles:
                if os.path.exists(style.master.path):
                    style.temp = True
                    kit.copy(style.master.path, style.path)
                else:
                    style.check_override()
                if style.file_format == "UFO":
                    style.open().info.postscriptFontName = style.full_name_postscript
                    style.dirty = True

        for style in styles:
            try:
                style.postprocess()
            except AttributeError:
                pass
            else:
                style.dirty = True
            style.save_temp()

    def generate_styles(self):

        p = self.project
        p.designspace.prepare()

        arguments = ['-d', p.designspace.path]
        if not p.options['run_checkoutlines']:
            arguments.append('-c')
        if not p.options['run_autohint']:
            arguments.append('-a')

        subprocess.call(['makeInstancesUFO'] + arguments)


class DesignSpace(kit.BaseFile):

    def __init__(self, project, name='font'):
{'fraction_non_alphanumeric': 0.09076283684139966, 'fraction_numerical': 0.001340662287169862, 'mean_word_length': 1.9027237354085602, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3370675', 'n_tokens_mistral': 2168, 'n_tokens_neox': 2078, 'n_words': 468}