blob: 50967ae9881e47e1d2734f1a475764d5e6d1a445 [file] [log] [blame]
Joe Gregorioc47fab72011-07-06 08:29:20 -04001#!/usr/bin/python2.4
2# -*- coding: utf-8 -*-
3#
4# Copyright (C) 2010 Google Inc.
5#
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17
18"""Copy files from source to dest expanding symlinks along the way.
19"""
20
Joe Gregoriod667c9d2011-10-17 13:25:24 -040021from shutil import copytree
Joe Gregoriob17c7632011-04-05 01:31:55 -040022
Joe Gregorio79daca02013-03-29 16:25:52 -040023import argparse
Joe Gregorioc47fab72011-07-06 08:29:20 -040024import sys
25
26
Joe Gregoriod667c9d2011-10-17 13:25:24 -040027# Ignore these files and directories when copying over files into the snapshot.
Joe Gregorio79daca02013-03-29 16:25:52 -040028IGNORE = set(['.hg', 'httplib2', 'oauth2', 'simplejson', 'static'])
Joe Gregoriod667c9d2011-10-17 13:25:24 -040029
30# In addition to the above files also ignore these files and directories when
31# copying over samples into the snapshot.
32IGNORE_IN_SAMPLES = set(['apiclient', 'oauth2client', 'uritemplate'])
33
Joe Gregorio79daca02013-03-29 16:25:52 -040034parser = argparse.ArgumentParser(description=__doc__)
Joe Gregoriod667c9d2011-10-17 13:25:24 -040035
Joe Gregorio79daca02013-03-29 16:25:52 -040036parser.add_argument('--source', default='.',
37 help='Directory name to copy from.')
38
39parser.add_argument('--dest', default='snapshot',
40 help='Directory name to copy to.')
Joe Gregorioc47fab72011-07-06 08:29:20 -040041
42
Joe Gregoriod667c9d2011-10-17 13:25:24 -040043def _ignore(path, names):
44 retval = set()
45 if path != '.':
46 retval = retval.union(IGNORE_IN_SAMPLES.intersection(names))
47 retval = retval.union(IGNORE.intersection(names))
48 return retval
49
50
Joe Gregorio79daca02013-03-29 16:25:52 -040051def main():
Joe Gregoriod667c9d2011-10-17 13:25:24 -040052 copytree(FLAGS.source, FLAGS.dest, symlinks=True,
53 ignore=_ignore)
Joe Gregorioc47fab72011-07-06 08:29:20 -040054
55
56if __name__ == '__main__':
Joe Gregorio79daca02013-03-29 16:25:52 -040057 FLAGS = parser.parse_args(sys.argv[1:])
58 main()