blob: 3c6a615804b6edc5169ea700732e26e9c76930bd [file] [log] [blame]
Xixuan Wueefb21a2019-03-18 15:15:00 -07001# Copyright 2018 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
5"""Module for ChromeOS build utils without import external packages."""
6
7import logging
8
9
10def parse_full_model(full_model):
11 """Parse full model name to single board and model.
12
13 Args:
Shijin Abrahama8c74772020-01-24 09:39:25 -080014 full_model: A string, whose format is like 'board_model or
15 family_board_model'.
Xixuan Wueefb21a2019-03-18 15:15:00 -070016
17 Returns:
18 A tuple (board, model).
Shijin Abrahama8c74772020-01-24 09:39:25 -080019
20 Raises:
21 ValueError if the full_model is in wrong format.
Xixuan Wueefb21a2019-03-18 15:15:00 -070022 """
23 model_tokens = full_model.strip().split('_')
Shijin Abrahama8c74772020-01-24 09:39:25 -080024 if len(model_tokens) == 2:
Xixuan Wueefb21a2019-03-18 15:15:00 -070025 return model_tokens[0], model_tokens[1]
Xinan Lin6653d382020-03-03 10:41:13 -080026 if len(model_tokens) == 4:
27 return '_'.join(model_tokens[:2]), '_'.join(model_tokens[2:])
Shijin Abrahama8c74772020-01-24 09:39:25 -080028
29 logging.error('Invalid full_model format: %s', full_model)
30 raise ValueError