Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Side by Side Diff: chrome/browser/resources/safe_browsing/gen_file_type_proto.py

Issue 1909653002: FileTypePolicies class to load types from proto. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: changes per jialiul, and set upstream CL Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright 2016 The Chromium Authors. All rights reserved. 2 # Copyright 2016 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """ 6 """
7 Convert the ASCII download_file_types.asciipb proto into a binary resource. 7 Convert the ASCII download_file_types.asciipb proto into a binary resource.
8 """ 8 """
9 9
10 import optparse 10 import optparse
(...skipping 17 matching lines...) Expand all
28 ifile.close() 28 ifile.close()
29 29
30 # Parse it into a structure PB 30 # Parse it into a structure PB
31 pb = config_pb2.DownloadFileTypeConfig() 31 pb = config_pb2.DownloadFileTypeConfig()
32 text_format.Merge(ascii_pb_str, pb) 32 text_format.Merge(ascii_pb_str, pb)
33 33
34 # Serialize it 34 # Serialize it
35 binary_pb_str = pb.SerializeToString() 35 binary_pb_str = pb.SerializeToString()
36 36
37 # Write it to disk 37 # Write it to disk
38 open(opts.outfile, 'w').write(binary_pb_str) 38 open(opts.outfile, 'wb').write(binary_pb_str)
39 39
40 40
41 def main(): 41 def main():
42 parser = optparse.OptionParser() 42 parser = optparse.OptionParser()
43 # TODO(nparker): Remove this once the bug is fixed. 43 # TODO(nparker): Remove this once the bug is fixed.
44 parser.add_option('-w', '--wrap', action="store_true", default=False, 44 parser.add_option('-w', '--wrap', action="store_true", default=False,
45 help='Wrap this script in another python ' 45 help='Wrap this script in another python '
46 'execution to disable site-packages. This is a ' 46 'execution to disable site-packages. This is a '
47 'fix for http://crbug.com/605592') 47 'fix for http://crbug.com/605592')
48 parser.add_option('-i', '--infile', 48 parser.add_option('-i', '--infile',
(...skipping 20 matching lines...) Expand all
69 69
70 try: 70 try:
71 ConvertProto(opts) 71 ConvertProto(opts)
72 except Exception as e: 72 except Exception as e:
73 print "ERROR: %s failed to parse ASCII proto\n%s: %s\n" % ( 73 print "ERROR: %s failed to parse ASCII proto\n%s: %s\n" % (
74 sys.argv, opts.infile, str(e)) 74 sys.argv, opts.infile, str(e))
75 return 1 75 return 1
76 76
77 if __name__ == '__main__': 77 if __name__ == '__main__':
78 sys.exit(main()) 78 sys.exit(main())
OLDNEW
« no previous file with comments | « chrome/browser/resources/safe_browsing/download_file_types.asciipb ('k') | chrome/chrome_common.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698