acrn-config: fix pci sub class name contain "-" and ' '

Current python code could handle pci sub class name contain "-" as
expected, but some space characters may still exist. This patch support
to parse similar strings which contain "-" and ' ' for pci sub class name.

Also, add the index number as suffix for the similar strings

Tracked-On: #3788
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-09 10:18:51 +08:00 committed by ACRN System Integration
parent 43410fd008
commit bb1a8eea40
1 changed files with 10 additions and 7 deletions

View File

@ -65,14 +65,17 @@ def parser_pci():
def undline_name(name):
"""
This convert name which has contain '-' to '_'
:param name: name which contain '-'
:return:
:param name: name which contain '-' and ' '
:return: name_str which contain'_'
"""
name_list = name
if '-' in name:
name_list = "_".join(name.split('-'))
# convert '-' to '_' in name string
name_str = "_".join(name.split('-')).upper()
return name_list
# stitch '_' while ' ' in name string
if ' ' in name_str:
name_str = "_".join(name_str.split()).upper()
return name_str
def write_pbdf(i_cnt, bdf, subname, config):
@ -88,7 +91,7 @@ def write_pbdf(i_cnt, bdf, subname, config):
tmp_sub_name = "_".join(subname.split()).upper()
else:
if '-' in subname:
tmp_sub_name = undline_name(subname)
tmp_sub_name = undline_name(subname) + "_" + str(i_cnt)
else:
tmp_sub_name = "_".join(subname.split()).upper() + "_" + str(i_cnt)