config-tools: change name for board XML

Use file name as the board xml name instead of using the name in
'board' field in board XML.

e.g.

1. Initial filename is "my_potato.xml"
2. User imports my_potato.xml into the Configurator
3. Resulting file is my_potato.board.xml

Tracked-On: #7521
Signed-off-by: Conghui <conghui.chen@intel.com>
This commit is contained in:
Conghui 2022-05-18 22:34:07 +08:00 committed by acrnsi-robot
parent 777cfae536
commit 6a0ada0a91
3 changed files with 20 additions and 9 deletions

View File

@ -22,8 +22,9 @@ class PythonObject {
}
}
loadBoard(boardXMLText) {
return this.api('loadBoard', 'json', boardXMLText)
loadBoard(boardXMLText, path) {
return this.api('loadBoard', 'json', boardXMLText, path)
}
loadScenario(scenarioXMLText) {
@ -120,7 +121,7 @@ class Configurator {
if (syntactical_errors !== "") {
throw Error("The file has broken structure.");
}
return this.pythonObject.loadBoard(fileContent);
return this.pythonObject.loadBoard(fileContent, path);
})
}

View File

@ -2,13 +2,15 @@
__package__ = 'configurator.pyodide'
import json
import logging
import re
from copy import deepcopy
import elementpath
import lxml.etree as etree
from bs4 import BeautifulSoup
from . import convert_result, nuc11_board, scenario_json_schema
from . import convert_result, nuc11_board, scenario_json_schema,nuc11_board_path
def get_dynamic_scenario(board):
@ -73,10 +75,17 @@ def get_dynamic_scenario(board):
return form_schemas
def get_board_info(board):
def get_board_info(board, path):
soup = BeautifulSoup(board, 'xml')
try:
board_name = re.split('[\\\\/.]', path)[-2]
if board_name == 'board':
board_name = re.split('[\\\\/.]', path)[-3]
except IndexError as e:
logging.warning(e)
board_name = 'default'
result = {
'name': soup.select_one('acrn-config').attrs['board'] + '.board.xml',
'name': board_name + '.board.xml',
'content': board,
'BIOS_INFO': soup.select_one('BIOS_INFO').text,
'BASE_BOARD_INFO': soup.select_one('BASE_BOARD_INFO').text
@ -84,16 +93,16 @@ def get_board_info(board):
return result
def load_board(board):
def load_board(board, path):
result = {
'scenarioJSONSchema': get_dynamic_scenario(board),
'boardInfo': get_board_info(board)
'boardInfo': get_board_info(board, path)
}
return convert_result(result)
def test():
load_board(nuc11_board)
load_board(nuc11_board, nuc11_board_path)
main = load_board

View File

@ -27,6 +27,7 @@ scenario_xml_schema_path = schema_dir / 'sliced.xsd'
datachecks_xml_schema_path = schema_dir / 'allchecks.xsd'
nuc11_folder = LazyPath(config_tools_dir / 'data' / 'nuc11tnbi5')
nuc11_board_path = nuc11_folder / 'nuc11tnbi5.xml'
# file define
nuc11_board = file_text(nuc11_folder / 'nuc11tnbi5.xml')