Ejemplo n.º 1
0
def move_fonts_2_directories(fonts, directories):
    """Move fonts to their target family directories"""
    directories = {get_repo_name(d): d for d in directories}
    for font_path in fonts:
        folder_name = get_repo_name(font_path)
        if folder_name in directories:
            print 'Copying %s to %s' % (font_path, directories[folder_name])
            shutil.copy(font_path, directories[folder_name])
Ejemplo n.º 2
0
def main():
    parser = ArgumentParser(description=__doc__)
    parser.add_argument("repo_path",
                        help="Path to local git linked google/fonts repo")
    parser.add_argument("git_username")
    parser.add_argument("git_password")
    parser.add_argument("families", nargs='+',
                        help="family folders to batch pr")
    args = parser.parse_args()

    repo = Repository(args.git_username, args.git_password)
    already_dispatched = repo.families_pr_after(sprint1_start)
    already_dispatched_dir = [fontdata.get_repo_name(f) for f in already_dispatched]
    families_2_dispatch = set(args.families) - set(already_dispatched_dir)

    if families_2_dispatch:
        user_dirs = get_folders(repo_cp_path, families_2_dispatch)
        dest_dirs = get_folders(args.repo_path, families_2_dispatch)
        dest_dirs = create_missing_dest_paths(args.repo_path, user_dirs, dest_dirs)

        pr_families(user_dirs, dest_dirs)
    
    for family in args.families:
        if family in already_dispatched_dir:
            print 'WARNING: %s has already dispatched, skipping.' % family
Ejemplo n.º 3
0
def add_repo_fonts(gf_repo_path, fonts_2_package, families_2_update):
    f = {}
    for path in fonts_2_package:
        pkg_name = get_repo_name(path)
        if not pkg_name in f:
            f[pkg_name] = []
        f[pkg_name].append(path)

    for to_path, r, files in os.walk(gf_repo_path):
        current_folder = basename(to_path)
        if current_folder in families_2_update:
            for from_path in f[current_folder]:
                shutil.copy(from_path, to_path)
Ejemplo n.º 4
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)
Ejemplo n.º 5
0
def get_family_directory(family):
    """Return the path to a family, if it doesn't exist, build a directory
    for the family.

    Use the GF api to determine the correct license parent folder"""
    repo_name = get_repo_name(family)
    family_dir = get_folder(repo_missing_fonts, repo_name)
    if family_dir:
        return family_dir

    print 'Creating folder for %s' % family
    family_data = family_api_info(family)
    license_type = family_data['license']

    # Make the parent directory if it doesn't exist
    parent_dir = os.path.join(repo_missing_fonts, license_type)
    if not os.path.isdir(parent_dir):
        os.mkdir(parent_dir)

    #Make the family directory if it doesn't exist
    family_dir = os.path.join(parent_dir, repo_name)
    if not os.path.isdir(family_dir):
        os.mkdir(family_dir)
    return family_dir