diff options
author | Joe Gregorio <jcgregorio@google.com> | 2013-03-29 16:25:52 -0400 |
---|---|---|
committer | Joe Gregorio <jcgregorio@google.com> | 2013-03-29 16:25:52 -0400 |
commit | 79daca0a32c7eba4867692f650411d099025501d (patch) | |
tree | c13ce0fa121436b6f0d36a65dc6f4a66078147da /expandsymlinks.py | |
parent | 731680a341ddd4e4e58febe207f40f894d56577a (diff) | |
download | google-api-python-client-79daca0a32c7eba4867692f650411d099025501d.tar.gz |
Start removing dependence on gflags.
Reviewed in https://codereview.appspot.com/7628044/.
This only removes the dependency from the core library, a second CL will
update all the samples.
Diffstat (limited to 'expandsymlinks.py')
-rw-r--r-- | expandsymlinks.py | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/expandsymlinks.py b/expandsymlinks.py new file mode 100644 index 000000000..50967ae98 --- /dev/null +++ b/expandsymlinks.py @@ -0,0 +1,58 @@ +#!/usr/bin/python2.4 +# -*- coding: utf-8 -*- +# +# Copyright (C) 2010 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Copy files from source to dest expanding symlinks along the way. +""" + +from shutil import copytree + +import argparse +import sys + + +# Ignore these files and directories when copying over files into the snapshot. +IGNORE = set(['.hg', 'httplib2', 'oauth2', 'simplejson', 'static']) + +# In addition to the above files also ignore these files and directories when +# copying over samples into the snapshot. +IGNORE_IN_SAMPLES = set(['apiclient', 'oauth2client', 'uritemplate']) + +parser = argparse.ArgumentParser(description=__doc__) + +parser.add_argument('--source', default='.', + help='Directory name to copy from.') + +parser.add_argument('--dest', default='snapshot', + help='Directory name to copy to.') + + +def _ignore(path, names): + retval = set() + if path != '.': + retval = retval.union(IGNORE_IN_SAMPLES.intersection(names)) + retval = retval.union(IGNORE.intersection(names)) + return retval + + +def main(): + copytree(FLAGS.source, FLAGS.dest, symlinks=True, + ignore=_ignore) + + +if __name__ == '__main__': + FLAGS = parser.parse_args(sys.argv[1:]) + main() |