OLD | NEW |
---|---|
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
97 os.path.realpath(destination_file)) | 97 os.path.realpath(destination_file)) |
98 os.symlink(targetname, destination_file) | 98 os.symlink(targetname, destination_file) |
99 else: | 99 else: |
100 shutil.copy2(current_file, destination_file) | 100 shutil.copy2(current_file, destination_file) |
101 | 101 |
102 # Copy all the locales, preserving directory structure | 102 # Copy all the locales, preserving directory structure |
103 destination_locales = os.path.join(destination, "_locales") | 103 destination_locales = os.path.join(destination, "_locales") |
104 os.mkdir(destination_locales , 0775) | 104 os.mkdir(destination_locales , 0775) |
105 for current_locale in locales: | 105 for current_locale in locales: |
106 pos = current_locale.find("/_locales/") | 106 pos = current_locale.find("/_locales/") |
107 len = 10 | |
garykac
2011/09/08 17:18:34
Would it be better to strlen("/locales/") here rat
| |
108 if (pos == -1): | |
109 pos = current_locale.find("/_locales.official/") | |
110 len = 19 | |
107 if (pos == -1): | 111 if (pos == -1): |
108 raise "Missing locales directory in " + current_locale | 112 raise "Missing locales directory in " + current_locale |
109 subtree = current_locale[pos+10:] | 113 subtree = current_locale[pos+len:] |
110 pos = subtree.find("/") | 114 pos = subtree.find("/") |
111 if (pos == -1): | 115 if (pos == -1): |
112 raise "Malformed locale: " + current_locale | 116 raise "Malformed locale: " + current_locale |
113 locale_id = subtree[:pos] | 117 locale_id = subtree[:pos] |
114 messages = subtree[pos+1:] | 118 messages = subtree[pos+1:] |
115 destination_dir = os.path.join(destination_locales, locale_id) | 119 destination_dir = os.path.join(destination_locales, locale_id) |
116 destination_file = os.path.join(destination_dir, messages) | 120 destination_file = os.path.join(destination_dir, messages) |
117 os.mkdir(destination_dir, 0775) | 121 os.mkdir(destination_dir, 0775) |
118 shutil.copy2(current_locale, destination_file) | 122 shutil.copy2(current_locale, destination_file) |
119 | 123 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
176 locales.append(arg) | 180 locales.append(arg) |
177 else: | 181 else: |
178 files.append(arg) | 182 files.append(arg) |
179 | 183 |
180 buildWebApp(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], | 184 buildWebApp(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], |
181 sys.argv[5], files, locales) | 185 sys.argv[5], files, locales) |
182 | 186 |
183 | 187 |
184 if __name__ == '__main__': | 188 if __name__ == '__main__': |
185 main() | 189 main() |
OLD | NEW |