blob: 4fb4981d019f57990d2228bf533303ac942555d3 [file] [log] [blame]
Andrew Lambeceaec02020-02-11 14:16:41 -07001# 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
6import os
7
Prathmesh Prabhu72f8a002020-04-10 09:57:53 -07008from chromiumos.config.payload import config_bundle_pb2
Andrew Lambeceaec02020-02-11 14:16:41 -07009
10
Andrew Lamb9328c402020-03-05 12:57:59 -070011def read_config(path: str) -> config_bundle_pb2.ConfigBundle:
12 """Reads a binary proto from a file.
13
Andrew Lambeceaec02020-02-11 14:16:41 -070014 Args:
Andrew Lamb9328c402020-03-05 12:57:59 -070015 path: Path to the binary proto. See note above about deprecated repo
16 root behavior.
Andrew Lambeceaec02020-02-11 14:16:41 -070017 """
18 project_config = config_bundle_pb2.ConfigBundle()
Andrew Lamb9328c402020-03-05 12:57:59 -070019 with open(os.path.join(path), 'rb') as f:
Andrew Lambeceaec02020-02-11 14:16:41 -070020 project_config.ParseFromString(f.read())
21 return project_config