SVG tool that downloads SVGs from a txt file into a specified dir

BUG=skia:5628
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2234823002

Review-Url: https://codereview.chromium.org/2234823002
This commit is contained in:
rmistry 2016-08-10 07:00:43 -07:00 committed by Commit bot
parent d5b88a3dc5
commit d8a620b173
3 changed files with 129 additions and 0 deletions

19
tools/svg/README.md Normal file
View File

@ -0,0 +1,19 @@
SVG Tools
=========
This directory contains the following-
svgs.txt
--------
This text file contains an SVG URL per line.
The SVGs in this file have been downloaded from the internal doc here:
https://docs.google.com/document/d/1kYRvUxZTnm1tI_0bTU0BX9jqSSTqPUhGXJVcD3Rcg2c/edit
svg_downloader.py
-----------------
This python script parses svgs.txt and downloads SVGs into a specified directory.
The script can be run by hand:
$ python svg_downloader.py --output_dir /tmp/svgs/

View File

@ -0,0 +1,41 @@
#!/usr/bin/env python
# Copyright (c) 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Downloads SVGs into a specified directory."""
import optparse
import os
import sys
import urllib
PARENT_DIR = os.path.dirname(os.path.realpath(__file__))
def downloadSVGs(svgs_file, output_dir):
with open(svgs_file, 'r') as f:
for url in f.xreadlines():
svg_url = url.strip()
dest_file = os.path.join(output_dir, os.path.basename(svg_url))
print 'Downloading %s' % svg_url
urllib.urlretrieve(svg_url, dest_file)
if '__main__' == __name__:
option_parser = optparse.OptionParser()
option_parser.add_option(
'-s', '--svgs_file',
help='Path to the text file containing SVGs. Each line should contain a '
'single URL.',
default=os.path.join(PARENT_DIR, 'svgs.txt'))
option_parser.add_option(
'-o', '--output_dir',
help='The output dir where downloaded SVGs will be stored in.')
options, unused_args = option_parser.parse_args()
if not options.output_dir:
raise Exception('Must specify --output_dir')
sys.exit(downloadSVGs(options.svgs_file, options.output_dir))

69
tools/svg/svgs.txt Normal file
View File

@ -0,0 +1,69 @@
https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/AJ_Digital_Camera.svg
https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/acid.svg
https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/alphachannel.svg
https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/android.svg
https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/bozo.svg
https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/cartman.svg
https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/bzrfeed.svg
https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/car.svg
https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/compass.svg
https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/displayWebStats.svg
https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/eff.svg
https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/fsm.svg
https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/gallardo.svg
https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/rg1024_green_grapes.svg
https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/usaf.svg
https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/yinyang.svg
https://upload.wikimedia.org/wikipedia/commons/6/6d/Alabama-StateSeal.svg
https://upload.wikimedia.org/wikipedia/commons/2/2b/Alaska-StateSeal.svg
https://upload.wikimedia.org/wikipedia/commons/7/7e/Arizona-StateSeal.svg
https://upload.wikimedia.org/wikipedia/commons/a/a4/Seal_of_Arkansas.svg
https://upload.wikimedia.org/wikipedia/commons/0/0f/Seal_of_California.svg
https://upload.wikimedia.org/wikipedia/commons/5/51/Colorado-StateSeal.svg
https://upload.wikimedia.org/wikipedia/commons/e/e5/Connecticut-StateSeal.svg
https://upload.wikimedia.org/wikipedia/commons/c/c0/Delaware-StateSeal.svg
https://upload.wikimedia.org/wikipedia/commons/b/bf/Florida-StateSeal.svg
https://upload.wikimedia.org/wikipedia/commons/e/e0/Georgia-StateSeal.svg
https://upload.wikimedia.org/wikipedia/commons/c/c5/Hawaii-StateSeal.svg
https://upload.wikimedia.org/wikipedia/commons/4/49/Idaho-StateSeal.svg
https://upload.wikimedia.org/wikipedia/commons/e/e7/Seal_of_Illinois.svg
https://upload.wikimedia.org/wikipedia/commons/c/c4/Indiana-StateSeal.svg
https://upload.wikimedia.org/wikipedia/commons/5/5a/Iowa-StateSeal.svg
https://upload.wikimedia.org/wikipedia/commons/4/45/Seal_of_Kansas.svg
https://upload.wikimedia.org/wikipedia/commons/3/35/Seal_of_Kentucky.svg
https://upload.wikimedia.org/wikipedia/commons/2/2f/Seal_of_Louisiana.svg
https://upload.wikimedia.org/wikipedia/commons/a/a0/Maine-StateSeal.svg
https://upload.wikimedia.org/wikipedia/commons/0/00/Seal_of_Maryland_%28reverse%29.svg
https://upload.wikimedia.org/wikipedia/commons/8/82/Seal_of_Massachusetts.svg
https://upload.wikimedia.org/wikipedia/commons/3/3f/Seal_of_Michigan.svg
https://upload.wikimedia.org/wikipedia/commons/6/63/Minnesota-StateSeal.svg
https://upload.wikimedia.org/wikipedia/commons/f/fe/Seal_of_Mississippi_2014.svg
https://upload.wikimedia.org/wikipedia/commons/d/de/Seal_of_Missouri.svg
https://upload.wikimedia.org/wikipedia/commons/e/ed/Montana-StateSeal.svg
https://upload.wikimedia.org/wikipedia/commons/6/60/Nebraska-StateSeal.svg
https://upload.wikimedia.org/wikipedia/commons/7/77/Nevada-StateSeal.svg
https://upload.wikimedia.org/wikipedia/commons/a/aa/Seal_of_New_Hampshire.svg
https://upload.wikimedia.org/wikipedia/commons/8/8d/Seal_of_New_Jersey.svg
https://upload.wikimedia.org/wikipedia/commons/3/3b/NewMexico-StateSeal.svg
https://upload.wikimedia.org/wikipedia/commons/c/ca/NewYork-StateSeal.svg
https://upload.wikimedia.org/wikipedia/commons/7/72/Seal_of_North_Carolina.svg
https://upload.wikimedia.org/wikipedia/commons/e/e7/NorthDakota-StateSeal.svg
https://upload.wikimedia.org/wikipedia/commons/6/69/Seal_of_Ohio_%281967-1996%29.svg
https://upload.wikimedia.org/wikipedia/commons/3/39/Seal_of_Oklahoma.svg
https://upload.wikimedia.org/wikipedia/commons/c/c9/Oregon-StateSeal.svg
https://upload.wikimedia.org/wikipedia/commons/e/e8/Pennsylvania_state_seal.svg
https://upload.wikimedia.org/wikipedia/commons/7/73/RhodeIsland-StateSeal.svg
https://upload.wikimedia.org/wikipedia/commons/8/80/Seal_of_South_Carolina.svg
https://upload.wikimedia.org/wikipedia/commons/b/bb/SouthDakota-StateSeal.svg
https://upload.wikimedia.org/wikipedia/commons/3/3c/Seal_of_Tennessee.svg
https://upload.wikimedia.org/wikipedia/commons/c/cb/Seal_of_Texas.svg
https://upload.wikimedia.org/wikipedia/commons/7/72/Seal_of_Utah_%28Alternate%29.svg
https://upload.wikimedia.org/wikipedia/commons/5/5b/Vermont_state_seal.svg
https://upload.wikimedia.org/wikipedia/commons/6/6f/Seal_of_Virginia.svg
https://upload.wikimedia.org/wikipedia/commons/9/92/Washington-StateSeal.svg
https://upload.wikimedia.org/wikipedia/commons/9/92/WestVirginia-StateSeal.svg
https://upload.wikimedia.org/wikipedia/commons/b/b3/Wisconsin-StateSeal.svg
https://upload.wikimedia.org/wikipedia/commons/c/c0/Wyoming-StateSeal.svg
https://upload.wikimedia.org/wikipedia/commons/d/df/Seal_of_American_Samoa.svg
https://upload.wikimedia.org/wikipedia/commons/f/fd/Ghostscript_Tiger.svg
https://upload.wikimedia.org/wikipedia/commons/6/6c/Trajans-Column-lower-animated.svg