OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. |
| 5 |
| 6 # Knows how to pull down files from the version of Blink we forked from. |
| 7 |
| 8 import argparse |
| 9 import requests |
| 10 import os |
| 11 import sys |
| 12 |
| 13 FORK_VERSION = "086acdd04cbe6fcb89b2fc6bd438fb8819a26776" |
| 14 |
| 15 parser = argparse.ArgumentParser("Tool for resurrecting pre-fork Blink files.") |
| 16 parser.add_argument("path", help="Path from Blink's Source root to the file." |
| 17 "e.g. core/dom/ExecutionContextTask.h") |
| 18 args = parser.parse_args() |
| 19 |
| 20 BASE_URL = "http://blink.lc/blink/plain/Source/%s?id=%s" |
| 21 url = BASE_URL % (args.path, FORK_VERSION) |
| 22 response = requests.get(url) |
| 23 if response.status_code != 200: |
| 24 print "Load failure: %s" % url |
| 25 sys.exit(0) |
| 26 contents = response.text |
| 27 |
| 28 file_name = os.path.basename(args.path) |
| 29 |
| 30 if os.path.exists(file_name): |
| 31 print "%s exists, do you want to overwrite [y/N]?" % file_name |
| 32 if raw_input().lower() not in ('y', 'yes'): |
| 33 print "Aborting." |
| 34 sys.exit(1) |
| 35 |
| 36 with open(file_name, "w+") as output: |
| 37 output.write(contents) |
| 38 print "Wrote %s" % file_name |
OLD | NEW |