<commit_before># coding: utf-8
# Copyright 2013 The Font Bakery Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# See AUTHORS.txt for the list of Authors and LICENSE.txt for the License.
import fnmatch
import os

from fontcrunch import fontcrunch

from bakery_cli.utils import shutil


class FontCrunch(object):

    def __init__(self, bakery):
        self.project_root = bakery.project_root
        self.builddir = bakery.build_dir
        self.bakery = bakery

    def run(self, pipedata):
        if not pipedata.get('fontcrunch'):
            return  # run fontcrunch only if user set flag in config

        from bakery_cli.utils import ProcessedFile
        filename = ProcessedFile()
        
        filename = os.path.join(self.builddir, filename)
        self.bakery.logging_raw('### Fontcrunch {}\n'.format(filename))

        fontcrunch.optimize(filename, '{}.crunched'.format(filename))
        shutil.move('{}.crunched'.format(filename), filename)
        return 1

    def execute(self, pipedata):
        if not pipedata.get('fontcrunch'):
            return  # run fontcrunch only if user set flag in config

        self.bakery.logging_task('Fontcrunch TTF')
        if self.bakery.forcerun:
            return

        for filename in [os.path.join(self.builddir, x) \
                         for x in pipedata['bin_files']]:
            self.run(filename, pipedata)<commit_msg>fontcrunch must be optional import<commit_after># coding: utf-8
# Copyright 2013 The Font Bakery Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# See AUTHORS.txt for the list of Authors and LICENSE.txt for the License.
import fnmatch
import os

from bakery_cli.utils import shutil


class FontCrunch(object):

    def __init__(self, bakery):
        self.project_root = bakery.project_root
        self.builddir = bakery.build_dir
        self.bakery = bakery

    def run(self, pipedata):
        try:
            from fontcrunch import fontcrunch
        except ImportError:
            self.bakery.logging_raw('Fontcruch is not installed. Please `pip install fontcrunch`')
            return

        if not pipedata.get('fontcrunch'):
            return  # run fontcrunch only if user set flag in config

        from bakery_cli.utils import ProcessedFile
        filename = ProcessedFile()
        
        filename = os.path.join(self.builddir, filename)
        self.bakery.logging_raw('### Fontcrunch {}\n'.format(filename))

        fontcrunch.optimize(filename, '{}.crunched'.format(filename))
        shutil.move('{}.crunched'.format(filename), filename)
        return 1

    def execute(self, pipedata):
        try:
            from fontcrunch import fontcrunch
        except ImportError:
            self.bakery.logging_raw('Fontcruch is not installed. Please `pip install fontcrunch`')
            return
            
        if not pipedata.get('fontcrunch'):
            return  # run fontcrunch only if user set flag in config

        self.bakery.logging_task('Fontcrunch TTF')
        if self.bakery.forcerun:
            return

        for filename in [os.path.join(self.builddir, x) \
                         for x in pipedata['bin_files']]:
            self.run(filename, pipedata)
{'fraction_non_alphanumeric': 0.08247422680412371, 'fraction_numerical': 0.004686035613870665, 'mean_word_length': 2.7381786339754814, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6061854', 'n_tokens_mistral': 1222, 'n_tokens_neox': 1173, 'n_words': 413}