Chromium Code Reviews| Index: chrome/browser/resources/ssl/tls_error_assistant/gen_tls_error_assistant_proto.py |
| diff --git a/chrome/browser/resources/ssl/tls_error_assistant/gen_tls_error_assistant_proto.py b/chrome/browser/resources/ssl/tls_error_assistant/gen_tls_error_assistant_proto.py |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..f57a69b7acb35c5759d3d9e1d44f9b5b51a76b3f |
| --- /dev/null |
| +++ b/chrome/browser/resources/ssl/tls_error_assistant/gen_tls_error_assistant_proto.py |
| @@ -0,0 +1,40 @@ |
| +#!/usr/bin/python |
| +# Copyright 2016 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +""" |
| + Convert the ASCII tls_error_assistant.asciipb proto into a binary resource. |
| +""" |
| + |
| +import os |
| +import sys |
| + |
| +proto_generator_path = os.path.normpath(os.path.join(os.path.abspath(__file__), |
|
Nathan Parker
2016/12/10 00:56:50
Add a comment describing this magic incantation
meacer
2016/12/13 02:30:16
Done.
|
| + *[os.path.pardir] * 6 + ['chrome/browser/resources/protobufs'])) |
| +sys.path.insert(0, proto_generator_path) |
| +from binary_proto_generator import BinaryProtoGenerator |
| + |
| + |
| +class TLSErrorAssistantProtoGenerator(BinaryProtoGenerator): |
| + def ImportProtoModule(self): |
| + import tls_error_assistant_pb2 |
| + globals()['tls_error_assistant_pb2'] = tls_error_assistant_pb2 |
| + |
| + def EmptyProtoInstance(self): |
| + return tls_error_assistant_pb2.TLSErrorAssistantConfig() |
| + |
| + def ValidatePb(self, opts, pb): |
| + assert pb.version_id > 0; |
|
Nathan Parker
2016/12/10 00:56:50
How about verifying that there's at least one entr
meacer
2016/12/13 02:30:16
Done.
|
| + |
| + def ProcessPb(self, opts, pb): |
| + binary_pb_str = pb.SerializeToString() |
| + outfile = os.path.join(opts.outdir, opts.outbasename) |
| + open(outfile, 'wb').write(binary_pb_str) |
| + |
| + |
| +def main(): |
| + return TLSErrorAssistantProtoGenerator().Run() |
| + |
| +if __name__ == '__main__': |
| + sys.exit(main()) |