OLD | NEW |
| (Empty) |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | |
2 # Use of this source code is governed by a BSD-style license that can be | |
3 # found in the LICENSE file. | |
4 | |
5 import argparse | |
6 import os | |
7 import shutil | |
8 import sys | |
9 | |
10 def touch(fname): | |
11 if os.path.exists(fname): | |
12 os.utime(fname, None) | |
13 else: | |
14 open(fname, 'a').close() | |
15 | |
16 def main(): | |
17 """Command line utility to copy python binary modules to the correct package | |
18 hierarchy. | |
19 """ | |
20 parser = argparse.ArgumentParser( | |
21 description='Copy python binary modules to the correct package ' | |
22 'hierarchy.') | |
23 parser.add_argument('timestamp', help='The timetsamp file.') | |
24 parser.add_argument('lib_dir', help='The directory containing the modules') | |
25 parser.add_argument('destination_dir', | |
26 help='The destination directory of the module') | |
27 parser.add_argument('mappings', nargs='+', | |
28 help='The mapping from module to library.') | |
29 opts = parser.parse_args() | |
30 | |
31 if not os.path.exists(opts.destination_dir): | |
32 try: | |
33 os.makedirs(opts.destination_dir) | |
34 except: | |
35 # Ignore errors on directory creation. | |
36 pass | |
37 | |
38 for mapping in opts.mappings: | |
39 [module, library] = mapping.split('=') | |
40 shutil.copy(os.path.join(opts.lib_dir, library), | |
41 os.path.join(opts.destination_dir, module)) | |
42 | |
43 touch(opts.timestamp) | |
44 | |
45 if __name__ == '__main__': | |
46 main() | |
OLD | NEW |