def main(): args_parser = argparse.ArgumentParser( description="Updates 'Chrome Browser Network Traffic Annotations' doc." ) args_parser.add_argument("--config-file", help="Configurations file.") args_parser.add_argument( "--annotations-file", help="TSV annotations file exported from auditor.") args_parser.add_argument("--verbose", action="store_true", help="Reports all updates. " " Also creates a scripts/template.json file " " outlining the document's current structure.") args_parser.add_argument("--config-help", action="store_true", help="Shows the configurations help.") args = args_parser.parse_args() if args.config_help: print_config_help() return 0 # Load and parse config file. with open(os.path.join(SRC_DIR, args.config_file)) as config_file: config = json.load(config_file) tsv_contents = load_tsv_file(os.path.join(SRC_DIR, args.annotations_file), False) if not tsv_contents: print("Could not read annotations file.") return -1 xml_parser = XMLParser( os.path.join(SRC_DIR, "tools/traffic_annotation/summary/grouping.xml"), map_annotations(tsv_contents)) placeholders = xml_parser.build_placeholders() print("#" * 40) print("There are:", len(placeholders), "placeholders") if args.verbose: print(placeholders) print("#" * 40) network_traffic_doc = NetworkTrafficAnnotationsDoc( doc_id=config["doc_id"], doc_name=config["doc_name"], credentials_file_path=config["credentials_file_path"], client_token_file_path=config["client_token_file_path"], verbose=args.verbose) if not network_traffic_doc.update_doc(placeholders): return -1 return 0