Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 # This script is used to copy all dependencies into the local directory. | 6 # This script is used to copy all dependencies into the local directory. |
| 7 # The package of files can then be uploaded to App Engine. | 7 # The package of files can then be uploaded to App Engine. |
| 8 import os | 8 import os |
| 9 import shutil | 9 import shutil |
| 10 import sys | 10 import sys |
| 11 | 11 |
| 12 THIRD_PARTY_DIR = os.path.join(sys.path[0], os.pardir, os.pardir, os.pardir, | 12 THIRD_PARTY_DIR = os.path.join(sys.path[0], os.pardir, os.pardir, os.pardir, |
| 13 os.pardir, os.pardir, 'third_party') | 13 os.pardir, os.pardir, 'third_party') |
| 14 LOCAL_THIRD_PARTY_DIR = os.path.join(sys.path[0], 'third_party') | 14 LOCAL_THIRD_PARTY_DIR = os.path.join(sys.path[0], 'third_party') |
| 15 TOOLS_DIR = os.path.join(sys.path[0], os.pardir, os.pardir, os.pardir, | |
| 16 os.pardir, os.pardir, 'tools') | |
| 17 | |
| 18 SCHEMA_COMPILER_FILES = ['model.py'] | |
| 19 | |
| 20 def MakeInit(path): | |
| 21 path = os.path.join(path, '__init__.py') | |
| 22 with open(os.path.join(path), 'w') as f: | |
| 23 os.utime(os.path.join(path), None) | |
| 15 | 24 |
| 16 def main(): | 25 def main(): |
| 17 shutil.rmtree(LOCAL_THIRD_PARTY_DIR, True) | 26 shutil.rmtree(LOCAL_THIRD_PARTY_DIR, True) |
| 27 | |
| 28 # Get handlebar. | |
| 29 local_handlebar_path = os.path.join(LOCAL_THIRD_PARTY_DIR, 'handlebar') | |
| 18 shutil.copytree(os.path.join(THIRD_PARTY_DIR, 'handlebar'), | 30 shutil.copytree(os.path.join(THIRD_PARTY_DIR, 'handlebar'), |
| 19 os.path.join(LOCAL_THIRD_PARTY_DIR, 'handlebar')) | 31 local_handlebar_path) |
| 20 | 32 |
| 21 with open(os.path.join(LOCAL_THIRD_PARTY_DIR, '__init__.py'), 'w') as f: | 33 # Get json_schema_compiler files. |
| 22 os.utime(os.path.join(LOCAL_THIRD_PARTY_DIR, '__init__.py'), None) | 34 local_schema_compiler_path = os.path.join(LOCAL_THIRD_PARTY_DIR, |
| 35 'json_schema_compiler') | |
| 36 os.makedirs(local_schema_compiler_path) | |
| 37 for filename in SCHEMA_COMPILER_FILES: | |
| 38 shutil.copy(os.path.join(TOOLS_DIR, 'json_schema_compiler', filename), | |
| 39 os.path.join(local_schema_compiler_path, filename)) | |
|
not at google - send to devlin
2012/06/10 06:58:22
Could you have some kind of CopyThirdParty functio
cduvall
2012/06/18 19:13:46
Done.
| |
| 23 | 40 |
| 24 shutil.copy(os.path.join(LOCAL_THIRD_PARTY_DIR, '__init__.py'), | 41 # We will need the comment eater to load JSON. |
| 25 os.path.join(LOCAL_THIRD_PARTY_DIR, 'handlebar')) | 42 shutil.copy(os.path.join(TOOLS_DIR, 'json_comment_eater.py'), |
| 26 with open( | 43 os.path.join(local_schema_compiler_path, 'json_comment_eater.py')) |
| 27 os.path.join(LOCAL_THIRD_PARTY_DIR, 'handlebar/__init__.py'), 'a') as f: | 44 |
| 28 f.write('\nfrom handlebar import Handlebar\n') | 45 MakeInit(LOCAL_THIRD_PARTY_DIR) |
| 46 MakeInit(local_schema_compiler_path) | |
| 47 MakeInit(local_handlebar_path) | |
| 48 | |
| 49 # To be able to use the Handlebar class we need this import in __init__.py. | |
|
not at google - send to devlin
2012/06/10 06:58:22
Why do you need it in __init__ (I'm curious / lack
cduvall
2012/06/18 19:13:46
For some reason python won't let you import classe
| |
| 50 with open(os.path.join(local_handlebar_path, '__init__.py'), 'a') as f: | |
| 51 f.write('from handlebar import Handlebar\n') | |
| 29 | 52 |
| 30 if __name__ == '__main__': | 53 if __name__ == '__main__': |
| 31 main() | 54 main() |
| OLD | NEW |