]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/UPT/Xml/IniToXml.py
BaseTools: Clean up source files
[mirror_edk2.git] / BaseTools / Source / Python / UPT / Xml / IniToXml.py
index aa6f23011b17e805dccbcdc827a39f71b5bdf14c..70d8fb19f2697d9b1c36aced87d26d1580a549f4 100644 (file)
@@ -3,9 +3,9 @@
 #\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
@@ -96,20 +96,20 @@ def ParseFileList(Line, Map, CurrentKey, PathFunc):
             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
@@ -143,7 +143,7 @@ def CreateHeaderXml(DistMap, Root):
 #\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
@@ -225,7 +225,7 @@ def ValidateRegValues(Key, Value):
 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
@@ -314,12 +314,12 @@ def IniToXml(IniFile):
                    '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
@@ -339,13 +339,13 @@ def IniToXml(IniFile):
             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
@@ -363,7 +363,7 @@ def IniToXml(IniFile):
                 #\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
@@ -374,7 +374,7 @@ def IniToXml(IniFile):
                 # 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
@@ -390,7 +390,7 @@ def IniToXml(IniFile):
         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
@@ -399,9 +399,9 @@ def IniToXml(IniFile):
                 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
@@ -411,17 +411,17 @@ def IniToXml(IniFile):
                                           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
@@ -433,15 +433,15 @@ def IniToXml(IniFile):
 # @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
@@ -464,10 +464,10 @@ def CheckMdtKeys(DistMap, IniFile, LastIndex, Maps):
         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
@@ -478,7 +478,7 @@ def CheckMdtKeys(DistMap, IniFile, LastIndex, Maps):
 # @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
@@ -493,7 +493,7 @@ def CreateXml(DistMap, ToolsMap, MiscMap, IniFile):
     else:\r
         FileName = IniFile + '.xml'\r
     File = open(FileName, 'w')\r
-    \r
+\r
     try:\r
         File.write(Root.toprettyxml(indent = '  '))\r
     finally:\r