IniToXml.py revision 4fd606d1f5abe38e1f42c38de1d2e895166bd0f4
2N/A# This file is for converting package information data file to xml file. 2N/A# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR> 2N/A# This program and the accompanying materials are licensed and made available 2N/A# under the terms and conditions of the BSD License which accompanies this 2N/A# distribution. The full text of the license may be found at 2N/A# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 2N/A# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 2N/A# @param error: error 2N/A# @param Path: Path to be checked # @param Filename: File to be checked # @param Filename: File to be checked # @param CurrentKey: CurrentKey # @param PathFunc: Path validate function if Key not in [
'OS',
'Executable']:
if Key ==
'OS' and Val not in [
"Win32",
"Win64",
"Linux32",
"GenericWin",
"GenericNix"]:
elif Key ==
'Executable' and Val not in [
'true',
'false']:
## Create header XML file # @param DistMap: DistMap [], [[
'BaseName',
DistMap[
'BaseName']]])
[], [[
'Version',
DistMap[
'Version']]])
[
'RePackage',
DistMap[
'RePackage']]]
[
'Copyright',
DistMap[
'Copyright']],
[
'Description',
DistMap[
'Description']],
[
'Signature',
DistMap[
'Signature']],
[
'XmlSpecification',
DistMap[
'XmlSpecification']],
# Check if all elements in this section are empty [
'Copyright',
Map[
'Copyright']],
[
'License',
Map[
'License']],
[
'Abstract',
Map[
'Abstract']],
[
'Description',
Map[
'Description']],
# @param SectionName: SectionName (
'[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}' '-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}',
## __ValidateDistHeaderName ## __ValidateDistHeaderBaseName # @param BaseName: BaseName # if CheckLen and len(BaseName) < 2: ## __ValidateDistHeaderAbstract # @param Abstract: Abstract ## __ValidateOtherHeaderAbstract # @param Abstract: Abstract ## Convert ini file to xml file DistMap = {
'ReadOnly' :
'',
'RePackage' :
'',
'Name' :
'',
'BaseName' :
'',
'GUID' :
'',
'Version' :
'',
'Vendor' :
'',
'Date' :
'',
'Copyright' :
'',
'License' :
'',
'Abstract' :
'',
'Description' :
'',
'Signature' :
'',
'XmlSpecification' :
'' ToolsMap = {
'Name' :
'',
'Copyright' :
'',
'License' :
'',
'Abstract' :
'',
'Description' :
'',
'FileList' : []}
# Only FileList is a list: [['file1', {}], ['file2', {}], ...] MiscMap = {
'Name' :
'',
'Copyright' :
'',
'License' :
'',
'Abstract' :
'',
'Description' :
'',
'FileList' : []}
'MiscellaneousFilesHeader' :
MiscMap # Value spanned multiple or same keyword appears more than one time # Multiple lines for one key such as license # Or if string on the left side of '=' is not a keyword # @param MdtDistKeys: All mandatory keys # @param DistMap: Dist content # @param IniFile: Ini file # @param LastIndex: Last index of Ini file # @param Maps: Tools and Misc section name and map. (('section_name', map),*) MdtDistKeys = [
'Name',
'GUID',
'Version',
'Vendor',
'Copyright',
'License',
'Abstract',
'XmlSpecification']
# Check Tools Surface Area according to UPT Spec # <Header> ... </Header> {0,1} # <Filename> ... </Filename> {1,} # <Name> xs:normalizedString </Name> {1} # <Copyright> xs:string </Copyright> {0,1} # <License> xs:string </License> {0,1} # <Abstract> xs:normalizedString </Abstract> {0,1} # <Description> xs:string </Description> {0,1} # @param DistMap: Dist Content # @param ToolsMap: Tools Content # @param MiscMap: Misc Content # @param IniFile: Ini File [
'xmlns:xsi',
'http:/www.w3.org/2001/XMLSchema-instance'],