]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/UPT/Library/Misc.py
BaseTools: Clean up source files
[mirror_edk2.git] / BaseTools / Source / Python / UPT / Library / Misc.py
index 28471d81238aeb283e4cea9a8a569e73d43e2966..8c2a6787f0c16ef25cc13235e36e172c1b7b5cb7 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
@@ -52,7 +52,7 @@ from Object.POM.CommonObject import TextObject
 from Core.FileHook import __FileHookOpen__\r
 from Common.MultipleWorkspace import MultipleWorkspace as mws\r
 \r
-## Convert GUID string in xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx style to C \r
+## Convert GUID string in xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx style to C\r
 # structure style\r
 #\r
 # @param      Guid:    The GUID string\r
@@ -87,7 +87,7 @@ def CheckGuidRegFormat(GuidValue):
         return False\r
 \r
 \r
-## Convert GUID string in C structure style to \r
+## Convert GUID string in C structure style to\r
 # xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\r
 #\r
 # @param      GuidValue:   The GUID value in C structure format\r
@@ -151,12 +151,12 @@ def RemoveDirectory(Directory, Recursively=False):
 ## Store content in file\r
 #\r
 # This method is used to save file only when its content is changed. This is\r
-# quite useful for "make" system to decide what will be re-built and what \r
+# quite useful for "make" system to decide what will be re-built and what\r
 # won't.\r
 #\r
 # @param      File:            The path of file\r
 # @param      Content:         The new content of the file\r
-# @param      IsBinaryFile:    The flag indicating if the file is binary file \r
+# @param      IsBinaryFile:    The flag indicating if the file is binary file\r
 #                              or not\r
 #\r
 def SaveFileOnChange(File, Content, IsBinaryFile=True):\r
@@ -216,7 +216,7 @@ def GetFiles(Root, SkipList=None, FullPath=True):
 # @param FullPath:  True if the returned file should be full path\r
 # @param PrefixPath: the path that need to be added to the files found\r
 # @return: the list of files found\r
-#  \r
+#\r
 def GetNonMetaDataFiles(Root, SkipList, FullPath, PrefixPath):\r
     FileList = GetFiles(Root, SkipList, FullPath)\r
     NewFileList = []\r
@@ -602,25 +602,25 @@ def GetWorkspace():
 ## Get relative path\r
 #\r
 #  use full path and workspace to get relative path\r
-#  the destination of this function is mainly to resolve the root path issue(like c: or c:\)  \r
+#  the destination of this function is mainly to resolve the root path issue(like c: or c:\)\r
 #\r
 #  @param Fullpath: a string of fullpath\r
 #  @param Workspace: a string of workspace\r
 #\r
 def GetRelativePath(Fullpath, Workspace):\r
-    \r
+\r
     RelativePath = ''\r
     if Workspace.endswith(os.sep):\r
         RelativePath = Fullpath[Fullpath.upper().find(Workspace.upper())+len(Workspace):]\r
     else:\r
         RelativePath = Fullpath[Fullpath.upper().find(Workspace.upper())+len(Workspace)+1:]\r
-        \r
+\r
     return RelativePath\r
-    \r
+\r
 ## Check whether all module types are in list\r
 #\r
 # check whether all module types (SUP_MODULE_LIST) are in list\r
-#  \r
+#\r
 # @param ModuleList:  a list of ModuleType\r
 #\r
 def IsAllModuleList(ModuleList):\r
@@ -632,9 +632,9 @@ def IsAllModuleList(ModuleList):
         return True\r
 \r
 ## Dictionary that use comment(GenericComment, TailComment) as value,\r
-# if a new comment which key already in the dic is inserted, then the \r
+# if a new comment which key already in the dic is inserted, then the\r
 # comment will be merged.\r
-# Key is (Statement, SupArch), when TailComment is added, it will ident \r
+# Key is (Statement, SupArch), when TailComment is added, it will ident\r
 # according to Statement\r
 #\r
 class MergeCommentDict(dict):\r
@@ -671,7 +671,7 @@ def GenDummyHelpTextObj():
 # <Major>               ::=  (a-fA-F0-9){4}\r
 # <Minor>               ::=  (a-fA-F0-9){4}\r
 # <DecVersion>          ::=  (0-65535) ["." (0-99)]\r
-# \r
+#\r
 # @param StringIn:  The string contains version defined in INF file.\r
 #                   It can be Decimal or Hex\r
 #\r
@@ -764,7 +764,7 @@ def ConvertPath(Path):
 \r
 ## ConvertSpec\r
 #\r
-# during install, convert the Spec string extract from UPD into INF allowable definition, \r
+# during install, convert the Spec string extract from UPD into INF allowable definition,\r
 # the difference is period is allowed in the former (not the first letter) but not in the latter.\r
 # return converted Spec string\r
 #\r
@@ -787,7 +787,7 @@ def ConvertSpec(SpecStr):
 # The rule is elements in List A are in List B and elements in List B are in List A.\r
 #\r
 # @param ListA, ListB  Lists need to be judged.\r
-# \r
+#\r
 # @return True  ListA and ListB are identical\r
 # @return False ListA and ListB are different with each other\r
 #\r
@@ -808,10 +808,10 @@ def IsEqualList(ListA, ListB):
 ## ConvertArchList\r
 #\r
 # Convert item in ArchList if the start character is lower case.\r
-# In UDP spec, Arch is only allowed as: [A-Z]([a-zA-Z0-9])* \r
+# In UDP spec, Arch is only allowed as: [A-Z]([a-zA-Z0-9])*\r
 #\r
 # @param ArchList The ArchList need to be converted.\r
-# \r
+#\r
 # @return NewList  The ArchList been converted.\r
 #\r
 def ConvertArchList(ArchList):\r
@@ -835,7 +835,7 @@ def ConvertArchList(ArchList):
 # If one line ends with a line extender, then it will be combined together with next line.\r
 #\r
 # @param LineList The LineList need to be processed.\r
-# \r
+#\r
 # @return NewList  The ArchList been processed.\r
 #\r
 def ProcessLineExtender(LineList):\r
@@ -854,11 +854,11 @@ def ProcessLineExtender(LineList):
 \r
 ## ProcessEdkComment\r
 #\r
-# Process EDK style comment in LineList: c style /* */ comment or cpp style // comment \r
+# Process EDK style comment in LineList: c style /* */ comment or cpp style // comment\r
 #\r
 #\r
 # @param LineList The LineList need to be processed.\r
-# \r
+#\r
 # @return LineList  The LineList been processed.\r
 # @return FirstPos  Where Edk comment is first found, -1 if not found\r
 #\r
@@ -868,7 +868,7 @@ def ProcessEdkComment(LineList):
     StartPos = -1\r
     EndPos = -1\r
     FirstPos = -1\r
-    \r
+\r
     while(Count < len(LineList)):\r
         Line = LineList[Count].strip()\r
         if Line.startswith("/*"):\r
@@ -886,7 +886,7 @@ def ProcessEdkComment(LineList):
                     FindEdkBlockComment = True\r
                     break\r
                 Count = Count + 1\r
-            \r
+\r
             if FindEdkBlockComment:\r
                 if FirstPos == -1:\r
                     FirstPos = StartPos\r
@@ -900,9 +900,9 @@ def ProcessEdkComment(LineList):
             LineList[Count] = Line.replace("//", '#')\r
             if FirstPos == -1:\r
                 FirstPos = Count\r
-        \r
+\r
         Count = Count + 1\r
-    \r
+\r
     return LineList, FirstPos\r
 \r
 ## GetLibInstanceInfo\r
@@ -994,13 +994,13 @@ def GetLibInstanceInfo(String, WorkSpace, LineNo):
 ## GetLocalValue\r
 #\r
 # Generate the local value for INF and DEC file. If Lang attribute not present, then use this value.\r
-# If present, and there is no element without the Lang attribute, and one of the elements has the rfc1766 code is \r
-# "en-x-tianocore", or "en-US" if "en-x-tianocore" was not found, or "en" if "en-US" was not found, or startswith 'en' \r
+# If present, and there is no element without the Lang attribute, and one of the elements has the rfc1766 code is\r
+# "en-x-tianocore", or "en-US" if "en-x-tianocore" was not found, or "en" if "en-US" was not found, or startswith 'en'\r
 # if 'en' was not found, then use this value.\r
 # If multiple entries of a tag exist which have the same language code, use the last entry.\r
 #\r
 # @param ValueList  A list need to be processed.\r
-# @param UseFirstValue: True to use the first value, False to use the last value \r
+# @param UseFirstValue: True to use the first value, False to use the last value\r
 #\r
 # @return LocalValue\r
 def GetLocalValue(ValueList, UseFirstValue=False):\r
@@ -1040,7 +1040,7 @@ def GetLocalValue(ValueList, UseFirstValue=False):
                     Value5 = Value\r
             else:\r
                 Value5 = Value\r
-            \r
+\r
     if Value1:\r
         return Value1\r
     if Value2:\r
@@ -1051,7 +1051,7 @@ def GetLocalValue(ValueList, UseFirstValue=False):
         return Value4\r
     if Value5:\r
         return Value5\r
-    \r
+\r
     return ''\r
 \r
 \r
@@ -1088,29 +1088,29 @@ def GetCharIndexOutStr(CommentCharacter, Line):
 #\r
 # Check the UNI file path\r
 #\r
-# @param FilePath: The UNI file path \r
+# @param FilePath: The UNI file path\r
 #\r
 def ValidateUNIFilePath(Path):\r
     Suffix = Path[Path.rfind(TAB_SPLIT):]\r
-    \r
+\r
     #\r
-    # Check if the suffix is one of the '.uni', '.UNI', '.Uni' \r
+    # Check if the suffix is one of the '.uni', '.UNI', '.Uni'\r
     #\r
     if Suffix not in TAB_UNI_FILE_SUFFIXS:\r
-        Logger.Error("Unicode File Parser", \r
-                        ToolError.FORMAT_INVALID, \r
-                        Message=ST.ERR_UNI_FILE_SUFFIX_WRONG, \r
-                        ExtraData=Path)    \r
-    \r
+        Logger.Error("Unicode File Parser",\r
+                        ToolError.FORMAT_INVALID,\r
+                        Message=ST.ERR_UNI_FILE_SUFFIX_WRONG,\r
+                        ExtraData=Path)\r
+\r
     #\r
     # Check if '..' in the file name(without suffixe)\r
     #\r
     if (TAB_SPLIT + TAB_SPLIT) in Path:\r
-        Logger.Error("Unicode File Parser", \r
-                        ToolError.FORMAT_INVALID, \r
-                        Message=ST.ERR_UNI_FILE_NAME_INVALID, \r
-                        ExtraData=Path)    \r
-    \r
+        Logger.Error("Unicode File Parser",\r
+                        ToolError.FORMAT_INVALID,\r
+                        Message=ST.ERR_UNI_FILE_NAME_INVALID,\r
+                        ExtraData=Path)\r
+\r
     #\r
     # Check if the file name is valid according to the DEC and INF specification\r
     #\r
@@ -1118,8 +1118,8 @@ def ValidateUNIFilePath(Path):
     FileName = Path.replace(Suffix, '')\r
     InvalidCh = re.sub(Pattern, '', FileName)\r
     if InvalidCh:\r
-        Logger.Error("Unicode File Parser", \r
-                        ToolError.FORMAT_INVALID, \r
-                        Message=ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALID, \r
-                        ExtraData=Path)    \r
+        Logger.Error("Unicode File Parser",\r
+                        ToolError.FORMAT_INVALID,\r
+                        Message=ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALID,\r
+                        ExtraData=Path)\r
 \r