From 46eff27c32166f007132bfa5f4effc3c306b5f47 Mon Sep 17 00:00:00 2001 From: Deepanshu Gupta Date: Tue, 27 May 2014 11:21:24 -0700 Subject: Recurse into directories to find fonts. [DO NOT MERGE] We now recurse into directories to find all fonts. This change is needed to prevent having to list all fonts in external/google-fonts individually. As a side effect, we now only copy xml files over. Change-Id: Ifdea3b8451878c2449ac7c5e17ef3d1b00d1b955 (cherry picked from commit c6364fd90de1600526d3431ce0740b6b856e48f0) --- tools/layoutlib/rename_font/build_font.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'tools') diff --git a/tools/layoutlib/rename_font/build_font.py b/tools/layoutlib/rename_font/build_font.py index 7f01a13..aea3241 100755 --- a/tools/layoutlib/rename_font/build_font.py +++ b/tools/layoutlib/rename_font/build_font.py @@ -52,13 +52,17 @@ def main(argv): os.chdir(cwd) input_fonts = list() for src_dir in src_dirs: - for filename in os.listdir(src_dir): - if os.path.isdir(os.path.join(src_dir, filename)): - continue - if not os.path.splitext(filename)[1].lower() == '.ttf': - shutil.copy(os.path.join(src_dir, filename), dest_dir) - continue - input_fonts.append(os.path.join(src_dir, filename)) + for dirname, dirnames, filenames in os.walk(src_dir): + for filename in filenames: + input_path = os.path.join(dirname, filename) + extension = os.path.splitext(filename)[1].lower() + if (extension == '.ttf'): + input_fonts.append(input_path) + elif (extension == '.xml'): + shutil.copy(input_path, dest_dir) + if '.git' in dirnames: + # don't go into any .git directories. + dirnames.remove('.git') # Create as many threads as the number of CPUs pool = Pool(processes=None) pool.map(convert_font, input_fonts) -- cgit v1.1