コード例 #1
0
ファイル: test_bakery.py プロジェクト: davelab6/fontbakery
    def test_copy_with_splitted_ttx(self):
        pipedata = {
            'process_files': ['1.in/fontname-bold.ttx'],
            'builddir': 'build',
            'project_root': ''
        }

        b = Bakery('/home/user', 'project', 'out', 'build')

        b = Copy(b)
        with patch.object(b, 'copy_to_builddir') as copy2builddir:
            with patch.object(b, 'lookup_splitted_ttx') as splitted_ttx:
                with patch.object(b, 'create_source_dir') as mock_create_src:
                    mock_create_src.return_value = 'sources'
                    with patch.object(b, 'copy_helper_files') as mock_copyhf:
                        splitted_ttx.return_value = [
                            '1.in/fontname-bold._g_p_o_s.ttx'
                        ]

                        pipedata = b.execute(pipedata)

                        copy2builddir.assert_called_once_with([
                            '1.in/fontname-bold.ttx',
                            '1.in/fontname-bold._g_p_o_s.ttx'
                        ], 'sources')
                        self.assertEqual(pipedata['process_files'],
                                         ['sources/fontname-bold.ttx'])
                        self.assert_(mock_create_src.called)
                        self.assert_(mock_copyhf.called)
コード例 #2
0
ファイル: fontbakery.py プロジェクト: lowks/fontbakery-cli
def run_bakery(sourcedir, config=None):

    try:
        if config:
            config = yaml.safe_load(open(config, 'r'))
        else:
            config = yaml.safe_load(open(BAKERY_CONFIGURATION_DEFAULTS))

        if 'process_files' not in config:
            directory = UpstreamDirectory(sourcedir)
            config['process_files'] = directory.get_fonts()

        bakeryyaml = os.path.abspath(os.path.join(sourcedir, '.bakery.yaml'))
        l = open(bakeryyaml, 'w')
        l.write(yaml.safe_dump(config))
        l.close()

        b = Bakery('', sourcedir, 'builds', sourcedir)

        b.init_logging('%s.process.log' % sourcedir.replace('/', '-'))

        b.pipes = [
            pipe.Copy, pipe.Build, pipe.Rename, pipe.Metadata, pipe.PyFtSubset,
            pipe.FontLint, pipe.Optimize, pipe.AutoFix, pipe.CopyLicense,
            pipe.CopyFontLog, pipe.CopyDescription, pipe.CopyMetadata,
            pipe.CopyTxtFiles, pipe.TTFAutoHint, pipe.PyFontaine
        ]

        config = os.path.join(sourcedir, '.bakery.yaml')
        b.load_config(config)

        b.run()
    except Exception, ex:
        print >> sys.stderr, 'FAILED: %s' % sourcedir
        print >> sys.stderr, ex
コード例 #3
0
ファイル: test_bakery.py プロジェクト: adrientetar/fontbakery
    def test_convert(self):
        pipedata = {'process_files': ['sources/fontname-bold.ttx',
                                      'sources/fontname-regular.ttx']}

        b = Bakery('/home/user', 'project', 'out', 'build')

        b = Build(b)
        with patch('bakery_cli.utils.UpstreamDirectory.get_ttx') as ttx:
            ttx.return_value = ['Font-Regular.ttx']
            with patch.object(b, 'execute_ttx') as execttx:
                b.execute(pipedata)
                execttx.assert_called_once_with(['sources/Font-Regular.ttx'], {'process_files': ['sources/fontname-bold.ttx', 'sources/fontname-regular.ttx']})
コード例 #4
0
ファイル: test_bakery.py プロジェクト: adrientetar/fontbakery
    def test_copy_process(self):
        pipedata = {'process_files': ['1.in/fontname-bold.ttx'],
                    'builddir': 'build',
                    'project_root': ''}

        b = Bakery('/home/user', 'project', 'out', 'build')

        b = Copy(b)
        with patch.object(b, 'copy_to_builddir') as mock_copy2builddir:
            with patch.object(b, 'create_source_dir') as mock_create_src:
                mock_create_src.return_value = 'sources'
                with patch.object(b, 'copy_helper_files') as mock_copyhf:
                    pipedata = b.execute(pipedata)

                    mock_copy2builddir.assert_called_once_with(['1.in/fontname-bold.ttx'], 'sources')
                    self.assertEqual(pipedata['process_files'], ['sources/fontname-bold.ttx'])
                    self.assert_(mock_copyhf.called)
                    self.assert_(mock_create_src.called)
コード例 #5
0
def run_bakery(path, verbose=False):
    # fontbakery-build supports passing arguments of directory or
    # concrete bakery.y[a]ml files. In case of passing directory
    # it looks at existing bakery.yml or bakery.yaml and runs on
    # first matched filepath

    # There can also be cases when directory does not contain any
    # bakery.y[a]ml or passed bakery.yml file does not exist. Then
    # fontbakery-build loads default configuration.
    bakery_yml_file = None
    sourcedir = path

    if os.path.isdir(path):
        for filename in ['bakery.yml', 'bakery.yaml']:
            if os.path.exists(os.path.join(path, filename)):
                bakery_yml_file = os.path.join(path, filename)
                break
    else:
        bakery_yml_file = path
        sourcedir = os.path.dirname(path)

    try:
        if bakery_yml_file:
            config = yaml.safe_load(open(bakery_yml_file, 'r'))
        else:
            raise IOError
    except IOError:
        bakery_yml_file = os.path.join(sourcedir, 'bakery.yml')
        config = yaml.safe_load(open(BAKERY_CONFIGURATION_DEFAULTS))

    try:
        builddir = 'build'
        if GITPYTHON_INSTALLED:
            try:
                repo = Repo(sourcedir)
                builddir = repo.git.rev_parse('HEAD', short=True)
            except git.exc.InvalidGitRepositoryError:
                pass
        builddir = os.environ.get('TRAVIS_COMMIT', builddir)

        if 'process_files' not in config:
            directory = UpstreamDirectory(sourcedir)
            # normalize process_files path
            config['process_files'] = directory.get_fonts()

        create_bakery_config(bakery_yml_file, config)

        Bakery.verbose = verbose or config.get('verbose')

        b = Bakery('', sourcedir, 'builds', builddir)
        b.addLoggingToFile()
        b.load_config(bakery_yml_file)
        b.run()
    except:
        if verbose or config.get('verbose'):
            raise
        sys.exit(1)
コード例 #6
0
ファイル: test_bakery.py プロジェクト: davelab6/fontbakery
    def test_convert(self):
        pipedata = {
            'process_files':
            ['sources/fontname-bold.ttx', 'sources/fontname-regular.ttx']
        }

        b = Bakery('/home/user', 'project', 'out', 'build')

        b = Build(b)
        with patch('bakery_cli.utils.UpstreamDirectory.get_ttx') as ttx:
            ttx.return_value = ['Font-Regular.ttx']
            with patch.object(b, 'execute_ttx') as execttx:
                b.execute(pipedata)
                execttx.assert_called_once_with(
                    ['sources/Font-Regular.ttx'], {
                        'process_files': [
                            'sources/fontname-bold.ttx',
                            'sources/fontname-regular.ttx'
                        ]
                    })
コード例 #7
0
def run_bakery(bakery_yml_file, verbose=False):
    try:
        config = yaml.safe_load(open(op.join(bakery_yml_file), 'r'))
    except IOError:
        config = yaml.safe_load(open(BAKERY_CONFIGURATION_DEFAULTS))

    sourcedir = op.dirname(bakery_yml_file)
    try:
        builddir = 'build'
        if GITPYTHON_INSTALLED:
            try:
                repo = Repo(sourcedir)
                builddir = repo.git.rev_parse('HEAD', short=True)
            except git.exc.InvalidGitRepositoryError:
                pass
        builddir = os.environ.get('TRAVIS_COMMIT', builddir)

        if 'process_files' not in config:
            directory = UpstreamDirectory(sourcedir)
            # normalize process_files path
            config['process_files'] = directory.get_fonts()

        create_bakery_config(bakery_yml_file, config)

        b = Bakery('', sourcedir, 'builds', builddir)
        b.load_config(bakery_yml_file)
        b.run()
    except:
        if verbose or config.get('verbose'):
            raise
        sys.exit(1)
コード例 #8
0
ファイル: fontbakery.py プロジェクト: lowks/fontbakery-cli
def run_bakery(sourcedir, config=None):

    try:
        if config:
            config = yaml.safe_load(open(config, 'r'))
        else:
            config = yaml.safe_load(open(BAKERY_CONFIGURATION_DEFAULTS))

        if 'process_files' not in config:
            directory = UpstreamDirectory(sourcedir)
            config['process_files'] = directory.get_fonts()

        bakeryyaml = os.path.abspath(os.path.join(sourcedir, '.bakery.yaml'))
        l = open(bakeryyaml, 'w')
        l.write(yaml.safe_dump(config))
        l.close()

        b = Bakery('', sourcedir, 'builds', sourcedir)

        b.init_logging('%s.process.log' % sourcedir.replace('/', '-'))

        b.pipes = [
            pipe.Copy,
            pipe.Build,
            pipe.Rename,
            pipe.Metadata,
            pipe.PyFtSubset,
            pipe.FontLint,
            pipe.Optimize,
            pipe.AutoFix,
            pipe.CopyLicense,
            pipe.CopyFontLog,
            pipe.CopyDescription,
            pipe.CopyMetadata,
            pipe.CopyTxtFiles,
            pipe.TTFAutoHint,
            pipe.PyFontaine
        ]

        config = os.path.join(sourcedir, '.bakery.yaml')
        b.load_config(config)

        b.run()
    except Exception, ex:
        print >> sys.stderr, 'FAILED: %s' % sourcedir
        print >> sys.stderr, ex
コード例 #9
0
def run_bakery(path, verbose=False):
    # fontbakery-build supports passing arguments of directory or
    # concrete bakery.y[a]ml files. In case of passing directory
    # it looks at existing bakery.yml or bakery.yaml and runs on
    # first matched filepath

    # There can also be cases when directory does not contain any
    # bakery.y[a]ml or passed bakery.yml file does not exist. Then
    # fontbakery-build loads default configuration.
    bakery_yml_file = None
    sourcedir = path

    if os.path.isdir(path):
        for filename in ["bakery.yml", "bakery.yaml"]:
            if os.path.exists(os.path.join(path, filename)):
                bakery_yml_file = os.path.join(path, filename)
                break
    else:
        bakery_yml_file = path
        sourcedir = os.path.dirname(path)

    try:
        if bakery_yml_file:
            config = yaml.safe_load(open(bakery_yml_file, "r"))
        else:
            raise IOError
    except IOError:
        bakery_yml_file = os.path.join(sourcedir, "bakery.yml")
        config = yaml.safe_load(open(BAKERY_CONFIGURATION_DEFAULTS))

    try:
        builddir = "build"
        if GITPYTHON_INSTALLED:
            try:
                repo = Repo(sourcedir)
                builddir = repo.git.rev_parse("HEAD", short=True)
            except git.exc.InvalidGitRepositoryError:
                pass
        builddir = os.environ.get("TRAVIS_COMMIT", builddir)

        if "process_files" not in config:
            directory = UpstreamDirectory(sourcedir)
            # normalize process_files path
            config["process_files"] = directory.get_fonts()

        create_bakery_config(bakery_yml_file, config)

        b = Bakery("", sourcedir, "builds", builddir)
        b.addLoggingToFile()
        b.load_config(bakery_yml_file)
        b.run()

        if not ttfautohint_installed():
            msg = (
                "Command line tool `ttfautohint` is required. Install it with"
                " `apt-get install ttfautohint` or `brew install ttfautohint`"
            )
            logger.error(msg)
    except:
        if verbose or config.get("verbose"):
            raise
        sys.exit(1)
コード例 #10
0
def run_bakery(path, verbose=False):
    # fontbakery-build supports passing arguments of directory or
    # concrete bakery.y[a]ml files. In case of passing directory
    # it looks at existing bakery.yml or bakery.yaml and runs on
    # first matched filepath

    # There can also be cases when directory does not contain any
    # bakery.y[a]ml or passed bakery.yml file does not exist. Then
    # fontbakery-build loads default configuration.
    bakery_yml_file = None
    sourcedir = path

    if os.path.isdir(path):
        for filename in ['bakery.yml', 'bakery.yaml']:
            if os.path.exists(os.path.join(path, filename)):
                bakery_yml_file = os.path.join(path, filename)
                break
    else:
        bakery_yml_file = path
        sourcedir = os.path.dirname(path)

    try:
        if bakery_yml_file:
            config = yaml.safe_load(open(bakery_yml_file, 'r'))
        else:
            raise IOError
    except IOError:
        bakery_yml_file = os.path.join(sourcedir, 'bakery.yml')
        config = yaml.safe_load(open(BAKERY_CONFIGURATION_DEFAULTS))

    try:
        builddir = 'build'
        if GITPYTHON_INSTALLED:
            try:
                repo = Repo(sourcedir)
                builddir = repo.git.rev_parse('HEAD', short=True)
            except git.exc.InvalidGitRepositoryError:
                pass
        builddir = os.environ.get('TRAVIS_COMMIT', builddir)

        if 'process_files' not in config:
            directory = UpstreamDirectory(sourcedir)
            # normalize process_files path
            config['process_files'] = directory.get_fonts()

        create_bakery_config(bakery_yml_file, config)

        b = Bakery('', sourcedir, 'builds', builddir)
        b.addLoggingToFile()
        b.load_config(bakery_yml_file)
        b.run()

        if not ttfautohint_installed():
            msg = ('Command line tool `ttfautohint` is required. Install it with'
                   ' `apt-get install ttfautohint` or `brew install ttfautohint`')
            logger.error(msg)
    except:
        logger.error('BUILD FAILED')
        if verbose or config.get('verbose'):
            raise
        logger.error('Run with --verbose to get stacktrace info.')
        sys.exit(1)