| # Copyright 2018 The LUCI Authors. All rights reserved. |
| # Use of this source code is governed under the Apache License, Version 2.0 |
| # that can be found in the LICENSE file. |
| """Simple script for creating symbolic links for an arbitrary number of path pairs.""" |
| parser = argparse.ArgumentParser(description='Create symlinks') |
| parser.add_argument("--link-json", |
| help="Simple JSON mapping of a source to a linkname", |
| args = parser.parse_args() |
| with open(args.link_json, 'r') as f: |
| def make_parent_dirs(path): |
| path = os.path.dirname(path) |
| if ex.errno != errno.EEXIST: |
| while path and path not in made_dirs: |
| path = os.path.dirname(path) |
| for target, linknames in links.iteritems(): |
| for linkname in linknames: |
| make_parent_dirs(linkname) |
| os.symlink(target, linkname) |
| if __name__ == '__main__': |
| sys.exit(main(sys.argv[1:])) |