#\r
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r
#\r
-# This program and the accompanying materials are licensed and made available \r
-# under the terms and conditions of the BSD License which accompanies this \r
-# distribution. The full text of the license may be found at \r
+# This program and the accompanying materials are licensed and made available\r
+# under the terms and conditions of the BSD License which accompanies this\r
+# distribution. The full text of the license may be found at\r
# http://opensource.org/licenses/bsd-license.php\r
#\r
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
Attr = Token.split(TAB_EQUAL_SPLIT)\r
if len(Attr) != 2 or not Attr[0].strip() or not Attr[1].strip():\r
return False, ST.ERR_WRONG_FILELIST_FORMAT\r
- \r
+\r
Key = Attr[0].strip()\r
Val = Attr[1].strip()\r
if Key not in ['OS', 'Executable']:\r
return False, ST.ERR_UNKNOWN_FILELIST_ATTR % Key\r
- \r
- if Key == 'OS' and Val not in ["Win32", "Win64", "Linux32", \r
- "Linux64", "OS/X32", "OS/X64", \r
+\r
+ if Key == 'OS' and Val not in ["Win32", "Win64", "Linux32",\r
+ "Linux64", "OS/X32", "OS/X64",\r
"GenericWin", "GenericNix"]:\r
return False, ST.ERR_FILELIST_ATTR % 'OS'\r
elif Key == 'Executable' and Val not in ['true', 'false']:\r
return False, ST.ERR_FILELIST_ATTR % 'Executable'\r
FileList[1][Key] = Val\r
- \r
+\r
Map[CurrentKey].append(FileList)\r
return True, ''\r
\r
#\r
# @param Map: Map\r
# @param Root: Root\r
-# @param Tag: Tag \r
+# @param Tag: Tag\r
#\r
def CreateToolsXml(Map, Root, Tag):\r
#\r
def __ValidateDistHeaderName(Name):\r
if len(Name) < 1:\r
return False\r
- \r
+\r
for Char in Name:\r
if ord(Char) < 0x20 or ord(Char) >= 0x7f:\r
return False\r
'ToolsHeader' : ToolsMap,\r
'MiscellaneousFilesHeader' : MiscMap\r
}\r
- \r
+\r
PathValidator = {\r
'ToolsHeader' : ValidateToolsFile,\r
'MiscellaneousFilesHeader' : ValidateMiscFile\r
}\r
- \r
+\r
ParsedSection = []\r
\r
SectionName = ''\r
if SectionName not in SectionMap:\r
IniParseError(ST.ERR_SECTION_NAME_INVALID % SectionName,\r
IniFile, Index+1)\r
- \r
+\r
if SectionName in ParsedSection:\r
IniParseError(ST.ERR_SECTION_REDEFINE % SectionName,\r
IniFile, Index+1)\r
else:\r
ParsedSection.append(SectionName)\r
- \r
+\r
Map = SectionMap[SectionName]\r
continue\r
if not Map:\r
#\r
# Special for FileList\r
#\r
- Valid, Cause = ParseFileList(Line, Map, CurrentKey, \r
+ Valid, Cause = ParseFileList(Line, Map, CurrentKey,\r
PathValidator[SectionName])\r
if not Valid:\r
IniParseError(Cause, IniFile, Index+1)\r
# Or if string on the left side of '=' is not a keyword\r
#\r
Map[CurrentKey] = ''.join([Map[CurrentKey], '\n', Line])\r
- Valid, Cause = ValidateValues(CurrentKey, \r
+ Valid, Cause = ValidateValues(CurrentKey,\r
Map[CurrentKey], SectionName)\r
if not Valid:\r
IniParseError(Cause, IniFile, Index+1)\r
if Map[CurrentKey]:\r
IniParseError(ST.ERR_KEYWORD_REDEFINE % CurrentKey,\r
IniFile, Index+1)\r
- \r
+\r
if id(Map) != id(PreMap) and Map['Copyright']:\r
PreMap = Map\r
Copyright = Map['Copyright'].lower()\r
IniParseError(ST.ERR_COPYRIGHT_CONTENT, IniFile, Index)\r
if not Copyright[Pos + len('copyright'):].lstrip(' ').startswith('('):\r
IniParseError(ST.ERR_COPYRIGHT_CONTENT, IniFile, Index)\r
- \r
+\r
if CurrentKey == 'FileList':\r
- Valid, Cause = ParseFileList(TokenList[1], Map, CurrentKey, \r
+ Valid, Cause = ParseFileList(TokenList[1], Map, CurrentKey,\r
PathValidator[SectionName])\r
if not Valid:\r
IniParseError(Cause, IniFile, Index+1)\r
Map[CurrentKey], SectionName)\r
if not Valid:\r
IniParseError(Cause, IniFile, Index+1)\r
- \r
+\r
if id(Map) != id(PreMap) and Map['Copyright'] and 'copyright' not in Map['Copyright'].lower():\r
IniParseError(ST.ERR_COPYRIGHT_CONTENT, IniFile, LastIndex)\r
\r
#\r
# Check mandatory keys\r
- # \r
- CheckMdtKeys(DistMap, IniFile, LastIndex, \r
+ #\r
+ CheckMdtKeys(DistMap, IniFile, LastIndex,\r
(('ToolsHeader', ToolsMap), ('MiscellaneousFilesHeader', MiscMap))\r
)\r
- \r
+\r
return CreateXml(DistMap, ToolsMap, MiscMap, IniFile)\r
\r
\r
# @param LastIndex: Last index of Ini file\r
# @param Maps: Tools and Misc section name and map. (('section_name', map),*)\r
#\r
-def CheckMdtKeys(DistMap, IniFile, LastIndex, Maps): \r
+def CheckMdtKeys(DistMap, IniFile, LastIndex, Maps):\r
MdtDistKeys = ['Name', 'GUID', 'Version', 'Vendor', 'Copyright', 'License', 'Abstract', 'XmlSpecification']\r
for Key in MdtDistKeys:\r
if Key not in DistMap or DistMap[Key] == '':\r
IniParseError(ST.ERR_KEYWORD_MANDATORY % Key, IniFile, LastIndex+1)\r
- \r
+\r
if '.' not in DistMap['Version']:\r
DistMap['Version'] = DistMap['Version'] + '.0'\r
- \r
+\r
DistMap['Date'] = str(strftime("%Y-%m-%dT%H:%M:%S", localtime()))\r
\r
#\r
for Key in Map:\r
if Map[Key]:\r
NonEmptyKey += 1\r
- \r
+\r
if NonEmptyKey > 0 and not Map['FileList']:\r
IniParseError(ST.ERR_KEYWORD_MANDATORY % (Item[0] + '.FileList'), IniFile, LastIndex+1)\r
- \r
+\r
if NonEmptyKey > 0 and not Map['Name']:\r
IniParseError(ST.ERR_KEYWORD_MANDATORY % (Item[0] + '.Name'), IniFile, LastIndex+1)\r
\r
# @param MiscMap: Misc Content\r
# @param IniFile: Ini File\r
#\r
-def CreateXml(DistMap, ToolsMap, MiscMap, IniFile): \r
+def CreateXml(DistMap, ToolsMap, MiscMap, IniFile):\r
Attrs = [['xmlns', 'http://www.uefi.org/2011/1.1'],\r
['xmlns:xsi', 'http:/www.w3.org/2001/XMLSchema-instance'],\r
]\r
else:\r
FileName = IniFile + '.xml'\r
File = open(FileName, 'w')\r
- \r
+\r
try:\r
File.write(Root.toprettyxml(indent = ' '))\r
finally:\r