Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: tools/svg/svg_downloader.py

Issue 2234823002: SVG tool that downloads SVGs from a txt file into a specified dir (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Minor fixes Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/svg/README.md ('k') | tools/svg/svgs.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright (c) 2016 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 """Downloads SVGs into a specified directory."""
7
8
9 import optparse
10 import os
11 import sys
12 import urllib
13
14
15 def downloadSVGs(svgs_file, output_dir):
16 with open(svgs_file, 'r') as f:
17 for url in f.xreadlines():
18 svg_url = url.strip()
19 dest_file = os.path.join(output_dir, os.path.basename(svg_url))
20 print 'Downloading %s' % svg_url
21 urllib.urlretrieve(svg_url, dest_file)
22
23
24 if '__main__' == __name__:
25 option_parser = optparse.OptionParser()
26 option_parser.add_option(
27 '-s', '--svgs_file',
28 help='Path to the text file containing SVGs. Each line should contain a '
29 'single URL.',
30 default='svgs.txt')
borenet 2016/08/10 13:27:53 Can we make the default correctly determine the pa
rmistry 2016/08/10 13:36:13 Done.
31 option_parser.add_option(
32 '-o', '--output_dir',
33 help='The output dir where downloaded SVGs will be stored in.')
34 options, unused_args = option_parser.parse_args()
35
36 if not options.output_dir:
37 raise Exception('Must specify --output_dir')
38 sys.exit(downloadSVGs(options.svgs_file, options.output_dir))
OLDNEW
« no previous file with comments | « tools/svg/README.md ('k') | tools/svg/svgs.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698