1#!/usr/bin/env python 2# 3# Copyright 2016 Google Inc. 4# 5# Use of this source code is governed by a BSD-style license that can be 6# found in the LICENSE file. 7 8 9"""Create the asset.""" 10 11 12import argparse 13import common 14import subprocess 15import os 16import shutil 17 18 19SVG_TOOLS = os.path.join(common.INFRA_BOTS_DIR, os.pardir, os.pardir, 'tools', 20 'svg') 21SVG_GS_BUCKET = 'gs://skia-svgs' 22 23 24def create_asset(target_dir): 25 """Create the asset.""" 26 target_dir = os.path.realpath(target_dir) 27 28 if not os.path.exists(target_dir): 29 os.makedirs(target_dir) 30 31 # Download the SVGs specified in tools/svg/svgs.txt 32 download_svgs_cmd = [ 33 'python', os.path.join(SVG_TOOLS, 'svg_downloader.py'), 34 '--output_dir', target_dir, 35 '--svgs_file', os.path.join(SVG_TOOLS, 'svgs.txt'), 36 ] 37 subprocess.check_call(download_svgs_cmd) 38 39 # Download the SVGs specified in tools/svg/svgs_parse_only.txt with a prefix. 40 download_svgs_parse_only_cmd = [ 41 'python', os.path.join(SVG_TOOLS, 'svg_downloader.py'), 42 '--output_dir', target_dir, 43 '--svgs_file', os.path.join(SVG_TOOLS, 'svgs_parse_only.txt'), 44 '--prefix', 'svgparse_', 45 ] 46 subprocess.check_call(download_svgs_parse_only_cmd) 47 48 # Download SVGs from Google storage. 49 # The Google storage bucket will either contain private SVGs or SVGs which we 50 # cannot download over the internet using svg_downloader.py. 51 for skbug in ['skbug4713', 'skbug6918']: 52 subprocess.check_call([ 53 'gsutil', '-m', 'cp', os.path.join(SVG_GS_BUCKET, skbug, '*'), 54 target_dir 55 ]) 56 57 58def main(): 59 parser = argparse.ArgumentParser() 60 parser.add_argument('--target_dir', '-t', required=True) 61 args = parser.parse_args() 62 create_asset(args.target_dir) 63 64 65if __name__ == '__main__': 66 main() 67