Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Side by Side Diff: chrome/tools/build/win/make_policy_zip.py

Issue 6969064: Start generating translated policy templates (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: activate translations for mac Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 """Creates a zip archive with policy template files. The list of input files is
6 specified by the list of available translations. This is to keep the length of
7 input arguments below the limit on Windows.
8 """
9
10 import sys
11 import zipfile
12
13 # The following list specifies the files to be archived. Items containing the
14 # substring ZZLOCALE will be replicated for each specified locale with ZZLOCALE
15 # replaced with the respective locale.
16 FILE_NAME_PATTERNS = [
17 'VERSION',
18 # The following elements of the list should be in sync with the outputs
19 # specified for Windows in app/policy/policy_templates.grd
tony 2011/05/19 18:49:24 Hmm, is it possible for you to import tools/grit/g
gfeher 2011/05/20 20:32:48 It required hacking, but I guess it worthed it. Do
20 'linux/examples/chrome.json',
21 'windows/examples/chrome.reg',
22 'windows/admx/chrome.admx',
23 'windows/admx/ZZLOCALE/chrome.adml',
24 'windows/adm/ZZLOCALE/chrome.adm',
25 'common/html/ZZLOCALE/chrome_policy_list.html',
26 ]
27
28 def add_files_to_zip(zip_file, base_dir, file_list):
29 """Pack a list of files into a zip archive, that is already
30 opened for writing.
31
32 Args:
33 zip_file: An object representing the zip archive.
34 base_dir: Base path of all the files in the real file system.
35 files: List of file paths to add, all relative to base_dir.
36 The zip entries will only contain this componenet of the path.
37 """
38 for file_path in file_list:
39 zip_file.write(base_dir + file_path, file_path)
40 return 0
41
42 def locales_to_file_names(file_name_patterns, locales):
43 """Combines |file_name_patterns| and |locales| into a list of file paths.
44 Each entry in file_name_patterns containing the substring ZZLOCALE will
45 be included in the result for each locale with ZZLOCALE replaced with
46 the respective locale.
47 """
48 result = []
49 for f in file_name_patterns:
50 if 'ZZLOCALE' in f:
51 for locale in locales:
52 result.append(f.replace('ZZLOCALE', locale))
53 else:
54 result.append(f)
55 return result
56
57 def main(zip_path, base_dir, locales):
58 """Pack a list of files into a zip archive.
59
60 Args:
61 zip_path: The file name of the zip archive.
62 base_dir: Base path of input files.
63 locales: The list of locales that are used to generate the list of file
64 names using INPUT_FILES.
65 """
66 if (base_dir[-1] != '/'):
67 base_dir = base_dir + '/'
68
69 file_list = locales_to_file_names(FILE_NAME_PATTERNS, locales)
70 zip_file = zipfile.ZipFile(zip_path, 'w', zipfile.ZIP_DEFLATED)
71 try:
72 return add_files_to_zip(zip_file, base_dir, file_list)
73 finally:
74 zip_file.close()
75
76 if '__main__' == __name__:
77 if len(sys.argv) < 4:
78 print "usage: %s output.zip path/to/base/dir list of locales" % sys.argv[0]
79 sys.exit(1)
80
81 sys.exit(main(sys.argv[1], sys.argv[2], sys.argv[3:]))
OLDNEW
« no previous file with comments | « chrome/app/policy/policy_templates.gypi ('k') | chrome/tools/build/win/make_zip_with_relative_entries.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698