#\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
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
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
## 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
# @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
## 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
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
# <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
\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
# 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
## 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
# 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
\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
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
FindEdkBlockComment = True\r
break\r
Count = Count + 1\r
- \r
+\r
if FindEdkBlockComment:\r
if FirstPos == -1:\r
FirstPos = StartPos\r
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
## 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
Value5 = Value\r
else:\r
Value5 = Value\r
- \r
+\r
if Value1:\r
return Value1\r
if Value2:\r
return Value4\r
if Value5:\r
return Value5\r
- \r
+\r
return ''\r
\r
\r
#\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
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