Andrew Lamb | eceaec0 | 2020-02-11 14:16:41 -0700 | [diff] [blame] | 1 | # Copyright 2020 The Chromium OS Authors. All rights reserved. |
| 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | """IO-related helper functions.""" |
| 5 | |
| 6 | import os |
| 7 | |
Andrew Lamb | bc029d3 | 2020-02-24 12:42:50 -0700 | [diff] [blame] | 8 | from bindings.api import config_bundle_pb2 |
Andrew Lamb | eceaec0 | 2020-02-11 14:16:41 -0700 | [diff] [blame] | 9 | |
| 10 | |
| 11 | def read_repo_config(repo_path: str) -> config_bundle_pb2.ConfigBundle: |
| 12 | """Reads a binary proto from a file in a program or project repo. |
| 13 | |
| 14 | Args: |
| 15 | repo_path: Path to the root of the program or project repo. |
| 16 | """ |
| 17 | project_config = config_bundle_pb2.ConfigBundle() |
| 18 | with open(os.path.join(repo_path, 'generated', 'config.binaryproto'), |
| 19 | 'rb') as f: |
| 20 | project_config.ParseFromString(f.read()) |
| 21 | return project_config |