| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/python2.4 | |
| 2 # | |
| 3 # Copyright 2009 Google Inc. | |
| 4 # | |
| 5 # Licensed under the Apache License, Version 2.0 (the "License"); | |
| 6 # you may not use this file except in compliance with the License. | |
| 7 # You may obtain a copy of the License at | |
| 8 # | |
| 9 # http://www.apache.org/licenses/LICENSE-2.0 | |
| 10 # | |
| 11 # Unless required by applicable law or agreed to in writing, software | |
| 12 # distributed under the License is distributed on an "AS IS" BASIS, | |
| 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 14 # See the License for the specific language governing permissions and | |
| 15 # limitations under the License. | |
| 16 # ======================================================================== | |
| 17 | |
| 18 import getopt | |
| 19 import os.path | |
| 20 import re | |
| 21 import sys | |
| 22 | |
| 23 def GenerateResourceScript(input_filename, output_filename, payload_filename, | |
| 24 manifest_filename, resource_filename): | |
| 25 """ | |
| 26 Given a template name, output filename, payload filename, manifest filename, | |
| 27 and resource_filename, and creates a resource script. | |
| 28 """ | |
| 29 f_int = open(input_filename, 'r') | |
| 30 f_out = open(output_filename, 'w') | |
| 31 | |
| 32 for line in f_int.readlines(): | |
| 33 f_out.write(re.sub(r'__RESOURCE_FILENAME__', resource_filename, | |
| 34 re.sub(r'__MANIFEST_FILENAME__', manifest_filename, | |
| 35 re.sub(r'__PAYLOAD_FILENAME__', payload_filename, line)))) | |
| 36 | |
| 37 (opts, args) = getopt.getopt(sys.argv[1:], 'i:o:p:m:r:') | |
| 38 | |
| 39 input_filename = '' | |
| 40 output_filename = '' | |
| 41 payload_filename = '' | |
| 42 manifest_filename = '' | |
| 43 resource_filename = '' | |
| 44 | |
| 45 for (o, v) in opts: | |
| 46 if o == '-i': | |
| 47 input_filename = v | |
| 48 if o == '-o': | |
| 49 output_filename = v | |
| 50 if o == '-p': | |
| 51 payload_filename = v | |
| 52 if o == '-m': | |
| 53 manifest_filename = v | |
| 54 if o == '-r': | |
| 55 resource_filename = v | |
| 56 | |
| 57 # The forward slashes prevent the RC compiler from trying to interpret | |
| 58 # backslashes in the quoted path. | |
| 59 GenerateResourceScript(input_filename, output_filename, | |
| 60 re.sub(r'\\', r'/', payload_filename), | |
| 61 re.sub(r'\\', r'/', manifest_filename), | |
| 62 re.sub(r'\\', r'/', resource_filename)) | |
| OLD | NEW |