| OLD | NEW |
| (Empty) | |
| 1 #!/usr/bin/env python |
| 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 |
| 4 # found in the LICENSE file. |
| 5 |
| 6 """Creates google.admx and google.adml base files in all output folders. |
| 7 """ |
| 8 |
| 9 import grd_helper |
| 10 import optparse |
| 11 import os |
| 12 import sys |
| 13 |
| 14 |
| 15 def CreateGoogleAdmx(path): |
| 16 '''Creates an ADMX template at |path| that defines a Google namespace and a |
| 17 Google category. |
| 18 |
| 19 Args: |
| 20 path: File path to create the template at. |
| 21 ''' |
| 22 f = open(path, 'w') |
| 23 f.write("<?xml version=\"1.0\" ?>\n\ |
| 24 <policyDefinitions revision=\"1.0\" schemaVersion=\"1.0\">\n\ |
| 25 <policyNamespaces>\n\ |
| 26 <target namespace=\"Google.Policies\" prefix=\"Google\"/>\n\ |
| 27 </policyNamespaces>\n\ |
| 28 <resources minRequiredRevision=\"1.0\" />\n\ |
| 29 <categories>\n\ |
| 30 <category displayName=\"$(string.google)\" name=\"Cat_Google\"/>\n\ |
| 31 </categories>\n\ |
| 32 </policyDefinitions>\n") |
| 33 f.close() |
| 34 |
| 35 |
| 36 def CreateGoogleAdml(path): |
| 37 '''Creates an ADML template at |path| that defines a single string 'Google'. |
| 38 |
| 39 Args: |
| 40 path: File path to create the template at. |
| 41 ''' |
| 42 f = open(path, 'w') |
| 43 f.write("<?xml version=\"1.0\" ?>\n\ |
| 44 <policyDefinitionResources revision=\"1.0\" schemaVersion=\"1.0\">\n\ |
| 45 <displayName/>\n\ |
| 46 <description/>\n\ |
| 47 <resources>\n\ |
| 48 <stringTable>\n\ |
| 49 <string id=\"google\">Google</string>\n\ |
| 50 </stringTable>\n\ |
| 51 </resources>\n\ |
| 52 </policyDefinitionResources>\n") |
| 53 f.close() |
| 54 |
| 55 |
| 56 def main(argv): |
| 57 """Creates google.admx and google.adml files for every admx resp. adml files |
| 58 in the grit outputs. |
| 59 Usage: create_google_admx |
| 60 --basedir <dir> Base file path of output files. |
| 61 <grid options> Defined in grd_helper.py. |
| 62 """ |
| 63 parser = optparse.OptionParser() |
| 64 parser.add_option("--basedir", dest="basedir") |
| 65 grd_helper.add_options(parser) |
| 66 options, args = parser.parse_args(argv[1:]) |
| 67 |
| 68 file_list = grd_helper.get_grd_outputs(options) |
| 69 for path in file_list: |
| 70 directory, filename = os.path.split(path) |
| 71 filename, extension = os.path.splitext(filename) |
| 72 google_path = os.path.join(options.basedir, directory, "google" + extension) |
| 73 if extension == ".admx": |
| 74 CreateGoogleAdmx(google_path) |
| 75 elif extension == ".adml": |
| 76 CreateGoogleAdml(google_path) |
| 77 |
| 78 if '__main__' == __name__: |
| 79 sys.exit(main(sys.argv)) |
| OLD | NEW |