Exemplo n.º 1
0
def main():

    repo_fonts = get_fonts(repo_cp_path)
    prod_fonts = get_fonts(production_fonts_dir)

    repo_hashed_fonts = hash_files(repo_fonts)
    prod_hashed_fonts = hash_files(prod_fonts)

    l_hashes = set(repo_hashed_fonts.keys())
    r_hashes = set(prod_hashed_fonts.keys())

    compatible_fonts_hashes = l_hashes & r_hashes
    repo_compatible_fonts = [
        repo_hashed_fonts[h] for h in compatible_fonts_hashes
    ]
    repo_incompatible_fonts = [
        f for f in repo_fonts if f not in repo_compatible_fonts
    ]

    repo_font_families_names = set(
        [fontdata.get_familyname(TTFont(f)) for f in repo_fonts])
    prod_font_families_names = set(
        [fontdata.get_familyname(TTFont(f)) for f in prod_fonts])

    repo_missing_families = prod_font_families_names - repo_font_families_names
    prod_missing_families = repo_font_families_names - prod_font_families_names

    repo_missing_families = list(repo_missing_families)
    prod_missing_families = list(prod_missing_families)

    sorted(repo_missing_families)
    sorted(prod_missing_families)

    df = pd.concat([
        pd.Series(repo_compatible_fonts),
        pd.Series(repo_incompatible_fonts),
        pd.Series(repo_missing_families),
        pd.Series(prod_missing_families),
    ],
                   axis=1)
    df.columns = [
        'google/fonts compatible files',
        'google/fonts incompatible files',
        'google/fonts missing',
        'fonts.google.com missing',
    ]
    df.to_csv('./reports/repo_vs_production.csv',
              sep='\t',
              encoding='utf-8',
              index=False)
Exemplo n.º 2
0
def main():
    print 'cloning google/fonts'
    if os.path.isdir(repo_cp_path):
        shutil.rmtree(repo_cp_path)
    subprocess.call(['git', 'clone', repo_url, repo_cp_path])

    print 'Replacing broken fonts with fixed fonts'
    fonts_2_package = get_fonts(production_fonts_fixed_dir)
    families_2_update = set([get_repo_name(f) for f in fonts_2_package])
    swap_repo_fonts(fonts_2_package, repo_cp_path, families_2_update)

    print 'Updating family METADATA.pb files'
    gf_collection = api_request(gf_api_url)
    families_codepages = get_families_codepages(gf_collection)
    update_families_metadata_pb(repo_cp_path, families_codepages, families_2_update)

    print 'Replacing DESCRIPTION.en_us.html files'
    description_files = get_fonts(description_dir, filetype='.html')
    replace_families_description_file(repo_cp_path, description_files, families_2_update)
Exemplo n.º 3
0
def main():
    broken_families_doc = pd.read_csv('./reports/current_failed_families.csv',
                                      delimiter='\t',
                                      encoding='utf-8')
    broken_families = list(broken_families_doc['family'])

    renamed_prod_fonts = get_fonts(production_fonts_renamed_dir)
    if not os.path.isdir(production_fonts_fixed_dir):
        os.mkdir(production_fonts_fixed_dir)
    delete_files(production_fonts_fixed_dir)
    fix_fonts(renamed_prod_fonts, broken_families, production_fonts_fixed_dir)
Exemplo n.º 4
0
def main():
    if not os.path.isdir(repo_missing_fonts):
        os.mkdir(repo_missing_fonts)
    delete_files(repo_missing_fonts)

    print 'Making missing families folders'
    families = families_2_add('./reports/repo_vs_production.csv')
    fixed_fonts = get_fonts(production_fonts_fixed_dir)
    directories = get_families_directory(families)
    move_fonts_2_directories(fixed_fonts, directories)
    generate_families_metadata(directories)
    get_previous_families_data(directories)

    print 'Moving families to repo copy'
    move_families_2_repo_cp(directories)

    print 'Deleting temp missing repos folder'
    shutil.rmtree(repo_missing_fonts)
    print 'Missing families have been moved to the copied repo'
Exemplo n.º 5
0
def pr_family(src_path, dest_path):
    """Replace a family and do git operations to submit pr for family to
    google/fonts"""

    c_dir = os.getcwd()
    print 'Replacing %s' % dest_path

    try:
        shutil.rmtree(dest_path)
    except OSError:
        print 'Family does not exist, adding instead'
    shutil.copytree(src_path, dest_path)

    os.chdir(dest_path)
    folder = basename(dest_path)

    # git initialisation operations
    repo = git.Git('.')
    repo.checkout('master')
    # repo.pull('origin master') # update our master to match google/fonts

    branch_name = 'hotfix-%s' % folder
    repo.checkout('HEAD', b=branch_name)
    
    repo.add('../%s' % folder)
    repo_fonts_paths = get_fonts(os.path.join(c_dir, src_path))
    fam_version = fontdata.get_version(TTFont(repo_fonts_paths[0]))
    commit_msg = '%s: v%s added' % (branch_name, fam_version)
    repo.commit('-m', commit_msg)
    repo.push('upstream')
    
    # git make pr
    print 'PRing to google/fonts'
    subprocess.call(['hub', 'pull-request', '-b', 'google/fonts:master', '-m', commit_msg])

    # rest git and go back to c_dir
    repo.checkout('master')
    os.chdir(c_dir)
Exemplo n.º 6
0
def name_from_font_path(path):
    """Get the folders fony family name"""
    fonts = get_fonts(path)
    ttfont = TTFont(fonts[0])
    return fontdata.get_familyname(ttfont)