def main(argv): parsed_args = parse_args(argv[1:]) devtools_html = StringIO.StringIO() with open(parsed_args.inspector_html, 'r') as inspector_file: generate_devtools_html.write_devtools_html( inspector_file, devtools_html, True, parsed_args.devtools_files) zip = zipfile.ZipFile(parsed_args.output_filename, 'w', zipfile.ZIP_DEFLATED) zip.writestr("devtools.html", devtools_html.getvalue()) devtools_extension_api = StringIO.StringIO() generate_devtools_extension_api.write_devtools_extension_api( devtools_extension_api, parsed_args.extension_api_files) zip.writestr("devtools_extension_api.js", devtools_extension_api.getvalue()) js_extractor = concatenate_js_files.OrderedJSFilesExtractor( devtools_html.getvalue()) js_dirs = parsed_args.search_dirs + parsed_args.js_search_dirs expander = concatenate_js_files.PathExpander(js_dirs) files = js_extractor.ordered_js_files for input_file_name in set(files): full_path = expander.expand(input_file_name) if full_path is None: raise Exception('File %s referenced in %s not found on any source paths, ' 'check source tree for consistency' % (input_file_name, 'devtools.html')) zip.write(full_path, os.path.basename(full_path)) front_end_path = os.path.dirname(os.path.abspath(parsed_args.inspector_html)) for input_file_name in set(parsed_args.workers_files): script_path = os.path.dirname(os.path.abspath(input_file_name)) if script_path.startswith(front_end_path): script_path = script_path.replace(front_end_path, "") if len(script_path) > 0: script_path += '/' zip.write(input_file_name, script_path + os.path.basename(input_file_name)) else: raise Exception('Worker script %s is not from Inspector front-end dir' % (input_file_name)) for dirname in parsed_args.search_dirs: for filename in os.listdir(dirname): if filename.endswith('.css'): zip.write(os.path.join(dirname, filename), filename) dirname = os.path.join(dirname, 'Images') for filename in os.listdir(dirname): if filename.endswith('.png') or filename.endswith('.gif'): zip.write(os.path.join(dirname, filename), os.path.join('Images', filename)) # It would be nice to use the with statement to scope closing the archive, # but that wasn't added until python 2.7. zip.close()
def main(argv): parsed_args = parse_args(argv[1:]) devtools_html = StringIO.StringIO() with open(parsed_args.inspector_html, 'r') as inspector_file: generate_devtools_html.write_devtools_html( inspector_file, devtools_html, True, parsed_args.devtools_files) zip = zipfile.ZipFile(parsed_args.output_filename, 'w', zipfile.ZIP_DEFLATED) zip.writestr("devtools.html", devtools_html.getvalue()) css_extractor = concatenate_css_files.OrderedCSSFilesExtractor( devtools_html.getvalue()) js_extractor = concatenate_js_files.OrderedJSFilesExtractor( devtools_html.getvalue()) expander = concatenate_css_files.PathExpander(parsed_args.search_dirs) files = css_extractor.ordered_css_files + js_extractor.ordered_js_files for input_file_name in set(files): full_path = expander.expand(input_file_name) if full_path is None: raise Exception('File %s referenced in %s not found on any source paths, ' 'check source tree for consistency' % (input_file_name, 'devtools.html')) zip.write(full_path, os.path.basename(full_path)) for dirname in parsed_args.image_search_dirs: for filename in os.listdir(dirname): if not filename.endswith('.png') and not filename.endswith('.gif'): continue zip.write(os.path.join(dirname, filename), os.path.join('Images', filename)) # It would be nice to use the with statement to scope closing the archive, # but that wasn't added until python 2.7. zip.close()
def main(argv): parsed_args = parse_args(argv[1:]) devtools_html = StringIO.StringIO() with open(parsed_args.inspector_html, 'r') as inspector_file: generate_devtools_html.write_devtools_html(inspector_file, devtools_html, True, parsed_args.devtools_files) zip = zipfile.ZipFile(parsed_args.output_filename, 'w', zipfile.ZIP_DEFLATED) zip.writestr("devtools.html", devtools_html.getvalue()) devtools_extension_api = StringIO.StringIO() generate_devtools_extension_api.write_devtools_extension_api( devtools_extension_api, parsed_args.extension_api_files) zip.writestr("devtools_extension_api.js", devtools_extension_api.getvalue()) js_extractor = concatenate_js_files.OrderedJSFilesExtractor( devtools_html.getvalue()) js_dirs = parsed_args.search_dirs + parsed_args.js_search_dirs expander = concatenate_js_files.PathExpander(js_dirs) files = js_extractor.ordered_js_files for input_file_name in set(files): full_path = expander.expand(input_file_name) if full_path is None: raise Exception( 'File %s referenced in %s not found on any source paths, ' 'check source tree for consistency' % (input_file_name, 'devtools.html')) zip.write(full_path, os.path.basename(full_path)) front_end_path = os.path.dirname( os.path.abspath(parsed_args.inspector_html)) for input_file_name in set(parsed_args.workers_files): script_path = os.path.dirname(os.path.abspath(input_file_name)) if script_path.startswith(front_end_path): script_path = script_path.replace(front_end_path, "") if len(script_path) > 0: script_path += '/' zip.write(input_file_name, script_path + os.path.basename(input_file_name)) else: raise Exception( 'Worker script %s is not from Inspector front-end dir' % (input_file_name)) for dirname in parsed_args.search_dirs: for filename in os.listdir(dirname): if filename.endswith('.css'): zip.write(os.path.join(dirname, filename), filename) dirname = os.path.join(dirname, 'Images') for filename in os.listdir(dirname): if filename.endswith('.png') or filename.endswith('.gif'): zip.write(os.path.join(dirname, filename), os.path.join('Images', filename)) # It would be nice to use the with statement to scope closing the archive, # but that wasn't added until python 2.7. zip.close()