Exemplo n.º 1
0
def generate(config):
    matadata_json = op.join(config['path'], METADATA_JSON)
    if not op.exists(matadata_json):
        return

    try:
        data = yaml.load(open(op.join(config['path'], 'METADATA.yaml')))
    except IOError:
        data = {}

    tests_summary = {}
    tests_summary_filepath = op.join(config['path'], 'summary.tests.json')
    if op.exists(tests_summary_filepath):
        tests_summary = json.load(open(tests_summary_filepath))

    summary = {
        'success': len(data.get(METADATA_JSON, {}).get('success', [])),
        'error': len(data.get(METADATA_JSON, {}).get('error', [])),
        'failure': len(data.get(METADATA_JSON, {}).get('failure', [])),
        'fixed': len(data.get(METADATA_JSON, {}).get('fixed', []))
    }
    tests_summary.update({METADATA_JSON: summary})
    json.dump(tests_summary, open(tests_summary_filepath, 'w'))

    new_data = []
    for k in data:
        d = {'name': k}
        d.update(data[k])
        new_data.append(d)
    report_app = report_utils.BuildInfo(config)

    report_app.metadata_page.dump_file(new_data, 'tests.json')
Exemplo n.º 2
0
def generate(config):
    if not op.exists(op.join(config['path'], 'bakery.yaml')):
        return

    report_app = report_utils.BuildInfo(config)
    report_app.bakeryyaml_page.copy_file(op.join(config['path'],
                                                 'bakery.yaml'),
                                         alt_name='bakery_yaml.json')
Exemplo n.º 3
0
def generate(config):
    report_app = report_utils.BuildInfo(config)
    report_app.build_page.copy_file(op.join(config['path'], 'buildlog.txt'),
                                    alt_name='buildlog.html')
    build_page_dir = op.join(report_app.pages_dir, report_app.build_page.name)
    with codecs.open(op.join(build_page_dir, 'buildlog.html'),
                     'r+',
                     encoding='utf-8',
                     errors='ignore') as f:
        data = f.read()
        f.seek(0)
        f.write(markdown(data))
        f.truncate()
Exemplo n.º 4
0
def generate(config):
    upstreamdatafile = op.join(config['path'], 'upstream.yaml')
    if not op.exists(upstreamdatafile):
        return

    upstream = yaml.load(open(upstreamdatafile))

    new_data = []
    for k in upstream:
        d = {'name': k}
        d.update(upstream[k])
        new_data.append(d)

    report_app = report_utils.BuildInfo(config)
    report_app.checks_page.dump_file(new_data, 'tests.json')
Exemplo n.º 5
0
def generate(config, outfile='review.html'):
    directory = UpstreamDirectory(config['path'])
    fonts = [(path, FontFactory.openfont(op.join(config['path'], path)))
             for path in directory.BIN]

    metadata_file = open(op.join(config['path'], 'METADATA.json')).read()
    family_metadata = Metadata.get_family_metadata(metadata_file)
    faces = []
    for f in family_metadata.fonts:
        faces.append({
            'name': f.full_name,
            'basename': f.post_script_name,
            'path': f.filename,
            'meta': f
        })

    report_app = report_utils.BuildInfo(config)
    fonts_orthography = get_orthography(fonts)

    report_app.review_page.dump_file(fonts_orthography, 'orthography.json')
Exemplo n.º 6
0
def generate(config, outfile='tests.html'):
    directory = UpstreamDirectory(config['path'])

    tests = {}

    data = {}
    for fp in directory.BIN:
        path = op.join(config['path'], '{}.yaml'.format(fp[:-4]))
        if op.exists(path):
            data[fp] = yaml.load(open(path))
            tests[fp] = {
                'success': len(data[fp].get('success', [])),
                'error': len(data[fp].get('error', [])),
                'failure': len(data[fp].get('failure', [])),
                'fixed': len(data[fp].get('fixed', []))
            }

    if not data:
        return

    new_data = []
    for k in data:
        d = {'name': k}
        d.update(data[k])
        new_data.append(d)

    tests_summary = {}
    tests_summary_filepath = op.join(config['path'], 'summary.tests.json')
    if op.exists(tests_summary_filepath):
        tests_summary = json.load(open(tests_summary_filepath))
    tests_summary.update(tests)

    json.dump(tests_summary, open(tests_summary_filepath, 'w'))

    report_app = report_utils.BuildInfo(config)
    report_app.tests_page.dump_file(new_data, 'tests.json')
Exemplo n.º 7
0
    import jinja2
except IndexError:
    print(('Bakery report script uses jinja2 template engine.'
           ' Please install jinja2 before using'))

desc = 'Generates report files for given project directory'
parser = argparse.ArgumentParser(description=desc)
parser.add_argument('directory',
                    help='Place of directory with fonts to make'
                    ' report for')

args = parser.parse_args()

if int(os.environ.get('TRAVIS_TEST_RESULT', 0)) == 0:
    config = {'path': args.directory}
    report_app = utils.BuildInfo(config)
    # app.generate(config)
    tests.generate(config)
    index.generate(config)
    metadata.generate(config)
    description.generate(config)
    checks.generate(config)
    review.generate(config)
    bakery.generate(config)
    buildlog.generate(config)

    if os.path.exists(os.path.join(config['path'], 'FONTLOG.txt')):

        if not bool(glob.glob(os.path.join(config['path'], 'README*'))):
            src = os.path.join(config['path'], 'FONTLOG.txt')
            dst = os.path.join(config['path'], 'README.md')
Exemplo n.º 8
0
def generate(config):
    report_utils.BuildInfo(config)
Exemplo n.º 9
0
def generate(config):
    source_file = op.join(config['path'], 'DESCRIPTION.en_us.html')
    if not op.exists(source_file):
        return
    report_app = report_utils.BuildInfo(config)
    report_app.description_page.copy_file(source_file)
Exemplo n.º 10
0
def generate(config):
    if config.get('failed'):
        return

    directory = UpstreamDirectory(config['path'])
    if op.exists(op.join(config['path'], 'METADATA.json.new')):
        metadata_file = open(op.join(config['path'],
                                     'METADATA.json.new')).read()
    else:
        metadata_file = open(op.join(config['path'], 'METADATA.json')).read()
    family_metadata = Metadata.get_family_metadata(metadata_file)
    faces = []
    for f in family_metadata.fonts:
        faces.append({
            'name': f.full_name,
            'basename': f.post_script_name,
            'path': f.filename,
            'meta': f
        })

    metadata = yaml.load(open(op.join(config['path'], 'METADATA.yaml')))
    upstreamdata = {}
    upstreamdatafile = op.join(config['path'], 'upstream.yaml')
    if op.exists(upstreamdatafile):
        upstreamdata = yaml.load(open(upstreamdatafile))

    data = {}
    for fp in directory.BIN:
        path = op.join(config['path'], '{}.yaml'.format(fp[:-4]))
        if op.exists(path):
            data[fp] = yaml.load(open(path))
    data.update(metadata)
    data.update(upstreamdata)

    fontpaths = [op.join(config['path'], path) for path in directory.BIN]
    ttftablesizes = get_fonts_table_sizes(fontpaths)

    ftables_data = get_fonts_table_sizes_grouped(fontpaths)

    buildstate = yaml.load(open(op.join(config['path'], 'build.state.yaml')))
    autohint_sizes = buildstate.get('autohinting_sizes', [])
    vmet = get_metric_view(fontpaths)

    fonts = [(path, FontFactory.openfont(op.join(config['path'], path)))
             for path in directory.BIN]

    stems = [
        get_stem_info(op.join(config['path'], path)) for path in directory.BIN
    ]

    new_data = []
    for k in data:
        d = {'name': k}
        d.update(data[k])
        new_data.append(d)

    report_app = report_utils.BuildInfo(config)
    metrics = {'data': vmet._its_metrics, 'headings': vmet._its_metrics_header}
    table_sizes = {'tables': ttftablesizes[0], 'sizes': ttftablesizes[1:]}
    report_app.summary_page.dump_file(metrics, 'metrics.json')
    report_app.summary_page.dump_file(stems, 'stems.json')
    report_app.summary_page.dump_file(table_sizes, 'table_sizes.json')
    report_app.summary_page.dump_file(autohint_sizes, 'autohint_sizes.json')
    report_app.summary_page.dump_file(new_data, 'tests.json')
    report_app.summary_page.dump_file(
        {
            'mean': ftables_data.mean,
            'grouped': ftables_data.grouped,
            'delta': ftables_data.delta
        }, 'fonts_tables_grouped.json')
    for face in family_metadata.fonts:
        face_template = "@font-face {{ font-family: {}; src: url(fonts/{});}}\n".format(
            face.metadata_object['postScriptName'],
            face.metadata_object['filename'])
        report_app.write_file(face_template,
                              op.join(report_app.css_dir, 'faces.css'),
                              mode='a')

    fonts_serialized = dict([(str(path),
                              font_factory_instance_to_dict(fontaine))
                             for path, fontaine in fonts])
    report_app.summary_page.dump_file(fonts_serialized, 'fontaine_fonts.json')

    #Temporarily remove this broken piece of code
    if False:
        fonts_orthography = get_orthography(fonts)
        report_app.summary_page.dump_file(
            {
                'fonts_list': fonts_orthography[0],
                'coverage_averages': fonts_orthography[1],
                'fonts_info': fonts_orthography[2]
            }, 'fonts_orthography.json')