| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/env python | |
| 2 # | |
| 3 # Copyright 2015 The Chromium Authors. All rights reserved. | |
| 4 # Use of this source code is governed by a BSD-style license that can be | |
| 5 # found in the LICENSE file. | |
| 6 | |
| 7 """Extracts a set of zip archives. """ | |
| 8 | |
| 9 import ast | |
| 10 import optparse | |
| 11 import os | |
| 12 import sys | |
| 13 import zipfile | |
| 14 | |
| 15 def DoUnzip(inputs, output): | |
| 16 if not os.path.exists(output): | |
| 17 os.makedirs(output) | |
| 18 for i in inputs: | |
| 19 with zipfile.ZipFile(i) as zf: | |
| 20 zf.extractall(output) | |
| 21 | |
| 22 | |
| 23 def main(): | |
| 24 parser = optparse.OptionParser() | |
| 25 | |
| 26 parser.add_option('--inputs', help='List of archives to extract.') | |
| 27 parser.add_option('--output', help='Path to unzip the archives to.') | |
| 28 parser.add_option('--timestamp', help='Path to a timestamp file.') | |
| 29 | |
| 30 options, _ = parser.parse_args() | |
| 31 | |
| 32 inputs = [] | |
| 33 if (options.inputs): | |
| 34 inputs = ast.literal_eval(options.inputs) | |
| 35 | |
| 36 DoUnzip(inputs, options.output) | |
| 37 | |
| 38 if options.timestamp: | |
| 39 if os.path.exists(options.timestamp): | |
| 40 os.utime(options.timestamp, None) | |
| 41 else: | |
| 42 with open(options.timestamp, 'a'): | |
| 43 pass | |
| 44 | |
| 45 if __name__ == '__main__': | |
| 46 sys.exit(main()) | |
| OLD | NEW |