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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/svg/README.md ('k') | tools/svg/svgs.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/svg/svg_downloader.py
diff --git a/tools/svg/svg_downloader.py b/tools/svg/svg_downloader.py
new file mode 100644
index 0000000000000000000000000000000000000000..71bf6e01364f11f90801978e8dac60d5ae1dd1e6
--- /dev/null
+++ b/tools/svg/svg_downloader.py
@@ -0,0 +1,38 @@
+#!/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
+
+
+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='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.
+ 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))
« 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