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 """Creates a directory with with the unpacked contents of the remoting webapp. | 6 """Creates a directory with with the unpacked contents of the remoting webapp. |
7 | 7 |
8 The directory will contain a copy-of or a link-to to all remoting webapp | 8 The directory will contain a copy-of or a link-to to all remoting webapp |
9 resources. This includes HTML/JS and any plugin binaries. The script also | 9 resources. This includes HTML/JS and any plugin binaries. The script also |
10 massages resulting files appropriately with host plugin data. Finally, | 10 massages resulting files appropriately with host plugin data. Finally, |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 # to create a symlink in that case. | 104 # to create a symlink in that case. |
105 targetname = os.path.relpath(os.path.realpath(current_file), | 105 targetname = os.path.relpath(os.path.realpath(current_file), |
106 os.path.realpath(destination_file)) | 106 os.path.realpath(destination_file)) |
107 os.symlink(targetname, destination_file) | 107 os.symlink(targetname, destination_file) |
108 else: | 108 else: |
109 shutil.copy2(current_file, destination_file) | 109 shutil.copy2(current_file, destination_file) |
110 | 110 |
111 # Copy all the locales, preserving directory structure | 111 # Copy all the locales, preserving directory structure |
112 destination_locales = os.path.join(destination, "_locales") | 112 destination_locales = os.path.join(destination, "_locales") |
113 os.mkdir(destination_locales , 0775) | 113 os.mkdir(destination_locales , 0775) |
114 chromium_locale_dir = "/_locales/" | 114 locale_dir = "/_locales/" |
115 chrome_locale_dir = "/_locales.official/" | |
116 for current_locale in locales: | 115 for current_locale in locales: |
117 pos = current_locale.find(chromium_locale_dir) | 116 pos = current_locale.find(locale_dir) |
118 locale_len = len(chromium_locale_dir) | |
119 if (pos == -1): | 117 if (pos == -1): |
120 pos = current_locale.find(chrome_locale_dir) | 118 raise Exception("Missing locales directory in " + current_locale) |
121 locale_len = len(chrome_locale_dir) | 119 subtree = current_locale[pos + len(locale_dir):] |
122 if (pos == -1): | |
123 raise "Missing locales directory in " + current_locale | |
124 subtree = current_locale[pos+locale_len:] | |
125 pos = subtree.find("/") | 120 pos = subtree.find("/") |
126 if (pos == -1): | 121 if (pos == -1): |
127 raise "Malformed locale: " + current_locale | 122 raise Exception("Malformed locale: " + current_locale) |
128 locale_id = subtree[:pos] | 123 locale_id = subtree[:pos] |
129 messages = subtree[pos+1:] | 124 messages = subtree[pos+1:] |
130 destination_dir = os.path.join(destination_locales, locale_id) | 125 destination_dir = os.path.join(destination_locales, locale_id) |
131 destination_file = os.path.join(destination_dir, messages) | 126 destination_file = os.path.join(destination_dir, messages) |
132 os.mkdir(destination_dir, 0775) | 127 os.mkdir(destination_dir, 0775) |
133 shutil.copy2(current_locale, destination_file) | 128 shutil.copy2(current_locale, destination_file) |
134 | 129 |
135 # Create fake plugin files to appease the manifest checker. | 130 # Create fake plugin files to appease the manifest checker. |
136 # It requires that if there is a plugin listed in the manifest that | 131 # It requires that if there is a plugin listed in the manifest that |
137 # there be a file in the plugin with that name. | 132 # there be a file in the plugin with that name. |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 else: | 219 else: |
225 files.append(arg) | 220 files.append(arg) |
226 | 221 |
227 buildWebApp(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5], | 222 buildWebApp(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5], |
228 sys.argv[6], files, locales) | 223 sys.argv[6], files, locales) |
229 return 0 | 224 return 0 |
230 | 225 |
231 | 226 |
232 if __name__ == '__main__': | 227 if __name__ == '__main__': |
233 sys.exit(main()) | 228 sys.exit(main()) |
OLD | NEW |