Xixuan Wu | eefb21a | 2019-03-18 15:15:00 -0700 | [diff] [blame] | 1 | # 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 | |
| 7 | import logging |
| 8 | |
| 9 | |
| 10 | def parse_full_model(full_model): |
| 11 | """Parse full model name to single board and model. |
| 12 | |
| 13 | Args: |
Shijin Abraham | a8c7477 | 2020-01-24 09:39:25 -0800 | [diff] [blame] | 14 | full_model: A string, whose format is like 'board_model or |
| 15 | family_board_model'. |
Xixuan Wu | eefb21a | 2019-03-18 15:15:00 -0700 | [diff] [blame] | 16 | |
| 17 | Returns: |
| 18 | A tuple (board, model). |
Shijin Abraham | a8c7477 | 2020-01-24 09:39:25 -0800 | [diff] [blame] | 19 | |
| 20 | Raises: |
| 21 | ValueError if the full_model is in wrong format. |
Xixuan Wu | eefb21a | 2019-03-18 15:15:00 -0700 | [diff] [blame] | 22 | """ |
| 23 | model_tokens = full_model.strip().split('_') |
Shijin Abraham | a8c7477 | 2020-01-24 09:39:25 -0800 | [diff] [blame] | 24 | if len(model_tokens) == 2: |
Xixuan Wu | eefb21a | 2019-03-18 15:15:00 -0700 | [diff] [blame] | 25 | return model_tokens[0], model_tokens[1] |
Xinan Lin | 6653d38 | 2020-03-03 10:41:13 -0800 | [diff] [blame] | 26 | if len(model_tokens) == 4: |
| 27 | return '_'.join(model_tokens[:2]), '_'.join(model_tokens[2:]) |
Shijin Abraham | a8c7477 | 2020-01-24 09:39:25 -0800 | [diff] [blame] | 28 | |
| 29 | logging.error('Invalid full_model format: %s', full_model) |
| 30 | raise ValueError |