acrn-config: refine board name with undline_name api

Sometimes character '-' or space need to be converted to '_' to make string format uniformed.
Add this common api to satisfy such requirment and refine the code for board name generating.

Tracked-On: #3852
Signed-off-by: Wei Liu <weix.w.liu@intel.com>
Acked-by: Victor Sun <victor.sun@intel.com>
This commit is contained in:
Wei Liu
2019-10-17 10:23:56 +08:00
committed by wenlingz
parent 95b9ba36b0
commit a2430f1313
6 changed files with 43 additions and 38 deletions

View File

@@ -622,3 +622,19 @@ def get_max_clos(board_file):
clos_max = int(line.split(':')[1])
return (cache_support, clos_max)
def undline_name(name):
"""
This convert name which has contain '-' to '_'
:param name: name which contain '-' and ' '
:return: name_str which contain'_'
"""
# convert '-' to '_' in name string
name_str = "_".join(name.split('-')).upper()
# stitch '_' while ' ' in name string
if ' ' in name_str:
name_str = "_".join(name_str.split()).upper()
return name_str