def main(argv): """Pack a list of files into a zip archive. Args: zip_path: The file name of the zip archive. base_dir: Base path of input files. locales: The list of locales that are used to generate the list of file names using INPUT_FILES. """ parser = optparse.OptionParser() parser.add_option("--output", dest="output") parser.add_option("--basedir", dest="basedir") parser.add_option("--include_google_admx", action="store_true", dest="include_google_admx", default=False) parser.add_option("--extra_input", action="append", dest="extra_input", default=[]) grd_helper.add_options(parser) options, args = parser.parse_args(argv[1:]) if (options.basedir[-1] != '/'): options.basedir += '/' file_list = options.extra_input file_list += grd_helper.get_grd_outputs(options) # Pick up google.admx/adml files. if (options.include_google_admx): google_file_list = [] for path in file_list: directory, filename = os.path.split(path) filename, extension = os.path.splitext(filename) if extension == ".admx" or extension == ".adml": google_file_list.append(\ os.path.join(options.basedir, directory, "google" + extension)) file_list.extend(google_file_list) zip_file = zipfile.ZipFile(options.output, 'w', zipfile.ZIP_DEFLATED) try: return add_files_to_zip(zip_file, options.basedir, file_list) finally: zip_file.close()
def main(argv): """Creates google.admx and google.adml files for every admx resp. adml files in the grit outputs. Usage: create_google_admx --basedir <dir> Base file path of output files. <grid options> Defined in grd_helper.py. """ parser = optparse.OptionParser() parser.add_option("--basedir", dest="basedir") grd_helper.add_options(parser) options, args = parser.parse_args(argv[1:]) file_list = grd_helper.get_grd_outputs(options) for path in file_list: directory, filename = os.path.split(path) filename, extension = os.path.splitext(filename) google_path = os.path.join(options.basedir, directory, "google" + extension) if extension == ".admx": CreateGoogleAdmx(google_path) elif extension == ".adml": CreateGoogleAdml(google_path)