Chromium Code Reviews| Index: chrome/browser/resources/chromeos/chromevox/tools/webstore.py |
| diff --git a/chrome/browser/resources/chromeos/chromevox/tools/webstore.py b/chrome/browser/resources/chromeos/chromevox/tools/webstore.py |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..f612c6acfb1d170d7fde77297b41d8f0cf345e3a |
| --- /dev/null |
| +++ b/chrome/browser/resources/chromeos/chromevox/tools/webstore.py |
| @@ -0,0 +1,77 @@ |
| +#!/usr/bin/env python |
|
dmazzoni
2014/07/23 18:52:41
Maybe call this upload_to_webstore or something al
David Tseng
2014/07/23 22:45:31
I didn't specialize it because it will also contai
|
| + |
| +# Copyright 2014 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +'''Publishes an extension to the webstore. |
|
dmazzoni
2014/07/23 18:52:41
Is this "an extension" or is it just ChromeVox?
David Tseng
2014/07/23 22:45:31
Done.
|
| + Given an unpacked extension, compresses and sends to the Chrome webstore. |
| + |
| + Releasing to the webstore should involve the following manual steps before |
| + running this script: |
| + 1. clean the output directory. |
| + 2. make a release build. |
| + 3. run manual smoke tests. |
| + 4. run automated ChromeVox tests. |
| +''' |
| + |
| +import json |
| +import optparse |
| +import os |
| +import sys |
| +from zipfile import ZipFile |
| + |
| +# A list of files to exclude from the webstore build. |
| +EXCLUDE_FILES = ['manifest_guest.json'] |
| + |
| + |
| +def CreateOptionParser(): |
| + parser = optparse.OptionParser(description=__doc__) |
| + parser.usage = '%prog <extension_path> <output_path>' |
| + return parser |
| + |
| +def MakeManifestEdits(root, old): |
| + '''Customize a manifest for the webstore. |
| + |
| + Args: |
| + root: The directory containing file. |
| + |
| + old: A json file. |
| + |
| + Returns: |
| + Path of the new json manifest. |
| + ''' |
| + new = os.path.join('/tmp', old) |
|
dmazzoni
2014/07/23 18:52:41
Use a tmpfile api to get a temporary file that won
David Tseng
2014/07/23 22:45:31
Done.
|
| + with open(os.path.join(root, old)) as old_file, open(new, 'w') as new_file: |
| + new_contents = json.loads(old_file.read()) |
| + new_contents.pop('key', '') |
| + new_file.write(json.dumps(new_contents)) |
| + return new |
| + |
| +def main(): |
| + _, args = CreateOptionParser().parse_args() |
| + if len(args) != 2: |
| + print 'Expected exactly two arguments' |
| + sys.exit(1) |
| + |
| + extension_path = args[0] |
| + output_path = args[1] |
| + |
| + with ZipFile(output_path, 'w') as zip: |
| + for root, dirs, files in os.walk(extension_path): |
| + rel_path = os.path.join(os.path.relpath(root, extension_path), '') |
| + |
| + for file in files: |
| + extension_file = file |
| + if file in EXCLUDE_FILES: |
| + continue |
| + if file == 'manifest.json': |
| + extension_file = file |
| + file = MakeManifestEdits(root, file) |
| + |
| + zip.write( |
| + os.path.join(root, file), os.path.join(rel_path, extension_file)) |
| + # TODO(dtseng): Publish to webstore |
| + |
| +if __name__ == '__main__': |
| + main() |