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

Side by Side Diff: infra/bots/assets/svg/create.py

Issue 2346663003: Add ability to create and upload SVGs from a local dir (Closed)
Patch Set: Fix default Created 4 years, 3 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 | « no previous file | infra/bots/assets/svg/create_and_upload.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright 2016 Google Inc. 3 # Copyright 2016 Google Inc.
4 # 4 #
5 # Use of this source code is governed by a BSD-style license that can be 5 # Use of this source code is governed by a BSD-style license that can be
6 # found in the LICENSE file. 6 # found in the LICENSE file.
7 7
8 8
9 """Create the asset.""" 9 """Create the asset."""
10 10
11 11
12 import argparse 12 import argparse
13 import common 13 import common
14 import subprocess 14 import subprocess
15 import os 15 import os
16 import shutil
16 17
17 18
18 SVG_TOOLS = os.path.join(common.INFRA_BOTS_DIR, os.pardir, os.pardir, 'tools', 19 SVG_TOOLS = os.path.join(common.INFRA_BOTS_DIR, os.pardir, os.pardir, 'tools',
19 'svg') 20 'svg')
20 21
21 22
22 def create_asset(target_dir): 23 def create_asset(local_svgs_dir, target_dir):
23 """Create the asset.""" 24 """Create the asset."""
24 target_dir = os.path.realpath(target_dir) 25 target_dir = os.path.realpath(target_dir)
25 26
26 if not os.path.exists(target_dir): 27 if not os.path.exists(target_dir):
27 os.makedirs(target_dir) 28 os.makedirs(target_dir)
28 29
30 # Download the SVGs specified in tools/svg/svgs.txt
29 download_svgs_cmd = [ 31 download_svgs_cmd = [
30 'python', os.path.join(SVG_TOOLS, 'svg_downloader.py'), 32 'python', os.path.join(SVG_TOOLS, 'svg_downloader.py'),
31 '--output_dir', target_dir, 33 '--output_dir', target_dir,
32 ] 34 ]
33 subprocess.check_call(download_svgs_cmd) 35 subprocess.check_call(download_svgs_cmd)
34 36
37 # Copy over the SVGs from local_svgs_dir (if any).
38 if local_svgs_dir and os.path.exists(local_svgs_dir):
39 for svg_filename in os.listdir(local_svgs_dir):
40 shutil.copy(src=os.path.join(local_svgs_dir, svg_filename),
41 dst=os.path.join(target_dir, svg_filename))
42
35 43
36 def main(): 44 def main():
37 parser = argparse.ArgumentParser() 45 parser = argparse.ArgumentParser()
46 parser.add_argument('--local_svgs_dir', '-l', default='')
38 parser.add_argument('--target_dir', '-t', required=True) 47 parser.add_argument('--target_dir', '-t', required=True)
39 args = parser.parse_args() 48 args = parser.parse_args()
40 create_asset(args.target_dir) 49 create_asset(args.local_svgs_dir, args.target_dir)
41 50
42 51
43 if __name__ == '__main__': 52 if __name__ == '__main__':
44 main() 53 main()
OLDNEW
« no previous file with comments | « no previous file | infra/bots/assets/svg/create_and_upload.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698