Exemplo n.º 1
0
def main(sources, config):

    rootpath = os.path.abspath('build/tmp')
    if not config:
        config = yaml.safe_load(open(BAKERY_CONFIGURATION_DEFAULTS))
    else:
        config = yaml.safe_load(open(config))

    if 'process_files' not in config:
        config['process_files'] = []

    for source in sources:
        if source[-4:] in ['.ufo', '.ttx', '.ttf', '.otf', '.sfd']:
            # create config bakery.yaml from defaults
            config['process_files'].append(source)
        else:
            continue
        if os.path.isdir(source):
            shutil.copytree(source, rootpath)
        else:
            shutil.copy(source, rootpath)

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

    try:
        b = Bakery(os.path.join(rootpath, '.bakery.yaml'),
                   stdout_pipe=systdout)
        b.interactive = True
        b.run(with_upstream=True)
    finally:
        shutil.rmtree(rootpath)
        pass