blob: eb4fc0882203a5b3f5752f88435a747721b1fd8e [file] [log] [blame]
# Copyright 2024 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Module for ChromeOS build utils without import external packages."""
import safe_log
def parse_full_model(full_model):
"""Parse full model name to single board and model.
Args:
full_model: A string, whose format is like 'board_model or
family_board_model'.
Returns:
A tuple (board, model).
Raises:
ValueError if the full_model is in wrong format.
"""
model_tokens = full_model.strip().split('_')
if len(model_tokens) == 2:
return model_tokens[0], model_tokens[1]
if len(model_tokens) == 4:
return '_'.join(model_tokens[:2]), '_'.join(model_tokens[2:])
safe_log.error('Invalid full_model format: %s', full_model)
raise ValueError