| Index: chrome/common/extensions/docs/server2/build_server.py
|
| diff --git a/chrome/common/extensions/docs/server2/build_server.py b/chrome/common/extensions/docs/server2/build_server.py
|
| index db9d869e358ef7d79ae9411753d16227ffbd60b0..c9a0c53c361ddc52b602950d556ed3947992986a 100755
|
| --- a/chrome/common/extensions/docs/server2/build_server.py
|
| +++ b/chrome/common/extensions/docs/server2/build_server.py
|
| @@ -12,20 +12,45 @@ import sys
|
| THIRD_PARTY_DIR = os.path.join(sys.path[0], os.pardir, os.pardir, os.pardir,
|
| os.pardir, os.pardir, 'third_party')
|
| LOCAL_THIRD_PARTY_DIR = os.path.join(sys.path[0], 'third_party')
|
| +TOOLS_DIR = os.path.join(sys.path[0], os.pardir, os.pardir, os.pardir,
|
| + os.pardir, os.pardir, 'tools')
|
| +
|
| +SCHEMA_COMPILER_FILES = ['model.py']
|
| +
|
| +def MakeInit(path):
|
| + path = os.path.join(path, '__init__.py')
|
| + with open(os.path.join(path), 'w') as f:
|
| + os.utime(os.path.join(path), None)
|
| +
|
| +def CopyThirdParty(src, dest, files=None):
|
| + dest_path = os.path.join(LOCAL_THIRD_PARTY_DIR, dest)
|
| + if not files:
|
| + shutil.copytree(src, dest_path)
|
| + MakeInit(dest_path)
|
| + return
|
| + try:
|
| + os.makedirs(dest_path)
|
| + except:
|
| + pass
|
| + MakeInit(dest_path)
|
| + for filename in files:
|
| + shutil.copy(os.path.join(src, filename), os.path.join(dest_path, filename))
|
|
|
| def main():
|
| shutil.rmtree(LOCAL_THIRD_PARTY_DIR, True)
|
| - shutil.copytree(os.path.join(THIRD_PARTY_DIR, 'handlebar'),
|
| - os.path.join(LOCAL_THIRD_PARTY_DIR, 'handlebar'))
|
|
|
| - with open(os.path.join(LOCAL_THIRD_PARTY_DIR, '__init__.py'), 'w') as f:
|
| - os.utime(os.path.join(LOCAL_THIRD_PARTY_DIR, '__init__.py'), None)
|
| + CopyThirdParty(os.path.join(THIRD_PARTY_DIR, 'handlebar'), 'handlebar')
|
| + CopyThirdParty(os.path.join(TOOLS_DIR, 'json_schema_compiler'),
|
| + 'json_schema_compiler',
|
| + SCHEMA_COMPILER_FILES)
|
| + CopyThirdParty(TOOLS_DIR, 'json_schema_compiler', ['json_comment_eater.py'])
|
| + MakeInit(LOCAL_THIRD_PARTY_DIR)
|
|
|
| - shutil.copy(os.path.join(LOCAL_THIRD_PARTY_DIR, '__init__.py'),
|
| - os.path.join(LOCAL_THIRD_PARTY_DIR, 'handlebar'))
|
| - with open(
|
| - os.path.join(LOCAL_THIRD_PARTY_DIR, 'handlebar/__init__.py'), 'a') as f:
|
| - f.write('\nfrom handlebar import Handlebar\n')
|
| + # To be able to use the Handlebar class we need this import in __init__.py.
|
| + with open(os.path.join(LOCAL_THIRD_PARTY_DIR,
|
| + 'handlebar',
|
| + '__init__.py'), 'a') as f:
|
| + f.write('from handlebar import Handlebar\n')
|
|
|
| if __name__ == '__main__':
|
| main()
|
|
|