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

Side by Side Diff: third_party/mojo/src/mojo/public/tools/gn/zip.py

Issue 1058033002: NOT TO COMMITTED: Update mojo sdk to rev 0018e6a91b75bcb941c867f8a7aa1753c3b53a13 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright 2014 The Chromium Authors. All rights reserved. 3 # Copyright 2014 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """Archives a set of files. 7 """Archives a set of files.
8 """ 8 """
9 9
10 import ast 10 import ast
11 import optparse 11 import optparse
12 import os 12 import os
13 import sys 13 import sys
14 import zipfile 14 import zipfile
15 15
16 def DoZip(inputs, zip_inputs, output, base_dir): 16 def DoZip(inputs, zip_inputs, output, base_dir):
17 files = [] 17 files = []
18 with zipfile.ZipFile(output, 'w') as outfile: 18 with zipfile.ZipFile(output, 'w', zipfile.ZIP_DEFLATED) as outfile:
19 for f in inputs: 19 for f in inputs:
20 file_name = os.path.relpath(f, base_dir) 20 file_name = os.path.relpath(f, base_dir)
21 files.append(file_name) 21 files.append(file_name)
22 outfile.write(f, file_name) 22 outfile.write(f, file_name)
23 for zf_name in zip_inputs: 23 for zf_name in zip_inputs:
24 with zipfile.ZipFile(zf_name, 'r') as zf: 24 with zipfile.ZipFile(zf_name, 'r') as zf:
25 for f in zf.namelist(): 25 for f in zf.namelist():
26 if f not in files: 26 if f not in files:
27 files.append(f) 27 files.append(f)
28 with zf.open(f) as zff: 28 with zf.open(f) as zff:
(...skipping 18 matching lines...) Expand all
47 zip_inputs = [] 47 zip_inputs = []
48 if options.zip_inputs: 48 if options.zip_inputs:
49 zip_inputs = ast.literal_eval(options.zip_inputs) 49 zip_inputs = ast.literal_eval(options.zip_inputs)
50 output = options.output 50 output = options.output
51 base_dir = options.base_dir 51 base_dir = options.base_dir
52 52
53 DoZip(inputs, zip_inputs, output, base_dir) 53 DoZip(inputs, zip_inputs, output, base_dir)
54 54
55 if __name__ == '__main__': 55 if __name__ == '__main__':
56 sys.exit(main()) 56 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698