Have checker.py read config pbs in program and project repos.
- Also move to discussed layout, with top-level payload_utils
package.
BUG=chromium:1051187
TEST=generate.sh
TEST=python unittests
TEST=checker.py --program=../program/volteer\
--project=../project/volteer/volteer
Change-Id: I38976fc743c9695356e4d81f986021fe87842a2b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/config/+/2051089
Commit-Queue: Andrew Lamb <andrewlamb@chromium.org>
Tested-by: Andrew Lamb <andrewlamb@chromium.org>
Reviewed-by: Chris McDonald <cjmcdonald@chromium.org>
diff --git a/payload_utils/checker/io_utils.py b/payload_utils/checker/io_utils.py
new file mode 100644
index 0000000..a327efe
--- /dev/null
+++ b/payload_utils/checker/io_utils.py
@@ -0,0 +1,21 @@
+# Copyright 2020 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+"""IO-related helper functions."""
+
+import os
+
+from bindings.src.config.api import config_bundle_pb2
+
+
+def read_repo_config(repo_path: str) -> config_bundle_pb2.ConfigBundle:
+ """Reads a binary proto from a file in a program or project repo.
+
+ Args:
+ repo_path: Path to the root of the program or project repo.
+ """
+ project_config = config_bundle_pb2.ConfigBundle()
+ with open(os.path.join(repo_path, 'generated', 'config.binaryproto'),
+ 'rb') as f:
+ project_config.ParseFromString(f.read())
+ return project_config