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

Side by Side Diff: tools/copy_tree.py

Issue 2826793002: [Fuchsia] Build only the parts of the SDK that are needed (Closed)
Patch Set: Back out bad fix Created 3 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
« no previous file with comments | « sdk/BUILD.gn ('k') | tools/create_sdk.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
3 # for details. All rights reserved. Use of this source code is governed by a
4 # BSD-style license that can be found in the LICENSE file.
5
6 import argparse
7 import os
8 import re
9 import shutil
10 import sys
11
12 def ParseArgs(args):
13 args = args[1:]
14 parser = argparse.ArgumentParser(
15 description='A script to copy a file tree somewhere')
16
17 parser.add_argument('--exclude_patterns', '-e',
18 type=str,
19 help='Patterns to exclude [passed to shutil.copytree]')
20 parser.add_argument('--from', '-f',
21 dest="copy_from",
22 type=str,
23 required=True,
24 help='Source tree root')
25 parser.add_argument('--to', '-t',
26 type=str,
27 required=True,
28 help='Destination')
29
30 return parser.parse_args(args)
31
32
33 def ValidateArgs(args):
34 if not os.path.isdir(args.copy_from):
35 print "--from argument must refer to a directory"
36 return False
37 return True
38
39
40 def Main(argv):
41 args = ParseArgs(argv)
42 if not ValidateArgs(args):
43 return -1
44 if os.path.exists(args.to):
45 shutil.rmtree(args.to)
46 if args.exclude_patterns == None:
47 shutil.copytree(args.copy_from, args.to)
48 else:
49 patterns = args.exclude_patterns.split(',')
50 shutil.copytree(args.copy_from, args.to,
51 ignore=shutil.ignore_patterns(tuple(patterns)))
52 return 0
53
54
55 if __name__ == '__main__':
56 sys.exit(Main(sys.argv))
OLDNEW
« no previous file with comments | « sdk/BUILD.gn ('k') | tools/create_sdk.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698